tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/180-mediating-papervision3d-objectsRobotlegs: Discussion 2013-04-28T09:59:52Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-02T23:10:12Z2010-10-02T23:10:12ZMediating PaperVision3D Objects<div><p>Hi George,</p>
<p>any chance that you've got an app domain issue?</p>
<p>Are you loading a swf perhaps? Modules?</p>
<p>I'm afraid I've no Papervision experience at all, but this looks more general.</p>
<p>Usually when I have this kind of error it means that there are 2 different versions of this class loaded into memory. Could that be the case?</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-02T23:24:43Z2010-10-02T23:30:54ZMediating PaperVision3D Objects<div><p>Hi Stray,</p>
<p>In this case I am not using <em>Modules</em>, and the only other place I reference <em>Panel1Video</em> is in <em>PrepModelCommand</em> where I register the class:</p>
<p><code>registerClassAlias ( "com.example.materials.video.Panel1Video", Panel1Video );</code></p>
<p>as the Class (MovieClip) is embedded into the SWF and is instantiated using :</p>
<p><code>var Clazz : Class = getDefinitionByName ( reference ) as Class;</code>
<code>var movieclip : MovieClip = new Clazz () as MovieClip;</code></p>
<p>as the movie material reference is parsed from an XML document.<br />
The MovieMaterial does appear and draws fine.</p>
<p>It is feasible that PV3D creates 2 or more instances of the MovieMaterial, but I am imagine I would see more than 1 constructor trace appearing in the output.</p>
<p>Is there another approach I could try?</p>
<p>George</p></div>George Mtag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T13:27:05Z2010-10-03T13:27:05ZMediating PaperVision3D Objects<div><p>So - you're getting the wrong definition when you do getDefinitionByName. It differs from the one that you've compiled into the code that does the mapping.</p>
<p>This indicates to me that there's more than one applicationDomain in play.</p>
<p>Look into application domains - I'm thinking that you're simply not setting the application domain correctly when you load the swf containing Panel1Video.</p>
<p>Or do you mean that the swf that is the robotlegs main swf has this class attached to an item exported in the library of the main swf?</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T13:35:39Z2010-10-03T13:35:39ZMediating PaperVision3D Objects<div><p>Hi George,</p>
<p>I see from twitter that you're not loading swfs at runtime.</p>
<p>What I also see, from a quick google, is that these type conversion issues are very common in papervision.</p>
<p>Are you an experienced papervision user? Is what you're trying to do something that you've done before, without robotlegs?</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T13:38:26Z2010-10-03T13:53:56ZMediating PaperVision3D Objects<div><p>Hi Stray,<br />
There is one SWF only, the main SWF.<br />
The main SWF has Panel1Video in its library as well as various other mc's. So I can't understand why (or even how) I could set the application domain on only 1 SWF as surely all the classes included in the SWF fall under the same app domain?</p>
<p>In the case of my app, I use the XML to sequence the animations / PV3D planes to add and which material to apply to it.</p>
<p>The material is a MovieClip, referenced by its package and class name, i.e.<br />
<em>com.example.materials.video.Panel1Video</em></p>
<p>Hence why I have to use <em>getDefinitionByName</em> to retrieve the movieclip reference from the library so I can apply it as the material and why I have to register the class alias otherwise the material will not be exported.</p>
<p>Thanks</p>
<p>George</p></div>George Mtag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T13:50:06Z2010-10-03T13:50:06ZMediating PaperVision3D Objects<div><p>I've definitely had these frustrations myself in flash before - so I understand it's a nightmare to debug.</p>
<p>Other people using papervision and instantiating from the library seem to be having similar issues - possibly one of their solutions will help you.</p>
<p>Fingers crossed!</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T16:10:19Z2010-10-03T16:10:19ZMediating PaperVision3D Objects<div><p>Hi George,</p>
<p>I haven't done any PV3D in a while, but back when I did MovieMaterials weren't actual MovieClips on the stage - they were rasterized onto planes. If this is still the case, then RL will not be able to see any of the MovieMaterials land on stage (because they never do), and hence won't be able to automatically mediate them.</p>
<p>Could that be the problem?</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T16:24:21Z2010-10-03T16:24:21ZMediating PaperVision3D Objects<div><p>Hi Shaun,</p>
<p>I have thought this too, but using a hack (I have the MovieMaterial listening to a real Singleton - need to get the job done - had to hack it - <em>sorry</em>) I can update the frames in the MovieMaterial, so in essence the MovieMaterial <em>does</em> exist somewhere, and as you say a bitmap grab of that is being drawn onto the PV3D Plane.</p>
<p>Although, I am not trying to automatically mediate them, I set up<br />
<code>mediatorMap.mapView ( Panel1Video , Panel1Mediator );</code> in my <em>PrepViewCommand</em></p>
<p>In the Best Practices it mentions I can manually create mediators ☛ <a href="http://bit.ly/dq2cQV">http://bit.ly/dq2cQV</a></p>
<p>so, once I know the 3D model has been constructed I trigger another command where I run:<br />
<code>mediatorMap.createMediator ( Panel1Video );</code></p>
<p>In my opinion I would have thought this train of logic is <em>sound</em>, but I have been wrong lots before :o)</p>
<p>Is there a way I can Mediate classes that are not attached to a <em>physical</em> stage?</p>
<p>Cheers,</p>
<p>George</p></div>George Mtag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T17:47:39Z2010-10-03T17:47:39ZMediating PaperVision3D Objects<div><p>Hi George,</p>
<p>"Is there a way I can Mediate classes that are not attached to a physical stage?"</p>
<p>Yes, use <code>createMediator()</code>. But please note: <code>createMediator()</code> expects a view component instance, not a class (as you have it above):</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T18:45:03Z2010-10-03T18:45:03ZMediating PaperVision3D Objects<div><p>Hi Shaun,<br />
❝Yes, use <code>createMediator()</code>. But please note: <code>createMediator()</code> expects a view component instance, not a class (as you have it above)❞</p>
<p>I am a little lost now, are you telling me that I can't Mediate Panel1Video as it isn't attached to the stage?</p>
<p>After all, the PaperVision3D MovieMaterial is simply grabbing and redrawing the bitmap data of Panel1Video (<em>which extends MovieClip</em>). And using the FDT profiler can see that it still exists during runtime.</p></div>George Mtag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T19:12:38Z2010-10-03T19:12:38ZMediating PaperVision3D Objects<div><p>Hey George,</p>
<p>"I am a little lost now, are you telling me that I can't Mediate Panel1Video as it isn't attached to the stage?"</p>
<p>No, I'm just saying that you need to pass an instance to <code>createMediator()</code>:</p>
<pre>
// Correct: passing an instance
mediatorMap.createMediator( panelVideo );
// Incorrect: passing a class
mediatorMap.createMediator( PanelVideo );
</pre>
<p>For example:</p>
<pre>
mediatorMap.mapView( SomeView, SomeMediator, SomeView, false, false );
someView = new SomeView();
mediatorMap.createMediator( someView );
</pre>
<p>The view component doesn't have to be on stage, but you do have to have a reference to it.</p>
<p>Hope that helps!</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T19:38:33Z2010-10-03T19:38:33ZMediating PaperVision3D Objects<div><p>I getcha now! and Bingo! I just did a <code>dirty test</code> and it works!</p>
<p>Now to refactor and implement!</p>
<p>Sweet!</p>
<p>Cheers You Guys!</p>
<p>George</p></div>George Mtag:robotlegs.tenderapp.com,2009-10-18:Comment/32020502010-10-03T20:45:04Z2010-10-03T20:45:04ZMediating PaperVision3D Objects<div><p>Glad you're back on track!</p></div>Shaun Smith