views:

2289

answers:

3

Hi Friends!

I'm doing a Flex 3 project wherein I've to load SWF based on the availability of required file. And the loaded SWF file will be placed in a container (a Panel) at a particular location i.e. coordinates. This I don't want to do in MXML as the SWFLoader container shows a cross marked box if the file is unavailable.

So friends is there any solution?

A: 
  • Create a new URLRequest object with the url of the file.
  • Create a new Loader object.
  • Call the Loader object's load() method, passing the URLRequest instance as a parameter.
  • Call the addChild() method on a display object container (such as the main timeline of a Flash document) to add the Loader instance to the display list.

Source: Loading an external SWF file.

Raul Agrait
A: 

Hi Raul, Thanks for your answer. I want to give the actual picture here. I've an xmlObj from where I get the data (text line). From the xmlObj I get the name of the SWF file which is to be loaded. I've a panel wherein is a map. Here I want to place the SWF file at a particular coordinates in the panel, if only if it is available. And the compiler gives me the error that the object myCity is undefined. As posted by you I've ammended the code and checked. But it is still giving the same error.

My codes goes like this:

public var myCity:SWFLoader = new SWFLoader();

if (findImgSource(xmlObj.area[14].cityId[0]) != null) 
{
panelCountry.addChild(myCity);    
with (myCity)
    {
          source="{findImgSource(xmlObj.area[14].cityId[0])}";
       x="151";
       y="311";
       width="50";
       height="50";
    }

public function findImgSource(imgVal:String):String
{
      return "swfs/"+imgVal+".swf";
}

Hope, you've some suggestions on this!

A: 
* Create a new URLRequest object with the url of the file.
* Create a new Loader object.
* Call the Loader object's load() method, passing the URLRequest instance as a parameter.
* Call the addChild() method on a display object container (such as the main timeline of a Flash document) to add the Loader instance to the display list.
fleshLight