Reputation: 897
I am trying to animate a line which extends or retracts over time. I found a good solution but unfortunatly the line doesnt stay fixed it moves around as well. Maybe there is a better solution to my problem. I hope someone can help me.
private function init():void{
sh.graphics.lineStyle(1.0, 0x000000, 1.0, false, LineScaleMode.NONE);
sh.graphics.moveTo(200,100)
sh.graphics.lineTo(51,51);
sh.graphics.endFill();
addChild(sh);
addEventListener(Event.ENTER_FRAME, mainLoop);
}
private function mainLoop(e:Event):void{
sh.scaleX += 0.01;
sh.scaleY += 0.01;
}
Upvotes: 0
Views: 115
Reputation: 3922
I think you want to move the sh
display object, and draw from its origin (0,0):
private function init():void{
sh.x = 200;
sh.y = 100;
sh.graphics.lineStyle(1.0, 0x000000, 1.0, false, LineScaleMode.NONE);
sh.graphics.lineTo(51,51);
addChild(sh);
addEventListener(Event.ENTER_FRAME, mainLoop);
}
Notice that I removed the call to moveTo
since the default is (0,0). I also removed the call to endFill
since you are not doing any color fills, so it is not necessary.
Upvotes: 2