Highlighted

SWF file content is not displayed to the full screen size

New Here ,
Oct 27, 2020

Copy link to clipboard

Copied

Hello All,

                 I'm just started to work on Adobe AIR right now.I'm facing a problem while loading a Flex web application based SWF file (MXML application file) on the AIR app using the SWFLoader. The content is not displayed in fullscreen and also it gets cropped.

 

ScreenShot_AIR.jpg

 

Code:

 

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
					   xmlns:s="library://ns.adobe.com/flex/spark" 
					   xmlns:mx="library://ns.adobe.com/flex/mx"
					   applicationComplete="windowedapplication1_applicationCompleteHandler(event)">
	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			import mx.events.ResizeEvent;
			
			private var urlLoader:URLLoader;
			private var swfLoader:Loader;

			protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
			{
				this.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
				this.stage.align = StageAlign.TOP_LEFT;
				
				TestLoadBytes();
			}
			
			public function TestLoadBytes():void
			{
				trace('<---------------- TestLoadBytes start -------------------------------->');
				
				urlLoader = new URLLoader();
				urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
				urlLoader.addEventListener(Event.COMPLETE, IniturlLoaderCompleteHandler, false, 0, true);
				urlLoader.addEventListener(IOErrorEvent.IO_ERROR, urlLoaderIOErrorHandler, false, 0, true);
				urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, urlLoaderHttpStatusHandler, false, 0, true);
				urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,urlLoaderSecurityErrorHandler,false,0,true);
				urlLoader.load(new URLRequest("https://source.swf"));	//sample URL of source swf file (resides i remote server)		 	
				
				trace('<---------------- TestLoadBytes end -------------------------------->');
			}
			public function swfLoaded(event:Event):void
			{
				trace('swf Loaded Completely--1')
				swfLoader.removeEventListener(Event.COMPLETE,swfLoaded);
				swfld.source = event.currentTarget.loader.content;				
				trace('swf Loaded Completely ---->');
			}
			
			public  function IniturlLoaderCompleteHandler(event:Event):void
			{
				trace('<---------------- IniturlLoaderCompleteHandler start -------------------------------->');
				
				var lc:LoaderContext = new LoaderContext(false, null);			
				lc.allowCodeImport=true;
				lc.allowLoadBytesCodeExecution = true;
				swfLoader = new Loader();
				swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfLoaded, false, 0, true);
				swfLoader.contentLoaderInfo.addEventListener(Event.INIT,swfInit,false,0,true);
				swfLoader.contentLoaderInfo.addEventListener(Event.ADDED_TO_STAGE,swfLoaderContentAdded,false,0,true);				
				urlLoader.removeEventListener(Event.COMPLETE,IniturlLoaderCompleteHandler);
				swfLoader.loadBytes(urlLoader.data, lc);
				trace('<---------------- IniturlLoaderCompleteHandler end -------------------------------->');
			}
			
			public function swfInit(evt:Event):void
			{
				trace('swfloader content Init stage');
			}
			
			public function swfLoaderContentAdded(evt:FlexEvent):void
			{
				trace('swfloader content creation Added stage');
			}
			
			public	function urlLoaderIOErrorHandler(evt:IOErrorEvent):void
			{
				trace("Unable to load swf IO Error "+evt.type);
				trace("Unable to load swf IO Error "+evt.errorID);
				urlLoader.removeEventListener(IOErrorEvent.IO_ERROR, urlLoaderIOErrorHandler);
			}
			
			public	function urlLoaderSecurityErrorHandler(evt:IOErrorEvent):void
			{
				trace("Unable to load swf SecurityError "+evt.errorID);
				urlLoader.removeEventListener(IOErrorEvent.IO_ERROR, urlLoaderIOErrorHandler);
			}
			public function urlLoaderHttpStatusHandler(evt:HTTPStatusEvent):void
			{
				trace("SWFLoading httpstatus code "+evt.status);
				urlLoader.removeEventListener(HTTPStatusEvent.HTTP_STATUS, urlLoaderHttpStatusHandler);
			}


			protected function swfld_resizeHandler(event:ResizeEvent):void
			{
				if(this.stage!=null)
				{
					swfld.width = this.stage.stageWidth;
					swfld.height = this.stage.stageHeight;
					trace('Stage height:'+swfld.height+' Stage Width:'+swfld.width);
				}

			}

		]]>
	</fx:Script>
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	<s:BorderContainer width="100%" height="100%" borderColor="blue" borderStyle="solid" borderWeight="4">
		<s:Group width="100%" height="100%">
			<s:SWFLoader width="100%" height="100%" scaleContent="true" id="swfld" resize="swfld_resizeHandler(event)">				
			</s:SWFLoader>
		</s:Group>
	</s:BorderContainer>
</s:WindowedApplication>

 

Please provide some suggestion on how to display the content of the SWF file in different reso;utions montiors. 

Views

31

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

SWF file content is not displayed to the full screen size

New Here ,
Oct 27, 2020

Copy link to clipboard

Copied

Hello All,

                 I'm just started to work on Adobe AIR right now.I'm facing a problem while loading a Flex web application based SWF file (MXML application file) on the AIR app using the SWFLoader. The content is not displayed in fullscreen and also it gets cropped.

 

ScreenShot_AIR.jpg

 

Code:

 

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
					   xmlns:s="library://ns.adobe.com/flex/spark" 
					   xmlns:mx="library://ns.adobe.com/flex/mx"
					   applicationComplete="windowedapplication1_applicationCompleteHandler(event)">
	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			import mx.events.ResizeEvent;
			
			private var urlLoader:URLLoader;
			private var swfLoader:Loader;

			protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
			{
				this.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
				this.stage.align = StageAlign.TOP_LEFT;
				
				TestLoadBytes();
			}
			
			public function TestLoadBytes():void
			{
				trace('<---------------- TestLoadBytes start -------------------------------->');
				
				urlLoader = new URLLoader();
				urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
				urlLoader.addEventListener(Event.COMPLETE, IniturlLoaderCompleteHandler, false, 0, true);
				urlLoader.addEventListener(IOErrorEvent.IO_ERROR, urlLoaderIOErrorHandler, false, 0, true);
				urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, urlLoaderHttpStatusHandler, false, 0, true);
				urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,urlLoaderSecurityErrorHandler,false,0,true);
				urlLoader.load(new URLRequest("https://source.swf"));	//sample URL of source swf file (resides i remote server)		 	
				
				trace('<---------------- TestLoadBytes end -------------------------------->');
			}
			public function swfLoaded(event:Event):void
			{
				trace('swf Loaded Completely--1')
				swfLoader.removeEventListener(Event.COMPLETE,swfLoaded);
				swfld.source = event.currentTarget.loader.content;				
				trace('swf Loaded Completely ---->');
			}
			
			public  function IniturlLoaderCompleteHandler(event:Event):void
			{
				trace('<---------------- IniturlLoaderCompleteHandler start -------------------------------->');
				
				var lc:LoaderContext = new LoaderContext(false, null);			
				lc.allowCodeImport=true;
				lc.allowLoadBytesCodeExecution = true;
				swfLoader = new Loader();
				swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfLoaded, false, 0, true);
				swfLoader.contentLoaderInfo.addEventListener(Event.INIT,swfInit,false,0,true);
				swfLoader.contentLoaderInfo.addEventListener(Event.ADDED_TO_STAGE,swfLoaderContentAdded,false,0,true);				
				urlLoader.removeEventListener(Event.COMPLETE,IniturlLoaderCompleteHandler);
				swfLoader.loadBytes(urlLoader.data, lc);
				trace('<---------------- IniturlLoaderCompleteHandler end -------------------------------->');
			}
			
			public function swfInit(evt:Event):void
			{
				trace('swfloader content Init stage');
			}
			
			public function swfLoaderContentAdded(evt:FlexEvent):void
			{
				trace('swfloader content creation Added stage');
			}
			
			public	function urlLoaderIOErrorHandler(evt:IOErrorEvent):void
			{
				trace("Unable to load swf IO Error "+evt.type);
				trace("Unable to load swf IO Error "+evt.errorID);
				urlLoader.removeEventListener(IOErrorEvent.IO_ERROR, urlLoaderIOErrorHandler);
			}
			
			public	function urlLoaderSecurityErrorHandler(evt:IOErrorEvent):void
			{
				trace("Unable to load swf SecurityError "+evt.errorID);
				urlLoader.removeEventListener(IOErrorEvent.IO_ERROR, urlLoaderIOErrorHandler);
			}
			public function urlLoaderHttpStatusHandler(evt:HTTPStatusEvent):void
			{
				trace("SWFLoading httpstatus code "+evt.status);
				urlLoader.removeEventListener(HTTPStatusEvent.HTTP_STATUS, urlLoaderHttpStatusHandler);
			}


			protected function swfld_resizeHandler(event:ResizeEvent):void
			{
				if(this.stage!=null)
				{
					swfld.width = this.stage.stageWidth;
					swfld.height = this.stage.stageHeight;
					trace('Stage height:'+swfld.height+' Stage Width:'+swfld.width);
				}

			}

		]]>
	</fx:Script>
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	<s:BorderContainer width="100%" height="100%" borderColor="blue" borderStyle="solid" borderWeight="4">
		<s:Group width="100%" height="100%">
			<s:SWFLoader width="100%" height="100%" scaleContent="true" id="swfld" resize="swfld_resizeHandler(event)">				
			</s:SWFLoader>
		</s:Group>
	</s:BorderContainer>
</s:WindowedApplication>

 

Please provide some suggestion on how to display the content of the SWF file in different reso;utions montiors. 

Views

32

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 27, 2020 0

Have something to add?

Join the conversation