Very basic question about Classes
Hello,
Yesterday I began to study Actionscript 3 for the first time. I did a lot of reading and I think I understand the main principals behind it. What's confusing me is actually how to put it into practise.
I have testpage.fla and buttonWork.as. On the stage of testpage.fla I've placed a movieclip (it's not been Linked in any kind of way) and given it the instance name "theButton". There are ten frames on the timeline, with the tenth frame being labelled "success" and the first containing the following code:
Code:
theButton.addEventListener(MouseEvent.CLICK, buttonWork);
stop();
Inside buttonWork.as is:
Code:
package {
import flash.display.*;
import flash.events.*;
public class buttonWork extends MovieClip {
public function buttonWork() {
gotoAndStop("success");
}
}
}
This gives me the following error:
1067: Implicit coercion of a value of type Class to an unrelated type Function.
I don't really understand what that means.
What I would like someone to tell me is if I've actually grasped the concept of how using external .as files should be done. Should the EventListener be placed in the external .as file instead of the timeline? Should the MC be Linked? Does "gotoAndStop" cause a problem being written the way I've done it?
Could somebody please answer these questions and also rearrange my code so I can see the exact correct way of doing things? As I mentioned, I'm completely new to this so being shown the precise way to go about this would be perfect.
Thank you very much!