Skip to main content
Inspiring
August 2, 2011
Question

Embedding a website swf in my own AIR/FLASH application

  • August 2, 2011
  • 1 reply
  • 843 views

Hi,

I'm curious to know if I'm able to load a swf that is already embeded in a website into a new AIR/FLASH application. I'm trying to do a screensaver mode when there is no mouse activities in configurator.swf. Is this possible?

For example:

I have a website that has a swf loaded in it, and I want to load that swf file in another of my AIR/FLASH application.

The website link is http://test.com/configurator.swf (this link is just an example, it will not work). configurator.swf is the swf file that is embeded in the webpage. The SWF file will communicate with a server to retrieve the latest information.

And I want to load the swf that is in the website link to an AIR/FLASH application that I'm going to create now...

Can I embed the swf into an AIR/FLASH application?

If I can, should I use AIR or FLASH projector?

If not, are there any workaround?

Thanks alot,

Zainuu

This topic has been closed for replies.

1 reply

ZainuuAuthor
Inspiring
August 2, 2011

Here's my code to load a swf in a website to an AIR file:

import flash.net.URLRequest;

import flash.display.Loader;

import flash.events.Event;

import flash.events.ProgressEvent;

function startLoad()

{

var mLoader:Loader = new Loader();

var mRequest:URLRequest = new URLRequest("http://test.com/configurator.swf");

mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);

mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);

mLoader.load(mRequest);

}

function onCompleteHandler(loadEvent:Event)

{

      addChild(loadEvent.currentTarget.content);

}

function onProgressHandler(mProgress:ProgressEvent)

{

var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;

trace(percent);

}

startLoad();

I'm getting errors like:
*** Security Sandbox Violation ***
SecurityError: Error #2047: Security sandbox violation:
Does that means I can't load swf file created by other people?

Kenneth Kawamoto
Community Expert
Community Expert
August 2, 2011

You can load a SWF from anywhere into your AIR, however, loaded SWF cannot access your AIR and your AIR cannot access loaded SWF unless it is loaded from the same domain (namely "app:/" in the case of AIR).

Therefore the reason you get Security Sandbox Violation is that the loaded SWF is trying to access your AIR. It probably has stage.addEventListener or something like that - stage means your AIR and that is not allowed.

ZainuuAuthor
Inspiring
August 2, 2011

So is there any workaround for the Security Sandbox Violation?