SWFLoader Control in Flex4


 

SWFLoader Control in Flex4

The SWFLoader control is a MX component. It has no Spark component. The SWFLoader control loads one application into another application as a swf file.

The SWFLoader control is a MX component. It has no Spark component. The SWFLoader control loads one application into another application as a swf file.

SWFLoader control in Flex4:

The SWFLoader control is a MX component. It has no Spark component. The SWFLoader control loads one application into another application as a swf file.
The SWFLoader control loads the contents of a GIF, JPEG, PNG, SVG, or SWF file into your application. You can use this loaded application into another application as a  programmatically. When you loads the one application into main application you should be aware of two factors: Versioning and Security.
The tag of this control is <mx:SWFLoader>.

Example:

Very first you will make an application suppose which is swfapp.mxml and the source code of this application is given below.

swfapp.mxml

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx" width="200" height="200">

<fx:Script>

<![CDATA[

[Bindable]

public var lbl1var:String = "This is a Sub application.";

[Bindable]

public var lblvar:String = "Hi...How are you?";

public function initVariable(lbl1text:String):void{

lbl1var=lbl1text;

}

]]>

</fx:Script>

<s:VGroup x="14" y="10">

<s:Label text="{lblvar}" id="lbl"/>

<s:Label text="{lbl1var}" id="lbl1"/>

<s:Button label="Update Button" id="btn" click="initVariable('Clicked on Update Button')"/>

</s:VGroup>

</s:Application>

After that you can use the output(.swf file) of swfapp.mxml in another application using SWFLoader control suppose which is swfloader.mxml and the source code is given below.

swfloader.mxml

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx">

<s:Panel title="SWFLoader Control Example" height="234" width="268">

<s:VGroup width="263">

0

<mx:SWFLoader id="loader"

source="@Embed(source='../bin-debug/swfapp.swf')"

height="198"

1

width="262"/>

</s:VGroup>

</s:Panel>

2

</s:Application>

In this example you can see how we can use a SWFLoader control in Flex4.

3

Output:

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Get Adobe Flash player

Download swfapp.mxml file code

Download swfloader.mxml file code

Ads