The following example shows how you can 3D rotate a Sprite object around its x-axis with Flash, ActionScript 3.0, and Flash Player 10 by setting the object’s rotationX property.
Full code after the jump.
// http://actionscriptexamples.com/2009/02/26/rotating-a-sprite-object-around-its-x-axis-in-flash-using-actionscript-30-and-flash-player-10/ // ActionScript 3.0 /** Requires: * - Slider control in Flash library. * - Publish for Flash Player 10. */ [SWF(width="400", height="300")] import fl.controls.Slider; import fl.controls.SliderDirection; import fl.events.SliderEvent; var slider:Slider = new Slider(); slider.direction = SliderDirection.HORIZONTAL; slider.minimum = 0; slider.maximum = 360; slider.value = 45; slider.tickInterval = 45; slider.snapInterval = 1; slider.liveDragging = true; slider.addEventListener(SliderEvent.CHANGE, slider_change); slider.move(10, 10); addChild(slider); var spr:Sprite = new Sprite(); spr.graphics.lineStyle(2, 0xFF0000); spr.graphics.drawRect(0, 0, 100, 80); spr.x = Math.round((stage.stageWidth - spr.width)/2); spr.y = Math.round((stage.stageHeight - spr.height)/2); spr.rotationX = 45; addChild(spr); function slider_change(evt:SliderEvent):void { spr.rotationX = evt.value; }
{ 1 comment… read it below or add one }
Recent Posts
* Adding tick marks to a Slider control in Flash using ActionScript 3.0
* Creating a vertical Slider control in Flash using ActionScript 3.0
* Creating a custom context menu item in Flash using ActionScript 3.0
* Rotating a Sprite object around its x-axis in Flash using ActionScript 3.0 and Flash Player 10 Recent Posts
* Adding tick marks to a Slider control in Flash using ActionScript 3.0
* Creating a vertical Slider control in Flash using ActionScript 3.0
* Creating a custom context menu item in Flash using ActionScript 3.0
* Rotating a Sprite object around its x-axis in Flash using ActionScript 3.0 and Flash Player 10