onClick buttons in Actionscript 3

Actions are no longer applied directly to buttons in Actionscript 3. Instead all code can be placed on the main timeline. For a basic getURL you first createa function, then you add an Event Listener to the button instance. Code below:

———————————————–

function gotoPage(event:MouseEvent):void
{

var targetURL:URLRequest = new URLRequest(”http://www.sitedesignmagazine.com/”);
navigateToURL(targetURL,’_self’);

}

skip_btn.addEventListener(MouseEvent.CLICK,gotoPage);

———————————————–

Replace skip_btn with the instance name of your own button.

NOTE: For some reason WordPress converts my quotes (both single and double) to smart quotes or whatever. You will need to change those when you paste or you’ll get syntax errors.

3 Responses to “onClick buttons in Actionscript 3”

  1. Get Rid of Pimple Says:

    I was just googling around about this when I stumbled on your blog post. I’m simply visiting to say that I really enjoyed seeing this post, it’s very clear and well written. Are you planning topost more on this? It looks like there’s more material here for future posts.

  2. Virginia web design Says:

    This is a great blog post. . It’s really nice and informative. Thanks so much.

  3. prabhakar Says:

    thanks for sharing .

Leave a Reply

This entry was posted on Thursday, July 30th, 2009 at 6:29 am and is filed under Flash Design & Development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.