0
votes

I have developed a rolling credits style movieclip in Flash using Actionscript 2. Text is loaded from an XML file and parsed into a dynamic textfield. This text includes hyperlinks to webpages defined by a url node in the xml so Flash can add the appropriate a href to the dynamic text field and make the link clickable.

In my first attempts to do this the textfield stayed still and all the links worked fine both testing locally and when I run it in a browser on my website.

Then I wanted to make things move ... which I achieved easily enough and tested locally (from within Flash Professional) and the links remained clickable, a browser window opened and the webpage i was expecting to see opened... great

However, when I export the swf, upload it and run it from my website suddenly the links are not working. So I tried to test the movie in a browser from Flash Pro - same problem, it must be something to do with Flash Player and the moving dynamic textfield.

a couple of observations - the cursor will change to a hand icon when over the links as you would expect, and if I right click on the link and click open in a new window the link works ok, just not when I left click. If I stop the scrolling then the links become clickable again, it is only when the textfield is moving... actually its not technically scrolling, im moving the whole textfield.

Any ideas?

1

1 Answers

1
votes

Rather than using the href property of the dynamic textField, I would suggest wrapping the textFields as MovieClips and then using the MovieClips onRelease() method.

You could load your text from your xml into the wrapped textFields, and load the associated link urls into an array. Below presumes you have a linked library symbol that is a movieclip with a dynamic textField in it. The textField's instance name is tf. The library link ID is myListItem, the ID of the container to hold the list is myListContainer. The nextY variable is for placing each link below the last, and the listItemSpacing variable is how many pixels of spacing between each list item.

DISCLAIMER - THIS IS PART PSEUDO CODE - I typed this all out without actually compiling it, so there may be typos or as2/3 syntax goofs, but it should get you going in the right direction

var listContainer = myListContainer;
var xmlList = theXmlYouHaveParsed;
var urlArray = new Array();
var nextY = 0;
var listItemSpacing = 5;
var thisInstance = this;

for(i=0; i < theXmlYouHaveParsed.length; i++)
{
     var mc = listContainer.attachMovieClip("myListItem", i+1);
     mc._y = nextY;

     mc.tf.htmlText = theXmlYouHaveParsed[i].someText;
     mc.id = String(i);

     urlArray.push(theXmlYouHaveParsed[i].someUrl);

     mc.onRelease = function()
     {
         thisInstance.onLinkClicked(this.id);
     }

     nextY += mc._height + listItemSpacing;
}

function onLinkClicked(id)
{
     getURL(urlArray[id]);
}