Viewing "Dhana's" Blogs

Jun
27

Flash "asfunction"

By Dhana Shunmugasundram | Posted on 2007 3:15 PM | Comments on 0 comments

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!

This post is categorized under: Flash

  • Blog Tools:
  • Del.cio.us
  • Google
  • Stumbleupon
  • Yahoo

Leave a Comment

* Name:
* Email: (will not be displayed)
URL:
* Comment:
Enter the code shown:

  • Anonymous Comments Are Enabled
  • Moderated Comments Are Enabled
  • Fields marked with an asterisk (*) are required.
  • a, strong, em and code tags are allowed. Line breaks and paragraphs are automatically generated. Inappropriate comments will be either deleted or edited.