开发者

360 degree rotation in flash actionscript 3

开发者 https://www.devze.com 2022-12-21 20:56 出处:网络
how to rotate an object 360 degree in开发者_如何学编程 as3 is any solutionYour question is very unspecific, but this is a way to animate a full rotation for a sprite:

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

精彩评论

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