[Papervision3D] movieAssetMaterial play and stop

andysk8er elbarto37 at yahoo.com
Thu Jul 16 06:43:05 PDT 2009


Why don't you try another approach:

Place a function on the main timeline of the movieclip that you are using as
a material:

function traceMe() {
  trace("hello there");
}

Then, see if you can call that function from papervision with 
movieAssetMaterial.movie.traceMe();

If that works, then you can set up a series of controller functions for your
nested movieclips on the material's main timeline and call them from
papervision. That way, Papervision doesn't need a reference to all of your
nested movieclips - it just needs a reference to the main one.

-Andy





Maggical wrote:
> 
> Any help with this? =(
> 
> 2009/7/15 Javier España | javierespana.com <info at javierespana.com>
> 
>> It gives me this error:
>>
>> "Access of undefined property DislpayObjectContainer" :S
>>
>> I'm googling and searching but it seems weird...
>>
>>
>> On Wed, Jul 15, 2009 at 1:09 PM, Damien Pegoraro
>> <dpegoraro at actiplay.com>wrote:
>>
>>> try  trace(movieAssetMaterial.movie["animatedDoll"]);
>>> or in a cleaner way
>>> trace(  (movieAssetMaterial.movie as
>>> DisplayObjectContainer).getChildByName("animatedDoll"));
>>>
>>>
>>> Javier España | javierespana.com a écrit :
>>>
>>>> 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 <http://javierespana.com> <
>>>> info at javierespana.com <mailto: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 <mailto: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 <http://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
>>>>>        <mailto:butilon at gmail.com>> wrote:
>>>>>
>>>>>            it's a function inside obj. It is an example.
>>>>>
>>>>>
>>>>>            Javier España | javierespana.com
>>>>>            <http://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>
>>>>>                <mailto: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> <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>
>>>>>                <mailto: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>
>>>>>                <mailto: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
>>>>> <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 <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 list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> 
> 


-----
===============================================
Check out my blog for Flash, AS3, and web development stuff:
http://www.wastedpotential.com
-- 
View this message in context: http://www.nabble.com/movieAssetMaterial-play-and-stop-tp24485566p24516641.html
Sent from the Papervision3D mailing list archive at Nabble.com.




More information about the Papervision3D mailing list