код АС3 работает, а haXe нет(не вращается box)
((((
в чем грабли?
AS3:
Код AS3:
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite
{
private var box:MovieClip;
private function draw():void {
with (box.graphics) {
beginFill(0xffff00);
lineStyle(3, 0x000000, 1);
drawRect( -100, -100, 200, 200);
endFill();
}
}
private function RotateBox(e:Event):void {
box.rotationX++;
box.rotationY++;
box.rotationZ++;
}
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
box = new MovieClip();
draw();
stage.addChild(box);
box.x = stage.stageWidth / 2;
box.y = stage.stageHeight / 2;
addEventListener(Event.ENTER_FRAME, RotateBox);
}
}
}
haXe:
Код AS3:
package ;
import flash.display.MovieClip;
import flash.events.Event;
import flash.Lib;
class Main
{
private var box:MovieClip;
private function draw():Void {
box.graphics.beginFill(0xffff00);
box.graphics.lineStyle(3, 0x000000, 1);
box.graphics.drawRect( -100, -100, 200, 200);
box.graphics.endFill();
}
private function RotateBox(e:Event):Void {
box.rotationX++;
box.rotationY++;
box.rotationZ++;
}
public function new():Void {
box = new MovieClip();
draw();
Lib.current.addChild(box);
box.x = Lib.current.stage.stageWidth / 2;
box.y = Lib.current.stage.stageHeight / 2;
Lib.current.addEventListener(Event.ENTER_FRAME, RotateBox);
}
static function main()
{
new Main();
}
}