Reputation: 3
I had originally started with writing code within timeline and now trying to use classes. I wanted to know how i would bind a symbol so that when it is clicked it will switch frame, but doing this using classes.
I have a main menu button that i converted to a symbol and created a class file, but don't know where to get started. In the timeline i would have just created an Event listener(Mouse click), i tried doing the same thing and it doesn't seem to be working.
This is my code.
This class is linked to the main menu symbol.
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent
public class mainM extends MovieClip {
public function mainM() {
addEventListener(MouseEvent.CLICK,clicked)
}
public function clicked(e:MouseEvent)
{
gotoAndStop(2);
}
}
}
Upvotes: 0
Views: 59
Reputation: 14406
First, you need to attach the class file to the symbol in FlashPro. You do that by right clicking it in the library and choosing "properties", then "export for actionscript" and put in the path to class file (less the .as)
If you creating the class file in flash pro (via the pencil icon), it doesn't actually do anything with it. Save the file (next to your .fla), then it should work.
Upvotes: 3