开发者

360 degree rotation in flash actionscript 3

how to rotate an object 360 degree in开发者_如何学编程 as3 is any solution


Your question is very unspecific, but this is a way to animate a full rotation for a sprite:

// in your contstructor or somewhere equivalent
addEventListener(Event.ENTER_FRAME, handleEnterFrame);

// then add this function somewhere suitable
private function handleEnterFrame(e:Event):void{
    objectToRotate.rotation += 1;
}


(event.target as DisplayObject).rotation

This should really be ev.currentTarget.rotation as at times ev.target can refer to alternative object and cause errors. Plus this way, you correctly collecting the object 'as is' rather than trying to cast it to something it may not be.

For example - you could cast is as a DisplayObject (of which it is) but it may be a MovieClip.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜