tadster
04-23-2011, 02:30 AM
package {
import flash.display.*;
import EnemyClass;
public class Main extends Sprite {
private var commonPath:Array =
[0,0,4,4,8,9,10,10,12,12,14,12,21,24,34,38,34,50,34 ,75,34,100,34,150,34,200,34,150,34,300,34,350,34,5 00];
public function Main() {
addEnemy();
}
public function addEnemy():void {
addChild(new EnemyClass(commonPath));
}
}
}
package {
import flash.display.Sprite;
import flash.events.Event;
public class EnemyClass extends Sprite {
public var path:Array = [];
public function EnemyClass(path:Array = null) {
this.path = path;
with(this.graphics) {
beginFill(0xFF0000);drawCircle(0,0,20);
}
if(!stage) addEventListener(Event.ADDED_TO_STAGE, startMoving) else startMoving(null);
}
private function startMoving(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, startMoving);
addEventListener(Event.ENTER_FRAME, move);
}
private function move(e:Event):void {
if(path.length >= 2) {
this.x = path.pop();
this.y = path.pop();
} else {
removeEventListener(Event.ENTER_FRAME, move);
parent.removeChild(this);
(parent as Main).addEnemy();
}
}
}
}
Something like that should get you started.
kidshenlong
04-24-2011, 07:05 PM
Ahhh I know what you mean. So how would I then go about giving "blah" a definition?
And when I traced it gave me this:
0,0,4,4,8,9,10,10,12,12,14,12,21,24,34,38,34,50,34 ,75,34,100,34,150,34,200,34,150,34,300,34,350
0,0,4,4,8,9,10,10,12,12,14,12,21,24,34,38,34,50,34 ,75,34,100,34,150,34,200,34,150,34,300
0,0,4,4,8,9,10,10,12,12,14,12,21,24,34,38,34,50,34 ,75,34,100,34,150,34,200,34,150
0,0,4,4,8,9,10,10,12,12,14,12,21,24,34,38,34,50,34 ,75,34,100,34,150,34,200
0,0,4,4,8,9,10,10,12,12,14,12,21,24,34,38,34,50,34 ,75,34,100,34,150
0,0,4,4,8,9,10,10,12,12,14,12,21,24,34,38,34,50,34 ,75,34,100
0,0,4,4,8,9,10,10,12,12,14,12,21,24,34,38,34,50,34 ,75
0,0,4,4,8,9,10,10,12,12,14,12,21,24,34,38,34,50
0,0,4,4,8,9,10,10,12,12,14,12,21,24,34,38
0,0,4,4,8,9,10,10,12,12,14,12,21,24
0,0,4,4,8,9,10,10,12,12,14,12
0,0,4,4,8,9,10,10,12,12
0,0,4,4,8,9,10,10
0,0,4,4,8,9
0,0,4,4
0,0
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at EnemyClass/move()
vBulletin® v3.8.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.