Question

I'm very new to ActionScript 3, and I've followed this toturial on adobe TV. But I don't get it to work. The thing is that I want the box to move left/right when I click the buttons, but nothing happens.

You can download the .fla file here:

http://www.habitats.no/files/AC3.zip

Thanks.

Was it helpful?

Solution

You need to name your instances. Click on one of the movie clips on the stage and bring up the properties window, you should see an input for instance name. The way you've coded it the instance name should be the same as the clips name i.e. mc_box.

OTHER TIPS

You must to give your objects names, for example you have:

  1. Button - you must to put the name for Button in panel properties of button - myBtn (the name of button in Instance name field) ;

  2. Box - you must to put the name for Box in panel properties of Box (is movieClip) - myBox (the name of Box in Instance name field) ;

and write this code in actions:

myBtn.addEventListener(MouseEvent.CLICK, moveBox);
function moveBox(event):void
{
    Box.x+=25;
}

// addEventListener - Registers an event listener for the target event.

When you call AddEventListener () reported two parameters:

  • An event which should respond to the application;
  • A function which is a reaction to this event.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top