[Papervision3D] Tweener not executing onRollover

Justin Lawerance Mills JLM at justinfront.net
Thu Jul 24 11:13:47 PDT 2008


One approach that you can use requires a delegate such as this blokes  
class below, you can then pass the cube in the addEventListener, I am  
not saying it is ideal but it does work

// (c) 2007 Ian Thomas
// freely useable in whatever you like, as long as it's attributed.
package net.wildwinter
{

     public class Callback
     {

         public static function create( handler: Function,...args):  
Function
         {

             return function(...innerArgs):void
             {

                 handler.apply(this, innerArgs.concat(args));

             }

         }

     }

}

On 24 Jul 2008, at 18:57, Stephen Barrante wrote:

>
> Hi Xero,
>
> Thanks for the feedback. I've tried to implement some of the code you
> attached... and I'm running into an issue which I hope is just a  
> quick fix.
> It appears that displayObject3D is "undefined", according to the  
> publish
> errors. Is that something I would have needed to initialize else  
> where in my
> class? I have the cube attached to the stage using this code (in  
> pieces)
>
>
> public class ExampleCubesShadow extends Sprite {
> 	private var container:Sprite;
> 	private var scene:MovieScene3D;
> 	private var camera:Camera3D;
> 	
> 	private var cube:Cube;
> 	
> 	public function ExampleCubesShadow() {
> 		
> 		// create a container
> 		container = new Sprite;
> 		container.x = stage.stageWidth/2;
> 		container.y = stage.stageHeight/2;
> 		
> 		addChild( container );
>
> 			// create a scene
> 		scene = new MovieScene3D( container );
>
> 		// create a camera
> 		camera = new Camera3D();
> 		camera.z = -1000;
> 		camera.zoom = 5;
>
> 		// create a material
> 		// --- DEFINE SOME MATERIALS HERE --- //
> 		
> 		// create cube
> 		var cube:Cube = new Cube(materiallist, 300, 15, 125, 2, 2, 2);
> 		
> 		// rotate the cube a bit
> 		cube.rotationX = -15;
> 		cube.x = -300;
> 		
> 		// register the cube
> 		scene.addChild(cube);
>
> 		// render scene once
> 		scene.renderCamera(camera);
> 		
> 		stage.addEventListener( Event.ENTER_FRAME, myEnterFrame );
> 		
> 		// Register events for shapes
> 		cube.container.addEventListener( MouseEvent.MOUSE_OVER,  
> onMouseOver );
> 		cube.container.addEventListener( MouseEvent.MOUSE_OUT, onMouseOut );
> 	}
> }
>
>
>
>
> xero wrote:
>>
>>  hey man,
>> first off, on your mouseEvents try using
>>
>>  Tweener.addTween(event.displayObject3D, {rotationX:0, time:1});
>>
>> event.target is returning your entrie app.
>> event.displayObject3D will give your the actual cube.
>>
>> secondly,
>> i dont think your rendering will work in that fashion.
>> it will probally render the first or second frame of
>> the tween but thats it. try something like this:
>>
>> function mouseover(e:Event):void {
>>   Tweener.addTween(event.displayObject3D, {
>>        rotationX:0,
>>        time:1,
>>        onUpdate: function():void { needsRendered = true; } });
>> }
>>
>> functionRenderloop(e:Event):void {
>>   if(needsRendered){
>>      render.renderScene(scene, camera, viewport);
>>      needsRendered=false;
>>   }
>> }
>>
>> using onUpdate w/ an inline function will set the boolean  
>> "needsRendered"
>> to
>> true on each frame of the tween. in your render loop, it will  
>> check to see
>> if
>> the scene "needsRendered". if so it does it and sets the bool to  
>> false.so
>> each time there is tweening, your scene will be rendered. when the  
>> tween
>> completes the renderloop will automatically end...
>>
>> im using something VERY similar for a project at work.
>>
>> hope that helps!
>> ____  ___
>> \   \/  /___________  ____
>> .\     // __ \_  __ \/ _  \
>> ./     \  ___/ | | \( <_>  )
>> /___/\  \___  >__|---\____/
>> |     \_/   \/        |
>> | xero harrison       |
>> | xero.nu at gmail.com   |
>> | http://xero.nu      |
>> | http://fontvir.us   |
>> | http://0x000000.nu  |
>> | http://xero.owns.us |
>> `---------------------'
>>
>>
>>> ---------- Forwarded message ----------
>>> From: Stephen Barrante <stephen.barrante at storyworldwide.com>
>>> To: papervision3D at osflash.org
>>> Date: Wed, 23 Jul 2008 14:43:47 -0700 (PDT)
>>> Subject: [Papervision3D] Tweener not executing onRollover
>>>
>>> I've scanned through a bunch of posts and haven't really found an  
>>> answer
>>> to
>>> my issue, so hopefully this won't sound to repeatative. I'm  
>>> running into
>>> a
>>> situation where I have applied a MOUSE_OVER and MOUSE_OUT event to a
>>> cube.
>>>
>>> Code excerpt...
>>>
>>> // Register events for shapes
>>> cube.container.addEventListener( MouseEvent.MOUSE_OVER,  
>>> onMouseOver );
>>> cube.container.addEventListener( MouseEvent.MOUSE_OUT, onMouseOut );
>>>
>>>
>>> private function onMouseOver(event:MouseEvent):void
>>>        {
>>>                trace("I'm OVER");
>>>                Tweener.addTween(event.target, {rotationX:0, time: 
>>> 1});
>>>                // render the scene once
>>>                scene.renderCamera( camera );
>>>        }
>>>
>>> private function onMouseOut(event:MouseEvent):void
>>>        {
>>>                trace("I'm OUTA HERE");
>>>                Tweener.addTween(event.target, {rotationX:-15,  
>>> time:1});
>>>
>>>                // render the scene once
>>>                scene.renderCamera( camera );
>>>        }
>>>
>>>
>>> I've imported the Tweener class properly and tested it on other  
>>> items in
>>> the
>>> scene during the Init. e.g. I can make the camera fly across the  
>>> screen.
>>>
>>> However, it will not execute on the cube, and gives me this error:
>>>
>>> ReferenceError: Error #1069: Property rotationX not found on
>>> flash.display.Sprite and there is no default value.
>>>        at caurina.transitions::Tweener$/addTween()
>>>        at ExampleCubesShadow/::onMouseOver()
>>>
>>> Where "ExampleCubesShadow" is the name of my .as file.
>>>
>>> For the life of me I can't figure out why I can't tween the  
>>> properties of
>>> the cube, but I can just make it shift position manually.
>>>
>>> Thoughts? Questions? Need more info?
>>>
>>> Thanks!
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Tweener-not-executing-onRollover- 
>>> tp18619869p18619869.html
>>> Sent from the Papervision3D mailing list archive at Nabble.com.
>>>
>>
>> _______________________________________________
>> Papervision3D mailing list
>> Papervision3D at osflash.org
>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Tweener-not- 
> executing-onRollover-tp18619869p18637270.html
> Sent from the Papervision3D mailing list archive at Nabble.com.
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org




More information about the Papervision3D mailing list