While working on a Flash project this past week, I stumbled across a tiny problem that stumped me for a little while.
With all the Flash data coming in from an XML file, I could not set certain items to be clickable before runtime and assign it a "onpress" event. For this particular issue, I needed a function that would allow me to target items created at runtime.
With a little bit of rummaging through Macromedia (or Adobe's - to be more precise) Knowledgebase, I found a neat little function that potentially saved my weekend from being runneth over by "what can i do" worries.
By using a function called "asfunction", I assigned a HTML enabled text field with a HREF that pointed to an ActionScript statement. For example, I wanted my dynamic list item to execute a function called "displayAddress" when clicked.
So, I targeted my HREF like this:
<a href="asfunction:displayAddress,country">Country</a>
Once the link is clicked, the "displayAdress" function would be executed.
For functions that don't need an argument, simply remove the argument and the preceding comma.
<a href="asfunction:displayAddress">Country</a>
And that was all, simple and painless. The weekend was good too!