I'm having problems building a project in Flex4 around an swf application that I've already written as an ActionScript 3.0 project.
My inner swf file is located in the Debug folder for my VS project, as are some files that it loads at startup. In my Flex project I load the inner swf via SWFLoader() and add it as a child to a Canvas, which I created in the Main mxml file. Everything works fine when I build the project in Amethyst and I'm able to interact with the inner swf from the Amethyst Flash Player.
However, when I attempt to run the Flex project's swf from the Debug folder it no longer contains the inner swf application. There is only the blank Canvas where it normally loads. I'm new to Flex so am I just missing some step?
The same thing occurs when for the inner swf I load a simple swf containing only a MovieClip, like the one that is used in your tutorial on Flash Movies in Visual Studio Projects:
http://www.sapphiresteel.com/Tutorials/Amethyst-Tutorials/article/flash-movies-in-visual-studio. I can see the MovieClip playing in the Amethyst Flash Player, but not when I open the Flex project's swf file in either my internet browser or the standalone Flash player.
I have tried building the project and running in IE with a debug version of Flash instead of with the Amethyst Flash Player. When I do that I get an exception saying "Error #2044: Unhandled securityError:. text=Error #2140: Security sandbox violation...Local-with-filesystem and local-with-networking SWF files cannot load each other". Could this be the problem? If so, how to I setup Amethyst to build my swf's as either Local-with-filesystem and local-with-networking files? And when is it proper to use one or the other?
this is my mxml file:
<?xml version="1.0" encoding="utf-8"?>
<s:Application height="700" width="330" backgroundColor="#222222" applicationComplete="init()"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<mx:Canvas backgroundColor="#000000" height="700" id="canvas" name="Canvas" width="330" x="0" y="0"/>
<fx:Script source="LoadMySWF.designer.as"/>
</s:Application>
and here is the LoadMySWF.designer.as file:
import mx.events.*;
import mx.controls.SWFLoader;
public function init():void {
// load InnerApp swf using SWFLoader
var loader:SWFLoader = new SWFLoader();
loader.addEventListener(Event.COMPLETE, onSwfLoaded);
loader.load("InnerApp.swf");
canvas.addChild(loader);
}
private function onSwfLoaded(e:Event):void {
trace("swf loaded by SWFLoader");
}