PDA

View Full Version : Problem with buttons



WEich1213
March 12th, 2009, 09:06 PM
I'm trying to add actionscript to a button that says:

on (release) {
//Goto Webpage Behavior
getURL("http://www.thefwa.com?","_blank");
//End Behavior

}

but when I click the button it won't let me write any actionscript, it says"current selection cannot have actions applied to it."
I've done this before with no problem I don't know why it won't let me do it with this button. Any suggestions? Thanks WEich1213

miyijura
March 13th, 2009, 08:50 PM
In AS3 you must place all of your code in the timeline. No code is allowed to place in the instances.
The correct code must be something like:

myButton.addEventListener(MouseEvent.CLICK, theNavigationFunctionToRun);

function theNavigationFunctionToRun(e:MouseEvent):void{
var request:URLRequest = new URLRequest("http://www.adobe.com/");
navigateToURL(request);
}

Check some AS2 to AS3 tutorials so you can fill all the blanks.
Here´s a very good one
http://www.senocular.com/flash/tutorials/as3withflashcs3/#objects

Good luck!