[Papervision3D] movieAssetMaterial play and stop

Javier España | javierespana.com info at javierespana.com
Wed Jul 15 08:59:42 PDT 2009


I'm tracing this:

trace(movieAssetMaterial);
trace(movieAssetMaterial.movie);
trace(movieAssetMaterial.movie.animatedDoll);

First two are ok, but the last one generates 3 errors, any ideas?

1119: Access to a possibly undefined property animatedDoll through a
reference with static type flash.display:DisplayObject

Maybe this will help someone help me =)

2009/7/15 Javier España | javierespana.com <info at javierespana.com>

> Tried both of those solutions and none of them worked :S I seem to be
> missing something :S Any other ideas?
>
>
> On Tue, Jul 14, 2009 at 7:31 PM, Mark I. Ross <nospam at therossman.org>wrote:
>
>>  what if you just replace these two lines:
>>
>> var obj:*= getMaterial(plane as displayObject3D);
>> obj.animatedDoll.stop();
>>
>> with:
>>
>> movieAssetMaterial.movie.animatedDoll.stop();
>>
>>
>> also if you aren't going to do that, or it doesn't work, the other
>> suggestion is:
>>
>> var obj:*= getMaterial(plane as displayObject3D);
>>
>> should be:
>>
>> var obj:*= getMaterial(walkingDoll as displayObject3D);
>>
>>
>> HTH,
>> mark
>>
>>
>>
>> Javier España | javierespana.com wrote:
>>
>> Nope, can't seem to make it work, I may be doing something wrong... Here's
>> the complete code:
>>
>> -----------------------------
>>
>> package{
>>     ///
>>     import flash.display.Sprite;
>>     import flash.events.Event;
>>     import flash.events.MouseEvent;
>>     ///
>>     import org.papervision3d.view.Viewport3D;
>>     import org.papervision3d.scenes.Scene3D;
>>     import org.papervision3d.cameras.Camera3D;
>>     import org.papervision3d.materials.*;
>>     import org.papervision3d.objects.primitives.Plane;
>>     import org.papervision3d.render.BasicRenderEngine;
>>     ///
>>     import org.papervision3d.lights.PointLight3D;
>>     import org.papervision3d.materials.shaders.GouraudShader;
>>     import org.papervision3d.materials.shaders.ShadedMaterial;
>>     ///
>>     public class walkingTest_04 extends Sprite{
>>         ///
>>         // VARIABLES
>>         ///
>>         private var viewport:Viewport3D;
>>         private var scene:Scene3D;
>>         private var camera:Camera3D;
>>         private var movieAssetMaterial:MovieAssetMaterial;
>>         private var walkingDoll:Plane;
>>         private var renderer:BasicRenderEngine;
>>         ///
>>         // MATERIAL SHADER
>>         ///
>>         private var gShader:GouraudShader;
>>         private var gMaterial:ShadedMaterial;
>>         private var light:PointLight3D;
>>         ///
>>         // MOUSE MOVEMENT
>>         ///
>>         private var cameraPitch:Number = 90;
>>         private var cameraYaw:Number = 270;
>>         private var previousMouseX:Number = 0;
>>         private var previousMouseY:Number = 0;
>>
>>         /*----------------------- INITIALIZE -----------------------*/
>>         /*----------------------- INITIALIZE -----------------------*/
>>         /*----------------------- INITIALIZE -----------------------*/
>>         /*----------------------- INITIALIZE -----------------------*/
>>         /*----------------------- INITIALIZE -----------------------*/
>>         /*----------------------- INITIALIZE -----------------------*/
>>
>>         public function walkingTest_04():void{
>>             ///
>>             // VIEWPORT
>>             ///
>>             viewport = new Viewport3D(550, 400, false, true);
>>             addChild(viewport);
>>             ///
>>             // BASICS PV3D
>>             ///
>>             scene = new Scene3D();
>>             camera = new Camera3D();
>>             renderer = new BasicRenderEngine();
>>             ///
>>             // MATERIALS
>>             ///
>>             light = new PointLight3D();
>>             ///
>>             movieAssetMaterial = new MovieAssetMaterial("walkingTest",
>> true);
>>             movieAssetMaterial.animated = true;
>>             movieAssetMaterial.doubleSided = true;
>>             movieAssetMaterial.interactive = true;
>>             ///
>>             gShader = new GouraudShader(light, 0xFFFFFF, 0x111111, 30);
>>             gMaterial = new ShadedMaterial(movieAssetMaterial, gShader);
>>             gMaterial.doubleSided = true;
>>             ///
>>             // OBJECTS
>>             ///
>>             walkingDoll = new Plane(gMaterial, 600, 600, 3, 3);
>>             scene.addChild(light);
>>             scene.addChild(walkingDoll);
>>             ///
>>             var obj:*= getMaterial(plane as displayObject3D);
>>             obj.animatedDoll.stop();
>>             ///
>>             // LISTENERS
>>             ///
>>             stage.addEventListener(Event.ENTER_FRAME, procesarFrame);
>>             stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoving);
>>             stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheel);
>>         }
>>
>>         /*----------------------- MATERIAL STOP & PLAY
>> -----------------------*/
>>         /*----------------------- MATERIAL STOP & PLAY
>> -----------------------*/
>>         /*----------------------- MATERIAL STOP & PLAY
>> -----------------------*/
>>         /*----------------------- MATERIAL STOP & PLAY
>> -----------------------*/
>>         /*----------------------- MATERIAL STOP & PLAY
>> -----------------------*/
>>         /*----------------------- MATERIAL STOP & PLAY
>> -----------------------*/
>>
>>         protected function getMaterial(donde:*):MovieClip{
>>             ///
>>             var mat:MovieMaterial = donde.material as MovieMaterial;
>>             ///
>>             if(mat){
>>                 ///
>>                 //cast as our sub class, then test for null
>>                 var mov:MovieClip = mat.movie as MovieClip;
>>                 if(mov){
>>                     ///
>>                     // now you’re talking to the instance directly
>>                     return mov;
>>                 }
>>             }
>>             ///
>>             return null;
>>         }
>>
>>         /*----------------------- MOUSE MOVEMENT -----------------------*/
>>         /*----------------------- MOUSE MOVEMENT -----------------------*/
>>         /*----------------------- MOUSE MOVEMENT -----------------------*/
>>         /*----------------------- MOUSE MOVEMENT -----------------------*/
>>         /*----------------------- MOUSE MOVEMENT -----------------------*/
>>         /*----------------------- MOUSE MOVEMENT -----------------------*/
>>
>>         private function mouseWheel(event:MouseEvent):void{
>>             ///
>>             camera.moveForward(10 * event.delta);
>>         }
>>
>>         private function mouseMoving(event:MouseEvent):void{
>>             ///
>>             var differenceX:Number = event.stageX - previousMouseX;
>>             var differenceY:Number = event.stageY - previousMouseY;
>>              ///
>>             cameraPitch += differenceY;
>>             cameraYaw += differenceX;
>>             ///
>>             previousMouseX = event.stageX;
>>             previousMouseY = event.stageY;
>>         }
>>
>>         /*----------------------- ON ENTER FRAME -----------------------*/
>>         /*----------------------- ON ENTER FRAME -----------------------*/
>>         /*----------------------- ON ENTER FRAME -----------------------*/
>>         /*----------------------- ON ENTER FRAME -----------------------*/
>>         /*----------------------- ON ENTER FRAME -----------------------*/
>>         /*----------------------- ON ENTER FRAME -----------------------*/
>>
>>         private function procesarFrame(e:Event):void{
>>             ///
>>             // MOUSE MOVEMENT
>>             ///
>>             cameraPitch %= 360;
>>             cameraYaw %= 360;
>>             ///
>>             cameraPitch = cameraPitch > 0 ? cameraPitch : 0.0001;
>>             cameraPitch = cameraPitch < 90 ? cameraPitch : 89.9999;
>>             ///
>>             camera.orbit(cameraPitch, cameraYaw);
>>             ///
>>             // LIGHT MOVEMENT
>>             ///
>>             light.x = (mouseX - 275) * 5;
>>             light.y = (mouseY - 200) * -5;
>>             ///
>>             // PROCESS SCENE
>>             ///
>>             renderer.renderScene(scene, camera, viewport);
>>         }
>>     }
>> }
>>
>> ------------------------
>>
>> On Tue, Jul 14, 2009 at 4:24 PM, Buti <butilon at gmail.com> wrote:
>>
>>> it's a function inside obj. It is an example.
>>>
>>> Javier España | javierespana.com wrote:
>>>
>>>> But what does that rollover() function do?
>>>>
>>>>  On Tue, Jul 14, 2009 at 3:46 PM, Buti <butilon at gmail.com <mailto:
>>>> butilon at gmail.com>> wrote:
>>>>
>>>>    I use this function. Don't remember where I got it.
>>>>
>>>>    protected function getMaterial(donde:*):MovieClip{
>>>>           var mat:MovieMaterial = donde.material as MovieMaterial;
>>>>           if( mat ){
>>>>           // cast as our sub class, then test for null
>>>>                   var mov:MovieClip = mat.movie as MovieClip;
>>>>                   if( mov ){
>>>>                           // now you’re talking to the instance directly
>>>>                           return mov;
>>>>                   }
>>>>           }
>>>>                           return null;
>>>>    }
>>>>
>>>>    var obj:*= getMaterial(plane as displayObject3D);
>>>>    obj.rollover();
>>>>
>>>>
>>>>
>>>>     Javier España | javierespana.com <http://javierespana.com> wrote:
>>>>
>>>>        Hi there,
>>>>
>>>>        I have managed to create a Plane with a material that is a
>>>>        running movieClip with 8 frames. The thing is that I want to be
>>>>        able to play and stop that movieClip that's acting as the
>>>>        material of the Plane but can't seem to get to it...
>>>>
>>>>        Here's how I load it:
>>>>
>>>>        movieAssetMaterial = new MovieAssetMaterial("walkingTest", true);
>>>>        movieAssetMaterial.animated = true;
>>>>        movieAssetMaterial.doubleSided = true;
>>>>        movieAssetMaterial.interactive = true;
>>>>
>>>>        walkingDoll = new Plane(movieAssetMaterial, 600, 600, 3, 3);
>>>>        scene.addChild(walkingDoll);
>>>>
>>>>        That movieClip called "walkingTest" that I'm using as the
>>>>        material, has another movieClip inside it called animatedDoll
>>>>        that is the one I need to play and stop. Any help on how to
>>>>        reach it? If I use:
>>>>
>>>>        walkingTest.animatedDoll.stop();
>>>>
>>>>        I get an error...
>>>>
>>>>        Thanks a lot,
>>>>
>>>>        Javier
>>>>
>>>>
>>>>
>>>>  ------------------------------------------------------------------------
>>>>
>>>>        _______________________________________________
>>>>        Papervision3D mailing list
>>>>         Papervision3D at osflash.org <mailto:Papervision3D at osflash.org>
>>>>        http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>>>
>>>>
>>>>
>>>>
>>>>    _______________________________________________
>>>>    Papervision3D mailing list
>>>>     Papervision3D at osflash.org <mailto:Papervision3D at osflash.org>
>>>>    http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> Papervision3D mailing list
>>>> Papervision3D at osflash.org
>>>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Papervision3D mailing list
>>> Papervision3D at osflash.org
>>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>>
>>>
>> ------------------------------
>>
>> _______________________________________________
>> Papervision3D mailing listPapervision3D at osflash.orghttp://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>
>>
>> _______________________________________________
>> Papervision3D mailing list
>> Papervision3D at osflash.org
>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20090715/3508c124/attachment-0001.html>


More information about the Papervision3D mailing list