How to make a button
Make a button and call it - btn.
AS3 is very different to AS2, in this case you can not write code directly on a button so you must make a new layer (call it as or actionscript, whatever is easier) and write all the code on this button.
Now make sure the button is called btn and on the as layer (as layer must be the top layer and no objects can be on this layer) write out the following code:
import flash.events.MouseEvent;
btn.addEventListener(MouseEvent.CLICK,pressed1);
function pressed1(e:MouseEvent){
trace('true');
}
AS3 'listens' out for code, in this case it is listening for 'mouse clicks'. On the third line of code the e just before the : does not have to be and e but it is easier to have it, thinking "e stands for event handler".
No comments:
Post a Comment