My first hand with the ENTER_FRAME event. Still pretty confused about event flow... The yVel is not tracing and the Player instance is not falling off the screen like it is supposed to, so I'm not sure if the EventListener is right. I'm starting to really love flashkit and all the merciful help they've bestowed upon me. You guys are GREAT! Thanks in advance!Code:package { import flash.display.MovieClip; import flash.events.Event; public class Player extends MovieClip { //Constructs Registration Areas for placing aroud Player public var fReg:FloorReg; public var rReg:RightReg; public var lReg:LeftReg; public var cReg:CeilingReg; //Constructs velocity vars private var yVel:Number=0; private var xVel:Number=0; public const TERMINAL_VELOCITY:Number=-7; public function Player() { //This is adding registration areas to the display object var oHeight:Number=this.height; fReg=new FloorReg(0,this.height,this.height/4,this.width); addChild(fReg); rReg=new RightReg(this.width,0,this.height-fReg.height,this.width/4); addChild(rReg); lReg=new LeftReg(this.width/-4,0,this.height-fReg.height,this.width/4); addChild(lReg); cReg=new CeilingReg(0,this.height/-5,oHeight/4,oHeight); addChild(cReg); spawn(); } private function spawn():void { //direct player object to it's spawning animation and initialize the Fall function trace("spawnd"); addEventListener(Event.ENTER_FRAME, fall, excecuteVelocity); } private function fall(event:Event):void { if(yVel < TERMINAL_VELOCITY) { yVel--; trace(yVel); } } private function excecuteVelocity(event:Event):void { this.y -= yVel; this.x += xVel; } } }




Reply With Quote
