how to change actionscript 1-2 to actionscript 3-Collection of common programming errors
In flash, I created a button and gave the button this code (in AS1-AS2)
on (release)
{
gotoAndPlay(5);
tellTarget("/Anim") //'Anim' is just short form for 'an animation'
{
gotoAndPlay(5);
} // End of TellTarget
}
Since you can’t give specific buttons actions in AS3, I gave the button an instance name (the buttons instance name is now ‘runButton’) and then decided to do this in the actions layer.
runButton.addEventListener(MouseEvent.CLICK, startAnimation);
function startAnimation(event:MouseEvent){
gotoAndPlay(5);
tellTarget("/Anim")
{
gotoAndPlay(5);
} // End of TellTarget
}
but it is giving me an error saying that a ‘{‘ is expected after the
function startAnimation(event:MouseEvent):void{
line and it is saying that there is an unexpected ‘}’ on the last line. Any idea how to fix this?
Note: Anim is a movieclip on the main timeline. When I double click the Anim movieclip, it has it’s own timeline. I want that timeline to play along with the main timeline, hence the ‘gotoandPlay(5) and then the other gotoAndPlay after doing ‘tellTarget(Anim’).