|
| lavlav |
Post
#1
|
|
Member Group: Members Posts: 22 Joined: 18-October 06 Member No.: 484 |
I will told you the goal first
I make a plan3D with continue rotation and mapping a photo on the plan , and then when rotation 1 times , I set a random number, so that it can change other plan3D with other photo I am using "RotationInterpolator" and add listener but i find that when loading more time , about 15 times the "RotationInterpolator" is not working correct it will go to the next step , but the rotation is not complete I post the code in here, or may be it is write incorrect...... CODE import sandy.core.data.*; import sandy.core.group.*; import sandy.primitive.*; import sandy.view.*; import sandy.core.*; import sandy.skin.*; import sandy.util.*; import sandy.core.transform.*; import sandy.events.*; var loc5=new Object(); loader = new MovieClipLoader(); loc5.onLoadInit =function(_holder){ init(); } function init (Void):Void { var ecran:ClipScreen = new ClipScreen (this.createEmptyMovieClip('ecran',1),480,480); var cam:Camera3D = new Camera3D(800,ecran); // Position the camera cam.setPosition(400,0,0); // Look at the origin cam.lookAt(0,0,0); // Attach the camera to the world World3D.getInstance().addCamera(cam); var bg:Group = new Group(); createObject3D_1(bg); World3D.getInstance().setRootGroup(bg); World3D.getInstance().render(); } var rotint1:RotationInterpolator; function createObject3D_1( bg:Group ):Void { // We create our object. It is a cube of 50 pixels var o:Object3D = new Plane3D( 150, 150 ); // Now we simply link the Object leaf to the root node, and finish the tree creation var tg1:TransformGroup = new TransformGroup(); var tg2:TransformGroup = new TransformGroup(); var translation:Transform3D = new Transform3D(); var ease:Ease = new Ease(); ease.linear(); translation.rot(-90,45,0); tg2.setTransform(translation); tg1.setTransform(rotint1); tg2.addChild(o1); tg1.addChild(tg2); bg.addChild(tg1); rotint1 = new RotationInterpolator(ease.create(),200);//changed rotint1.addEventListener( InterpolationEvent.onProgressEVENT, this , onRender ); rotint1.addEventListener( InterpolationEvent.onEndEVENT, this , onEnd ); } function onEnd(e:InterpolationEvent):Void { var n:Number = randRange(1, 20); if(n==1) { unloadMovieNum(98); loadMovieNum("01plan3D.swf",98); } if(n==2) { unloadMovieNum(98); loadMovieNum("02plan3D.swf",98); } if(n==3) { unloadMovieNum(98); loadMovieNum("04plan3D.swf",98); } if(n==4) { unloadMovieNum(98); loadMovieNum("04plan3D.swf",98); } if(n==5) { unloadMovieNum(98); loadMovieNum("05plan3D.swf",98); } else { rotint1.redo(); } } function onRender( e:InterpolationEvent ) { var difX:Number = 600 - _xmouse; var difY:Number = 500 - _ymouse; var dist:Number = Math.sqrt( difX*difX + difY*difY ); rotint1.setPointOfReference( new Vector( 0, 75, 0) ); RotationInterpolator(e.getTarget()).setAxisOfRotation( new Vector( 0, 90, 0) ); RotationInterpolator(e.getTarget()).setDuration( 42000 / dist ); } function randRange(min:Number, max:Number):Number { var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min; return randomNum; } loader.addListener(loc5); // We lauch the animation creation. init(); 01plan3D.swf to 05plan3D.swf is the same code , only is the skin color not the same |
| kiroukou |
Post
#2
|
|
Administrator Group: Root Admin Posts: 881 Joined: 12-June 06 Member No.: 1 |
Hi
your code seems correct. What I need is you to explain me this : QUOTE about 15 times the "RotationInterpolator" is not working correct it will go to the next step , but the rotation is not complete thx |
| lavlav |
Post
#3
|
|
Member Group: Members Posts: 22 Joined: 18-October 06 Member No.: 484 |
sorry for that
when I load other file 01-05plan3D.swf, they also have a "RotationInterpolator" ,so that made it incorect I shall add "removelistener" or the 01-05plan3D.swf don't use "RotationInterpolator" I think it is the point of mistake This post has been edited by lavlav: Nov 25 2006, 07:14 PM |
| Lo-Fi Version | Time is now: 29th July 2007 - 08:28 AM |