3DのワッカをmouseWheelでまわすテスト
サンプルは、wonderflのページそのものがスクロールしてごめんなさい
AS3.0 MouseWheel on Mac OS X
http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x
import com.pixelbreaker.ui.osx.MacMouseWheel;
/**
* Copyright sinketu ( http://wonderfl.net/user/sinketu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/tm79
*/
package
{
//サンプルは、wonderflのページそのものがスクロールしてごめんなさい
import flash.display.*;
import flash.events.*;
//AS3.0 MouseWheel on Mac OS X
//http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x
//import com.pixelbreaker.ui.osx.MacMouseWheel;
import flash.text.TextField;
public class Main extends Sprite
{
private var _container:Sprite;
private var myMcArray:Array = new Array();
private var _roll:Number=0;
private var hankei:Number;
private var movieNum:uint = 20;
private var _holder:Number=0;
private var myTextField:TextField;
public function Main() {
//MacMouseWheel.setup( this.stage );
this.addEventListener(Event.ADDED_TO_STAGE,init);
}
public function init(e:Event):void
{
var mySprite:Sprite=new Sprite();
myTextField=new TextField();
myTextField.text="クリックしてスタート";
addChild(myTextField);
stage.addEventListener(MouseEvent.CLICK,xClick);
this.removeEventListener(Event.ADDED_TO_STAGE,init);
var myBitmapData:BitmapData = new BitmapData(200, 150, false , 0xccccff);
var myBitmapData2:BitmapData = new BitmapData(200, 150, false , 0xaaaaff);
_container = new Sprite();
_container.x = stage.stageWidth / 2;
_container.y = stage.stageHeight / 2;
_container.z = 1000;
addChild(_container);
var myBitmap:Bitmap
for (var i:uint = 0; i < movieNum; i++ ) {
if (i % 2 == 0) {
myBitmap = new Bitmap(myBitmapData);
}else {
myBitmap = new Bitmap(myBitmapData2);
}
var myMovieClip:MovieClip = new MovieClip();
myMovieClip.addChild(myBitmap)
myBitmap.x = -100;
myBitmap.y = -75;
_container.addChild(myMovieClip);
myMcArray.push(myMovieClip);
}
addEventListener(Event.ENTER_FRAME, xEnterFrame);
hankei = 150 * movieNum / (2 * Math.PI);
stage.addEventListener( MouseEvent.MOUSE_WHEEL, onMouseWheel );
}
private function xClick(e:MouseEvent):void{
myTextField.visible=false;
myTextField=null;
stage.removeEventListener(MouseEvent.CLICK,xClick);
}
private function onMouseWheel( e:MouseEvent ):void
{
_holder += e.delta*2;
}
private function xEnterFrame(e:Event):void
{
_container.rotationY = stage.mouseX/4-stage.stageWidth/2+180;
_roll += (_holder - _roll) / 5;
for (var i:uint = 0; i < myMcArray.length; i++ ) {
var myMc:MovieClip = myMcArray[i];
myMc.y = Math.sin((_roll+i*360/movieNum)*Math.PI/180 )* hankei;
myMc.z = Math.cos((_roll+i* 360 / movieNum )* Math.PI / 180) * hankei;
myMc.rotationX = -_roll-i* 360 / movieNum;
}
var myMcArray2:Array = myMcArray.concat();
myMcArray2.sortOn("z", Array.DESCENDING | Array.NUMERIC);
for (var j:uint = 0; j < myMcArray2.length; j++ ) {
myMc= myMcArray2[j]
_container.setChildIndex(myMc, j);
}
}
}
}