Loading & Resizing the SWF By using SWFLoader

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:TitleWindow xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; xmlns:asx=”asx.*” title=”Furnace Delay Tracking System” layout=”absolute” width=”970″

height=”654″
showCloseButton=”true” shadowDistance=”0″ close=”RemovePopUp();” creationComplete=”SetSource();”>

<mx:Script>
<![CDATA[

import flash.events.KeyboardEvent;
import mx.managers.PopUpManager;
import mx.controls.Alert;
import flash.system.LoaderContext;
import flash.system.ApplicationDomain;
import mx.controls.SWFLoader;
import flash.events.Event;
import mx.events.FlexEvent;
public var g_sHeatNumber:String;
public var g_sFurnace:String;
/**
* Function used to set the source for IFrame.
*/
private function SetSource() :void
{
var separateDefinitions:LoaderContext = new LoaderContext();
var objSWFLoader:SWFLoader = new SWFLoader();
objSWFLoader.scaleContent = false;
objSWFLoader.percentWidth = 100;
objSWFLoader.percentHeight = 100;
separateDefinitions.checkPolicyFile = true;
separateDefinitions.applicationDomain = new ApplicationDomain();
objSWFLoader.loaderContext = separateDefinitions;
objSWFLoader.source = “DelayEntry.swf?HeatAndFurnace=” + g_sHeatNumber + “,” + g_sFurnace;
objSWFLoader.addEventListener(Event.COMPLETE, GetCurrentSWF);
hboxDownTimeEntry.addChild(objSWFLoader);
}
private function GetCurrentSWF(event:Event):void
{
try
{
event.target.content.addEventListener(FlexEvent.APPLICATION_COMPLETE, GetLoadedSWF);
}
catch (e:Error)
{ }
}
private function  GetLoadedSWF(event:Event):void
{
try
{
event.target.application.width = hboxDownTimeEntry.width;
event.target.application.height = hboxDownTimeEntry.height;
}
catch (e:Error)
{ }
}
/**
* Function used to remove the popup window.
*/
private function RemovePopUp() :void
{
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:HBox id=”hboxDownTimeEntry” width=”100%” height=”100%” backgroundColor=”#C6BFBD”></mx:HBox>
</mx:TitleWindow>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s