SapphireSteel Forum
Welcome, Guest. Please login or register.
May 21, 2013, 07:34:40 AM

Login with username, password and session length
Search:     Advanced search
Welcome to the SapphireSteel forum - for discussion of the Ruby In Steel and Amethyst IDEs
3884 Posts in 800 Topics by 669 Members
Latest Member: m
* Home Help Search Login Register
+  SapphireSteel Forum
|-+  General
| |-+  Amethyst
| | |-+  problem:Flex project loading SWF via SWFLoader only works when run from Amethyst
« previous next »
Pages: [1] Print
Author Topic: problem:Flex project loading SWF via SWFLoader only works when run from Amethyst  (Read 4414 times)
smodpows
Newbie
*
Posts: 5


« on: March 07, 2011, 12:22:44 AM »

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:

Code:
<?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:

Code:
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");
}


« Last Edit: March 07, 2011, 01:06:37 AM by smodpows » Logged
Huw Collingbourne
Administrator
Hero Member
*****
Posts: 934



« Reply #1 on: March 07, 2011, 09:38:27 AM »

This sounds like a Flash problem rather than an Amethyst one. It's likely to arise if your SWF is either built in a location that is not considered to be trusted or if your app and the loaded SWF are built with different network settings. Adobe has a peculiar online tool here that can be used to set trusted location settings: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

However, it may be sufficient just to ensure that your app and its loaded SWF are both built using the same network settings. This can be set as a compiler option in Project/Properties/Compiler/Use network. You may need to experiment with this setting on both the Flex 4 app and the SWF that you plan to load.

best wishes

Huw
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #2 on: March 07, 2011, 11:25:02 AM »

I think an easier way might be to set 'Trust SWF' to true. Look in the project properties in the Application tab.

This default to false in 1.2 but we've changed this in 1.3 so that it defaults to true.

Dermot
Logged
rkosko
Jr. Member
**
Posts: 65


« Reply #3 on: May 31, 2011, 10:42:55 AM »

Hi Dermot

I too have this problem stated above and I made your suggested changes along with Huw's.
But to no avail .

Do you have any other suggestions to this probllem.

Thank you

Bob
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #4 on: May 31, 2011, 11:39:16 AM »

Hi Bob,

Look in the file
Code:
C:\Users\dermot\AppData\Roaming\Macromedia\Flash Player\#Security\FlashPlayerTrust\Amethyst.cfg
for the file you are trying to load (obviously, the location will be different for you, but it should be similar). Then make sure that you are loading the file using the exact specification in that cfg file. So if the file is

Code:
C:\Test\FlexApplication1\FlexApplication1\bin\Debug\FlexApplication1.swf

use

Code:
loader.load("C:\Test\FlexApplication1\FlexApplication1\bin\Debug\FlexApplication1.swf")

See if that works.

Dermot
Logged
rkosko
Jr. Member
**
Posts: 65


« Reply #5 on: June 01, 2011, 08:26:21 AM »

Hi Dermot

I still get the error

SecurityError: Error #2121: Security sandbox violation:
Loader.content: file:[snip]/src/flash3.swf
cannot access
 file:[snip]/src/SWF/Login/main.swf.
 This may be worked around by calling Security.allowDomain.
   at flash.display::Loader/get content()
   at com.sas.flashPhase::FlexLoader/loaderComplete()

I don't understand why I can't load a swf in the same file system.

Is this a flash thing. I am not a flash expert. I am tasked to set up a VS studio project for an existing flash application.

Bob


PS

I sucessfuly ran the application as a Amethyst Flash Player but I can not run it as a web applcation.
Also I CAN NOT run as a Adobe Flash Player. Debug or Otherwise.
« Last Edit: June 01, 2011, 09:50:22 AM by rkosko » Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #6 on: June 01, 2011, 01:35:17 PM »

I did a bit of searching for some info on this - I'm not a Flash expert by any means and I certainly don't understand the Flash security model. The simplest way to get this to work seem to be to 'trust' the whole of your development drive. See http://www.kirupa.com/forum/showthread.php?289600-Security-Error and look for the last reply.

Essentially, you need to set the C drive to be trusted using the Global Security Settings panel (http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html)

Before I set the security, I got the Sandbox exception and after, it worked fine for me:
Code:

private function button1_click(event:flash.events.MouseEvent):void {
var loader:SWFLoader = new SWFLoader();

loader.addEventListener(Event.COMPLETE, onSwfLoaded);
loader.load("C:\\Test\\FlexApplication5a\\Test1\\bin\\debug\\Test1.swf");
}
private function onSwfLoaded(e:Event):void {
trace("swf loaded by SWFLoader");
}

Dermot
Logged
rkosko
Jr. Member
**
Posts: 65


« Reply #7 on: June 02, 2011, 06:53:08 AM »

Thanks Dermot,

This seemed to work.

I now can run the app on the web browser and I can run the app on Adobe Flash Player

but it does not run under the Debug version of Adobe Flash Player. <strange/>

So my question is : Can I debug with the Amethyst version of the Flash Player or do I need to run with Adobe Debug Flash Player.

And thanks for all your help so far.

Bob
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #8 on: June 02, 2011, 09:54:59 AM »

I think this may be due to the version of the Flash Player that the Adobe Flash Player program uses. It's probably different from the one that's used by the Amethyst Flash Player, which uses the OCX version. I've had trouble with this before. The Amethyst one is a lot simpler than the Adobe version.

But to debug, you must have the 'content debugger' Player which is available from the Adobe website somewhere. If you have this, you should be able to debug either from a webpage or the Amethyst Player.

Dermot

Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!