|
View:
New views
14 Messages
—
Rating Filter:
Alert me
|
|
|
Tweener not executing onRolloverI'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! |
|
|
Re: Tweener not executing onRolloverisn't target a Sprite in your mouse event handler? it of course doens't have rotationX, but Cube does. So I think you just need to change your target that you pass to tweener
On Wed, Jul 23, 2008 at 4:43 PM, Stephen Barrante <stephen.barrante@...> wrote:
-- [ JPG ] _______________________________________________ Papervision3D mailing list Papervision3D@... http://osflash.org/mailman/listinfo/papervision3d_osflash.org |
|
|
|
|
|
Re: Tweener not executing onRolloverHi 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 ); } }
|
|
|
Re: Tweener not executing onRolloverOne 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@... | >> | http://xero.nu | >> | http://fontvir.us | >> | http://0x000000.nu | >> | http://xero.owns.us | >> `---------------------' >> >> >>> ---------- Forwarded message ---------- >>> From: Stephen Barrante <stephen.barrante@...> >>> To: papervision3D@... >>> 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@... >> 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@... > http://osflash.org/mailman/listinfo/papervision3d_osflash.org _______________________________________________ Papervision3D mailing list Papervision3D@... http://osflash.org/mailman/listinfo/papervision3d_osflash.org |
|
|
Re: Tweener not executing onRolloverIn your case - events that act on a single target, using a method on the
same class that contains the cube - you can just pass the cube as the target without a lot of fuss. Tweener.addTween(cube, {rotationX:0, time:1}); There's nothing left to initialize. It's all a matter of targeting the cube object properly. Because the event is initiated by its *container*, not the 3d object, you cannot use the event target directly - it refers to the sprite container, which may be controlled by the displayobject3d "cube", but is by all means independent from it. In case you need a bunch of different 3d objects all using the same event, you'll need some way to create the proper references. But in case of a method acting on a single object, the above code is enough. Zeh 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@... | >> | http://xero.nu | >> | http://fontvir.us | >> | http://0x000000.nu | >> | http://xero.owns.us | >> `---------------------' >> >> >>> ---------- Forwarded message ---------- >>> From: Stephen Barrante <stephen.barrante@...> >>> To: papervision3D@... >>> 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@... >> http://osflash.org/mailman/listinfo/papervision3d_osflash.org >> >> > _______________________________________________ Papervision3D mailing list Papervision3D@... http://osflash.org/mailman/listinfo/papervision3d_osflash.org |
|
|
Re: Tweener not executing onRolloverHey Zeh! Been a while since we've spoke... just getting started with Tweener and complicating it with Papervision 3D, heh. Thanks for chiming in!
I am trying to create a menu system... so capturing events on an individual object basis is important. I had used that at one point: Tweener.addTween(cube, {rotationX:0, time:1}); ... but something happens. The rollovers process fine... but there is NO animation applied to the cube itself. I've even changed properties, e.g. x:800 or z:0... etc... nothing. I know the Tweener class is loaded in an working, because if I change that code to: Tweener.addTween(camera, {z:0, time:1}); On rollOver of my cube... I fly right into the scene (kind of cool actually). I'm pretty stumped. I must be targetting the cube wrong from inside that onMouseOver function. I just don't know what that path would be. In the past I had tried cube, cube.container, _parent.cube... and I get errors.... Thoughts?
|
|
|
Re: Tweener not executing onRolloverHey Stephen,
> Tweener.addTween(cube, {rotationX:0, time:1}); > ... but something happens. The rollovers process fine... but there is NO > animation applied to the cube itself. I've even changed properties, e.g. > x:800 or z:0... etc... nothing. Try trace()ing "cube" inside of that function to see what gives. It probably IS working; but the scene is not getting re-rendered. This is what Xero talked about on a previous message. Just to test, be sure to include something like scene.renderCamera(camera); On your enter_frame loop. You can find better ways of disabling/pausing it later, but as a starting point, it's much easier to simply run it nonstop. They don't have/shouldn't be inside the mouse event methods. > I know the Tweener class is loaded in an working, because if I change that > code to: > Tweener.addTween(camera, {z:0, time:1}); > On rollOver of my cube... I fly right into the scene (kind of cool > actually). Now this is the weird part. If the camera animation is working, the cube animation should be working too. So in this case, I don't know what gives. If you're not using the repetitive rendering above, I advise you do and see if it works. In case you're already doing it.. there's something really strange with that cube, like it's not the actual render cube, or its properties are getting reset, or something weird of the sort. Zeh _______________________________________________ Papervision3D mailing list Papervision3D@... http://osflash.org/mailman/listinfo/papervision3d_osflash.org |
|
|
Re: Tweener not executing onRolloverI may be using trace wrong... but I put trace(cube) inside the function... and it returns "null". I'm fairly new to AS3... so I apologize.
I have omitted the fact that I do have an enterFrame function that continually re-renders the scene... I also added that scene.renderCamera(camera) in the rollOvers for good measure. I hate feeling dumb - heh... but this wouldn't be the first targetting issue I've spent hours on... I appreciate your time. Steve
|
|
|
Re: Tweener not executing onRollover> I may be using trace wrong... but I put trace(cube) inside the function...
> and it returns "null". I'm fairly new to AS3... so I apologize. Okay, so cube isn't found. Contrary to what I stated/believed, it doesn't exist on that function scope. > I have omitted the fact that I do have an enterFrame function that > continually re-renders the scene... I also added that > scene.renderCamera(camera) in the rollOvers for good measure. > I hate feeling dumb - heh... but this wouldn't be the first targetting issue > I've spent hours on... > I appreciate your time. Don't worry. AS3 is a better language but it's pretty odd at first, coming from an AS2 background. Some things may look backwards. I think I've missed the whole scope though. I thought cube was acessible from those events. Do you mind posting a stripped down version of your class with the methods used? Zeh _______________________________________________ Papervision3D mailing list Papervision3D@... http://osflash.org/mailman/listinfo/papervision3d_osflash.org |
|
|
Re: Tweener not executing onRolloverHey Zeh, not sure how much to strip out... so here is what I'm working with. It's nothing magical, so I don't mind sharing it...
package { import flash.display.*; import flash.geom.*; import flash.utils.* import flash.events.*; import flash.filters.*; import org.papervision3d.cameras.Camera3D; import org.papervision3d.scenes.MovieScene3D; import org.papervision3d.objects.*; import org.papervision3d.materials.*; import caurina.transitions.Tweener; [SWF(width='990',height='590',backgroundColor='0x000000',frameRate='30')]; public class ExampleCubesShadow extends Sprite { private var container:Sprite; private var scene:MovieScene3D; private var camera:Camera3D; private var cube:Cube; private var cube2:Cube; public function ExampleCubesShadow() { // create a container container = new Sprite; container.x = stage.stageWidth/2; container.y = stage.stageHeight/2; addChild( container ); trace("stageWidth: " + stage.stageWidth + " stageHeight: " + stage.stageHeight); // create a scene scene = new MovieScene3D( container ); // create a camera camera = new Camera3D(); camera.z = -1000; |