dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Need help loading flash as2 in flex 3.

  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    4

    Need help loading flash as2 in flex 3.

    I am trying to load a flash game in flex but the game does not work the same as it does in the flash player. The game was made using AS2 but I read somewhere that is should play without errors, that is not the case. Played normally the guns shoot the enemies no problem but in flex the bullets just float around the enemies never hitting them. It is hard to describe what is happening so I also included a link with the flex 3 project file that has all of the files.

    Here is what I am using for my flex 3 code.
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
    	creationComplete="init()">
    	<mx:Script>
    		<![CDATA[
    
    			private function init():void{
    				loader.width = 550;
    				loader.height = 400;
    				loader.source = "Caroler Defense.swf";
    				loader.scrollRect= new Rectangle(0,0,loader.width,loader.height);
    			}
    			
    		]]>
    	</mx:Script>
    
    	<mx:SWFLoader id="loader"/>
    	
    	
    </mx:Application>
    So is there a way to just play the swf file without messing up the game?
    Last edited by wac0020; 08-23-2009 at 06:31 PM.

  2. #2
    Junior Member
    Join Date
    Jan 2009
    Posts
    4
    I figured it out, here is how I did it.
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
    
    <mx:Script>
    	<![CDATA[
    		import mx.core.UIComponent;
    		
    		private var request:URLRequest = new URLRequest("test.swf");
    		private var loader:Loader = new Loader();
    		
    		private var myComponent:UIComponent = new UIComponent;  
    		
    		private function init():void{
    			loader.load(request);
    			myComponent.addChild(loader);
    			player.addChild(myComponent);
    		}
    		
    	]]>
    </mx:Script>
    	
    	<mx:Canvas id="player"/>
    	
    </mx:Application>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center