I´m 开发者_C百科trying to display two movie clips on the scene. I made an action script file called main.as and the .fla file is calling the main class. The button class is a button movieclip.
This is the code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events;
public class button extends SimpleButton {
public function button() {
// constructor code
}
}
}
public class main extends MovieClip {
private var button1:button = new button;
private var button2:button = new button;
public function main() {
// constructor code
button1.x = 550/4*3;
button1.y = 400/4*3;
addChild(boton1);
button2.x = 550/4*3;
button2.y = 400/4*3;
addChild(boton2);
button1.addEventListener(MouseEvent.CLICK,pressButton);
}
private function pressButton(e:Event){
trace("Pressing button");
}
}
}
I don´t know what went wrong, this error pops up in the console:
S:\flash3\Clase2\main.as, Line 24 1046: Type was not found or was not a compile-time constant: Event.
The error means you need to import flash.events.Event in your class. However you should use MouseEvent in your function instead, not Event.
private function pressButton(event : MouseEvent) : void
{
//
}
1:
addChild(boton1);
should be written with 2x 't'
addChild(botton1);
2:
pressButton(e:Event){
should be
pressButton(e:MouseEvent){
and you should import flash.events.MouseEvents
精彩评论