[Papervision3D] Dynamic textfield revisited
Trevor Burton
worldofpaper at googlemail.com
Sun Nov 25 10:47:50 PST 2007
try tracing the value of myMat without the cast to MovieMaterial... see if
it's just the cast that's returning null rather than the material itself
being null
var mat:MaterialObject3D = my3DObject.material
trace (mat)
var myMat:MovieMaterial = mat as MovieMaterial;
trace (myMat);
On Nov 25, 2007 6:38 PM, semiplay <mark at semiplay.com> wrote:
>
> John,
>
> Thanks for the input --- still no go ---- when I try that, "myMat" is
> ending
> up null. My code is below, with that section added in. Most of it is the
> generic component code, I marked the section I am talking about. Any
> thoughts?
>
> I am a complete noob (been at this a week), but I am totally addicted.
>
> Thanks!
>
>
>
> (I am using version 1.5 with the components.)
>
> //******************************************************************
> import org.papervision3d.components.as3.flash9.PV3DColladaScene;
> import org.papervision3d.events.InteractiveScene3DEvent;
> import org.papervision3d.events.FileLoadEvent;
> import org.papervision3d.scenes.InteractiveScene3D;
> import org.papervision3d.objects.DisplayObject3D;
> import org.papervision3d.materials.MovieMaterial;
> import org.papervision3d.materials.BitmapFileMaterial;
> import org.papervision3d.materials.MaterialsList;
>
>
>
> scene3d.addEventListener(PV3DColladaScene.SCENE_COMPLETE , handleInit);
> scene3d.addEventListener(PV3DColladaScene.SCENE_LOAD_PROGRESS,
> handleProgress);
> scene3d.addEventListener(PV3DColladaScene.SCENE_LOAD_ERROR,
> handleLoadError);
>
>
>
> function handleInit(...rest):void
> {
> /*
> * The code below is an example of getting mouse events from a
> DisplayObject3D in your collada scene -
> * YOU MUST USE INTERACTIVE MATERIALS TO RECEIVE MOUSE EVENTS
> * */
>
> var my3DObject:DisplayObject3D =
> scene3d.collada.getChildByName("Cylinder");
> my3DObject.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK,
> handleObjectClick);
> my3DObject.addEventListener (InteractiveScene3DEvent.OBJECT_OVER,
> handleObjectOver);
> my3DObject.addEventListener(InteractiveScene3DEvent.OBJECT_OUT,
> handleObjectOut);
>
> //*************************************************************
> //HERE'S THE SECTION *********************************************
>
> var myMat:MovieMaterial = my3DObject.material as MovieMaterial;
> trace (myMat); // SO FAR THIS IS NULL
>
> if( myMat )
> {
> var mov:MovieClip = myMat.movie as MovieClip;
> if( mov )
> {
> mov.myname.text = "ding";
> }
> }
> //*************************************************************
> //*************************************************************
>
>
>
> /*
> * The code below is an example of getting mouse events from the
> InteractiveSceneManager, which dispatches
> * events for all interactive objects in a scene.
> * */
> /*
>
> scene3d.scene.interactiveSceneManager.addEventListener(
> InteractiveScene3DEvent.OBJECT_PRESS,
> handleMousePress);
>
> scene3d.scene.interactiveSceneManager.addEventListener(
> InteractiveScene3DEvent.OBJECT_RELEASE ,
> handleMouseRelease);
>
> scene3d.scene.interactiveSceneManager.addEventListener(
> InteractiveScene3DEvent.OBJECT_CLICK,
> handleMouseClick);
>
> scene3d.scene.interactiveSceneManager.addEventListener(
> InteractiveScene3DEvent.OBJECT_OVER ,
> handleMouseOver);
>
> scene3d.scene.interactiveSceneManager.addEventListener(
> InteractiveScene3DEvent.OBJECT_OUT,
> handleMouseOut);
>
> scene3d.scene.interactiveSceneManager.addEventListener(
> InteractiveScene3DEvent.OBJECT_MOVE ,
> handleMouseMove);
>
> scene3d.scene.interactiveSceneManager.addEventListener(
> InteractiveScene3DEvent.OBJECT_RELEASE_OUTSIDE,
> handleReleaseOutside);
> */
> }
>
> // COLLADA Scene event handlers ===================================
>
> function handleProgress(e:FileLoadEvent):void
> {
> trace(Math.floor(e.bytesLoaded/e.bytesTotal)*100);
> }
>
> function handleLoadError(e:FileLoadEvent):void
> {
> trace("Collada load error", e.file, e.message);
> }
>
> // Individual DisplayObject3D event handlers
> ===================================
>
> function handleObjectOut(e:InteractiveScene3DEvent):void
> {
> trace("out", e.displayObject3D.name<http://e.displayobject3d.name/>
> );
> }
>
> function handleObjectOver(e:InteractiveScene3DEvent):void
> {
> trace("over", e.displayObject3D.name<http://e.displayobject3d.name/>);
> }
>
> function handleObjectClick(e:InteractiveScene3DEvent):void
> {
> trace("click", e.displayObject3D.name<http://e.displayobject3d.name/>
> );
>
>
>
> }
>
> // InteractiveSceneManager event handlers
> ===================================
>
> function handleMousePress(e:InteractiveScene3DEvent):void
> {
> trace("press", e.displayObject3D.name<http://e.displayobject3d.name/>
> );
> }
> function handleMouseRelease(e:InteractiveScene3DEvent):void
> {
> trace("release", e.displayObject3D.name<http://e.displayobject3d.name/>);
> }
> function handleReleaseOutside(e:InteractiveScene3DEvent):void
> {
> trace("releaseOutside");
> }
> function handleMouseClick(e:InteractiveScene3DEvent):void
> {
> trace("click", e.displayObject3D.name<http://e.displayobject3d.name/>
> );
> }
> function handleMouseOver(e:InteractiveScene3DEvent):void
> {
> trace("over", e.displayObject3D.name<http://e.displayobject3d.name/>
> );
> }
> function handleMouseOut(e:InteractiveScene3DEvent):void
> {
> trace("out", e.displayObject3D.name<http://e.displayobject3d.name/>
> );
> }
> function handleMouseMove(e:InteractiveScene3DEvent):void
> {
> trace("move", e.displayObject3D.name<http://e.displayobject3d.name/>
> );
> }
> this.addEventListener(Event.ENTER_FRAME , render);
>
> function render(e:Event):void
> {
>
> //scene.renderCamera(camera);
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> John Grden-2 wrote:
> >
> > if you're using a dynamic text field, make sure to use a font that's on
> > everyone's system like Arial.
> >
> > Also, you might put in some checks along the way to getting to your
> > movieclip through the material reference to avoid RTE's
> >
> > var myMat:MovieMaterial = myDO3D.material as MovieMaterial;
> > if( myMat )
> > {
> > var mov:MovieClip = myMat.movie as MovieClip;
> > if( mov )
> > {
> > mov.textFieldName.text = "ding";
> > }
> > }
> >
> > at one time, when I was trying to access a movieclip like this with
> > collada, I had to reset the material to the DO3D after the COllada
> object
> > was rendered. That was an old bug, but it fixed my issue ;)
> >
> > Hth,
> >
> > John
> >
> > On Nov 25, 2007 8:43 AM, semiplay < mark at semiplay.com> wrote:
> >
> >>
> >> Thanks for the info --- I am still not getting it to work, but I think
> it
> >> is
> >> something I am doing. Here are the actual names of materials and
> >> movieclips
> >> in the file I am playing with:
> >>
> >> The collada component on stage is called scene3d
> >> The MovieClip in the library is called uvtexture2, its linkage
> identifier
> >> is
> >> uvtexture2
> >> The dynamic textfield inside uvtexture2 is named myname
> >> The materialName in the component Materials List is uvcyl_Cylinder_jpg
> >>
> >>
> >> I tried the following:
> >> uvcyl_Cylinder_jpg.movie.myname.text="Whatever";
> >>
> >> This produces:
> >> 1120: Access of undefined property uvcyl_Cylinder_jpg.
> >>
> >> uvcyl_Cylinder_jpg.uvtexture2.myname.text="Whatever";
> >> 1120: Access of undefined property uvcyl_Cylinder_jpg.
> >>
> >> uvtexture2.myname.text="Whatever";
> >> 1119: Access of possibly undefined property myname through a reference
> >> with
> >> static type Class.
> >>
> >> Then I tried:
> >> scene3d.collada.uvtexture2.myname.text="Whatever";
> >> 1119: Access of possibly undefined property uvtexture2 through a
> >> reference
> >> with static type org.papervision3d.objects:Collada.
> >>
> >> Am I even close? Do I need to reference "scene3d.collada" in these
> >> calls?
> >>
> >> Is it possible the underscores "_" in the material name are messing
> >> things
> >> up?
> >>
> >> Thanks!
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> Roy Wiggins wrote:
> >> >
> >> > If your material is called, say, "MyMat" then it's just
> >> >
> >> > MyMat.movie.xwingslogan.text = "Whatever"
> >> >
> >> > It works with the Phunky branch, anyway.
> >> >
> >> > On Nov 24, 2007 8:01 PM, semiplay <mark at semiplay.com > wrote:
> >> >
> >> >>
> >> >> I saw several posts regarding embedding fonts and dynamic
> textfields,
> >> but
> >> >> not
> >> >> quite what I am looking for. Here is what I am doing:
> >> >>
> >> >> Using the PV3D Component, Collada Scene, ala the x-wing example
> >> >> http://www.rockonflash.com/blog/?p=54
> >> >>
> >> >> In this example, John uses a Bitmap material, and a MovieClip
> >> material,
> >> >> and
> >> >> differentiates them by adding some text to the MovieClip material
> when
> >> he
> >> >> switches them out.
> >> >>
> >> >> I've gone through all that so far, and it's great. How about if
> that
> >> >> text
> >> >> field in the MovieClip material is a dynamic textfield, let's call
> it
> >> >> "xwingslogan" --- how in the heck do I access that during runtime?
> >> ie,
> >> >> what
> >> >> path would I use to set the value of xwingslogan.text when the movie
>
> >> is
> >> >> running?
> >> >>
> >> >> Any help is greatly appreciated!
> >> >>
> >> >> Mark
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/Dynamic-textfield-revisited-tf4869015.html#a13932526
> >> >> Sent from the Papervision3D mailing list archive at Nabble.com<http://nabble.com/>
> .
> >> >>
> >> >>
> >> >> _______________________________________________
> >> >> 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
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Dynamic-textfield-revisited-tf4869015.html#a13936189
> >> Sent from the Papervision3D mailing list archive at Nabble.com<http://nabble.com/>
> .
> >>
> >>
> >> _______________________________________________
> >> Papervision3D mailing list
> >> Papervision3D at osflash.org
> >> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >>
> >
> >
> >
> > --
> > [ JPG ]
> >
> > _______________________________________________
> > Papervision3D mailing list
> > Papervision3D at osflash.org
> > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Dynamic-textfield-revisited-tf4869015.html#a13938380
>
> Sent from the Papervision3D mailing list archive at Nabble.com<http://nabble.com/>
> .
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
--
Trevor Burton
http://www.paperworld3d.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20071125/f2e44914/attachment.html
More information about the Papervision3D
mailing list