views:

35

answers:

1

I'm am super new at this, and this is my first time ever using Adobe. I get the "joy" of doing a project in my school using The CS4 Suite. I was playing around and using this book to help me get a button to start an action. I have tried many different codings, but this one gets me the least amount of errors. This is what I have so far:

var isPlaying = false;
this.myButton.addEventListener(MouseEvent.MOUSE_DOWN, onButtonClicked);
this.myButton.onButtonClicked = function(){
 gotoAndPlay(5);
}

Line 3, Error 1119: Access of undefined property onButtonClicked. Line 5, Error 1120: Access of possibly undefined property onButtonClicked through a reference with static type ...What am I doing wrong?

+1  A: 

The function called by the event should not be set like that. The code that you have is more like Javascript than ActionScript.

var isPlaying = false;

this.myButton.addEventListener(MouseEvent.CLICK, onButtonClicked);

function onButtonClicked(event:MouseEvent):void {

    gotoAndPlay(5);

}

Also, try to read documentation, more info on:

http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000376.html
jpabluz
Thank you SO much! Those tiny edits made a BIG difference on it working and errors everywhere. I think that will become a main theme with the scripting, eh? ;)
Cody B.