What does it mean? And why doesnt my code work?
stop();
import flash.events.Event;
var TimerApple:Timer = new Timer(500);
TimerApple.addEventListener(TimerEvent.TIMER, OnStartApple);
TimerApple.start();
function OnStartApple(e:Event){
var af:Sprite = new Enemy();
af.x= Math.random()*640;
addChild(af);
//Remove from stage, will give point
af.addEventListener(Event.ENTER_FRAME, hitTheGround)
function hitTheGround (e:Event):void
{
if(af.hitTestObject(Basket)){
removeChild(af);
}
}
//Controlling basket
Basket.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);
function fl_ClickToDrag_2(event:MouseEvent):void
{
Basket.startDrag();
}
}
And then the class “Enemy”
package {
import flash.events.Event;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.text.TextField;
public class Apple extends Sprite {
private var core:Object;
public function Apple() {
addEventListener(Event.ADDED_TO_STAGE,onadd);
}
private function onadd(e:Event) {
core=MovieClip(root);
addEventListener(Event.ENTER_FRAME,loop);
}
private function loop(e:Event) {
y+=10;
}
public function removeListeners():void {
removeEventListener(Event.ENTER_FRAME, loop);
}
}
}