tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/521-loading-one-robotlegs-project-to-another-robotlegs-projectRobotlegs: Discussion 2012-03-30T09:00:28Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/146246972012-03-20T11:58:31Z2012-03-20T11:58:32ZLoading one Robotlegs project to another Robotlegs project<div><p>Hi everyone!</p>
<p>I have a little problem. ( At the begining sorry if my English
is bad , it's not my native language).<br>
So i made application in RL , and now i have to include that
application into another ( which is also made in RL ) .<br>
But include have to be done by loading that smallest one app ( .swf
) into that bigger one, with preserving communication<br>
between both of them ( both are using Events for communicating ).
So I can send to small application events from that bigger one.<br>
Important thing is - that i have still possibility to change source
code from small application too.<br>
My problem is - that I can't achieve that. I was reading lot of
exaples for Modular Utility , but it's mainly for modular
applications without loading standalone modules. So i can't find
proper solution. Could you help me ? Maybe someone have some
exemple ? I would be very gratefull for some help. Thanks !</p></div>Lukastag:robotlegs.tenderapp.com,2009-10-18:Comment/146246972012-03-20T15:34:58Z2012-03-20T15:34:58ZLoading one Robotlegs project to another Robotlegs project<div><p>Hi Lukas,</p>
<blockquote>
<p>So i made application in RL , and now i have to include that
application into another ( which is also made in RL ) .</p>
</blockquote>
<p>This looks like a sub-application to me rather than a
module.<br>
A couple of questions to you:<br>
Have you tried to communicate between 2 non-rl applications
already? Does this work? How are you loading the sub-application,
are you using the Loader class?</p>
<p>If it is a sub-application, then one possible cause of your
problem could be the way you set your ApplicationDomain for the
loaded swf.</p>
<p>See this post for more info on ApplicationDomain: <a href=
"http://livedocs.adobe.com/flex/3/html/help.html?content=18_Client_System_Environment_5.html">
http://livedocs.adobe.com/flex/3/html/help.html?content=18_Client_S...</a><br>
Loading and managing sub-applications can be pretty annoying
sometimes.</p>
<p>The following code works for a sub-application:<br>
protected function onLoaderComplete(event:Event):void<br>
{</p>
<p>var
appDomain:ApplicationDomain=ApplicationDomain.currentDomain;<br>
var context:LoaderContext=new LoaderContext(false, appDomain);<br>
var loader:Loader=new Loader();<br>
loader.loadBytes(urlLoader.data, context);<br>
container.addChild(loader);</p>
<p>sharedEventDispatcher=loader.contentLoaderInfo.sharedEvents;<br>
sharedEventDispatcher.addEventListener("SubAppToMainAppEvent",
onSubAppChanged, false, 0, true);</p>
<p>}</p>
<p>protected function sendDataToSubApp():void<br>
{</p>
<p>var dynamicEvent:DynamicEvent=new
DynamicEvent("MainAppToSubAppEvent");<br>
dynamicEvent.data="application to subapplication";<br>
sharedEventDispatcher.dispatchEvent(dynamicEvent);</p>
<p>}</p>
<p>If this doesn’t answer your question, could you please
show us the code where you are loading your second application?</p>
<p>Cheers,<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/146246972012-03-22T11:12:56Z2012-03-22T11:12:56ZLoading one Robotlegs project to another Robotlegs project<div><p>Unfortunatelly it doesn't work like that .. There is no error
during compilation. But when application fires - smallest
application content doesn't appear at the stage.</p>
<p>this is a code :</p>
<p>protected const WALL_PATH:String = "data/small_rl_app.swf";</p>
<pre>
<code> public function load():void
{
var loader_context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
_loader = new BulkLoader("smallAppLoader");
_loader.addEventListener(BulkProgressEvent.COMPLETE, loadSuccess);
_loader.add(WALL_PATH, { id:WALL_PATH, context:loader_context});
_loader.start();
}
protected function loadSuccess(e:BulkProgressEvent):void
{
var wall:Sprite = _loader.getSprite(WALL_PATH);
addChild(wall);
}</code>
</pre></div>Lukastag:robotlegs.tenderapp.com,2009-10-18:Comment/146246972012-03-22T11:47:12Z2012-03-22T12:03:26ZLoading one Robotlegs project to another Robotlegs project<div><p>The code snippet from my previous message works fine on my end,
with 2 robotlegs applications, where one is loading the other one
as a sub-application.</p>
<p>So, I don’t think that your issue has anything to do with
robotlegs.</p>
<p>You didn’t answer my question from my previous post: Have
you tried to load a sub-application in another application, where
both applications are <em>not</em> using robotlegs or any other
libraries or frameworks? Just 2 simple applications?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/146246972012-03-22T13:14:28Z2012-03-22T13:14:28ZLoading one Robotlegs project to another Robotlegs project<div><blockquote>
<p>But when application fires - smallest application content
doesn't appear at the stage.</p>
</blockquote>
<p>Could it be that you created your SWFLoader or Loader through
actionscript like this:</p>
<p>private var swfLoader:SWFLoader;</p>
<p>Then, somewhere in your code:</p>
<p>var appDomain:ApplicationDomain=ApplicationDomain.currentDomain;
swfLoader=new SWFLoader(); swfLoader.addEventListener(Event.INIT,
swfLoaded); swfLoader.loaderContext=new LoaderContext(false,
appDomain); swfLoader.load(urlLoader.data);</p>
<p>and you forgot to add it to the display list?</p>
<p>addElement(swfLoader);</p></div>Ondina D.F.