Jump to content
  • Advertisement
Sign in to follow this  
Black Knight

[web] Loading a flex app into another flex app

This topic is 2924 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys this is going to be a long post so bare with me :)

I have been working on a flex application and I want to load other flex applications into this app. I have nearly tried everything on the adobe docs and on the web and nothing seems to work. The strange thing is the load method seems to load the application itself into self. So I have App1.swf and App2.swf. App1.swf tries to load App2.swf and add it to a panel in the gui but for some reason instead of App2.swf it loads itself.

Here is the code for the two simple apps that produce the issue. First the code for the app that I try to load.

<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" height="200" width="200">

<mx:Label text="I am here."/>
<mx:Box width="50" height="50" backgroundColor="#ff0000"></mx:Box>



As you can see it's just a simple flex app with a label and box, single mxml file.

Here is the app that tries to load it:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

<mx:Panel id="panel1" title="baws" width="500" height="400"></mx:Panel>

<mx:Button label="load external swf" click="loadgame(event)"></mx:Button>

import flash.display.DisplayObject;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import mx.controls.SWFLoader;
import mx.core.UIComponent;

import mx.managers.SystemManager;

import mx.controls.Label;

public var loader:Loader;

public function handleInit(event:Event):void
var myComp:UIComponent = new UIComponent();


private function loadgame(e:MouseEvent):void
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, handleInit);
loader.load(new URLRequest('flexapp.swf'));



When ran this loads App1 into the panel inside App1 basically it loads itself into itself. I am using FlashDevelop with the Flex SDK.

Anyone got any idea what might be wrong this is driving me nuts for a few days now.

Share this post

Link to post
Share on other sites
Doh I hate myself.

Turns out it was a name clash, both the App1.swf and App2.swf had Main.mxml as their file and this was resulting in 2 top level classes with name "Main". I renamed one of them to a different name and it worked.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!