hello as3!
this is my main class:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
public class main extends Sprite
{
public var mc1:Sprite;
public var dy = 0;
public var dx = 0;
public function main()
{
stage.addEventListener( KeyboardEvent.KEY_DOWN, keyDown );
stage.addEventListener( "enterFrame", _onEnterFrame);
mc1 = new disc();
this.addChild(mc1);
mc1.y=stage.stageHeight/2;
}
private function keyDown( event:KeyboardEvent ) : void
{
trace(event.keyCode);
var code = event.keyCode;
if(code=="39")
{
trace("ad");
dx+=3;
}
else if(code=="37")
{
trace("ad");
dx-=3;
}
if(code=="38")
{
trace("ad");
dy-=3;
}
}
private function _onEnterFrame(e:Event) : void
{
dy+=0.1;
mc1.y+=dy;
mc1.x+=dx;
}
}
}
so, i got a mc1 clip onStage (instance of “disc”) and it roams around with the key buttons.
It all works fine but it has a lot of lag… what’s wrong? my pc is fast indeed…
thank you.