ogaac
09-08-2010, 12:20 AM
I'm trying to create a navigation bar that works like a game. An instance of a ship is called in with code, which fires lasers when you click your left mouse.
And instance of a move clip (acting as a button) is on the stage (not imported with code) and my Engine.as is as follows:
package com.asgamer.basics1
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
import flash.display.DisplayObject;
public class Engine extends MovieClip
{
private var ourShip:Ship;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
public function Engine() : void
{
ourShip = new Ship(stage);
stage.addChild(ourShip);
ourShip.x = stage.stageWidth / 2;
ourShip.y = stage.stageHeight / 1.1;
}
// in your document class:
private function onEnterFrame(e:Event):void
{
if (LaserBlue.hitTestObject(homeButton))
trace ("Get URL")
}
}
When I compile this code, I get a few errors.
Line 32 1061: Call to a possibly undefined method hitTestObject through a reference with static type Class.
Didn't I define the method with my event listener and import.displayObject?
Line 8 1180: Call to a possibly undefined method addEventListener.
Again, didn't I define this already?
Line 8 1120: Access of undefined property onEnterFrame.
I won't repeat myself.
If I have these errors, obviously I didn't define the method, but I don't see where I went wrong.
Any ideas? Anything would be appreciated!
And instance of a move clip (acting as a button) is on the stage (not imported with code) and my Engine.as is as follows:
package com.asgamer.basics1
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
import flash.display.DisplayObject;
public class Engine extends MovieClip
{
private var ourShip:Ship;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
public function Engine() : void
{
ourShip = new Ship(stage);
stage.addChild(ourShip);
ourShip.x = stage.stageWidth / 2;
ourShip.y = stage.stageHeight / 1.1;
}
// in your document class:
private function onEnterFrame(e:Event):void
{
if (LaserBlue.hitTestObject(homeButton))
trace ("Get URL")
}
}
When I compile this code, I get a few errors.
Line 32 1061: Call to a possibly undefined method hitTestObject through a reference with static type Class.
Didn't I define the method with my event listener and import.displayObject?
Line 8 1180: Call to a possibly undefined method addEventListener.
Again, didn't I define this already?
Line 8 1120: Access of undefined property onEnterFrame.
I won't repeat myself.
If I have these errors, obviously I didn't define the method, but I don't see where I went wrong.
Any ideas? Anything would be appreciated!