elveatles
06-15-2008, 09:22 PM
Hi, I've just started learning AS3 so I bought the book "Learning ActionScript 3.0". I copies one of the examples exactly as it was written in the book, yet I got the error: "1046: Type was not found or was not a compile-time constant: Event."
Here's the code (it tells me the error is on the line that says
"public function onLoop(evt:Event):void":
package
{
import flash.display.MovieClip;
import flash.display.Graphics;
import flash.display.Event;
public class Box extends MovieClip
{
public var color:uint = 0x000099;
public function Box()
{
//draw a shape at runtime
this.graphics.lineStyle(1, 0x000000);
this.graphics.beginFill(color);
this.graphics.drawRect(0, 0, 100, 100);
this.graphics.endFill();
this.addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);
}
public function onLoop(evt:Event):void //Error line
{
this.x += 5;
}
}
}
Makes no sense to me why it refuses to work.
Here's the code (it tells me the error is on the line that says
"public function onLoop(evt:Event):void":
package
{
import flash.display.MovieClip;
import flash.display.Graphics;
import flash.display.Event;
public class Box extends MovieClip
{
public var color:uint = 0x000099;
public function Box()
{
//draw a shape at runtime
this.graphics.lineStyle(1, 0x000000);
this.graphics.beginFill(color);
this.graphics.drawRect(0, 0, 100, 100);
this.graphics.endFill();
this.addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);
}
public function onLoop(evt:Event):void //Error line
{
this.x += 5;
}
}
}
Makes no sense to me why it refuses to work.