Skip to main content
Known Participant
January 15, 2014
Answered

HTMLLoader loading local content (SWF files) problem

  • January 15, 2014
  • 1 reply
  • 1435 views

Hello guys,

I'm just finishing my application but I facing a problem.

I'm currently developing a desktop application using AIR.

I'm using HTMLLoader to load local SWF files when te user tries to access specific content on the application.

I successfully accomplished this, but the loaded SWF also loads other files (assets and xml files with translations) and that is not working.

When a SWF is loaded he just stops on his own loading screen (when loading the XML files).

All this stuff is happening on my CustomNativeWindow:

(my CustomNativeWindow "overlays" the main application)

public function CustomNativeWindow()

{

         var nativeWindowInitOptions:NativeWindowInitOptions = new NativeWindowInitOptions();

         nativeWindowInitOptions.systemChrome = NativeWindowSystemChrome.NONE;

         nativeWindowInitOptions.renderMode = NativeWindowRenderMode.DIRECT;

         nativeWindowInitOptions.resizable = false;

         nativeWindowInitOptions.maximizable = false;

         nativeWindowInitOptions.minimizable = false;

 

         super(nativeWindowInitOptions);

 

         alwaysInFront = true;

 

         this.activate();

}

 

public function setProperties(contentName:String, contentURL:String, posX:Number, posY:Number, stageWidth:Number, stageHeight:Number):void

{

          this.stageHeight = stageHeight;

          this.stageWidth = stageWidth;

          this.contentURL = contentURL;

          this.contentName = contentName;

 

          this.x = posX;

          this.y = posY;

 

          this.width = stageWidth;

          this.height = stageHeight;

 

          this.title = contentName;

 

          this.addEventListener(Event.RESIZE, onWindowResize);

 

          SWFHTMLLoader();

}

 

private function SWFHTMLLoader():void

{

          //REQUEST LOAD URL

          var request:URLRequest = new URLRequest(contentURL);

 

          //HTML LOADER SWF

          htmlLoader  = new HTMLLoader();

          htmlLoader.width = stageWidth;

          htmlLoader.height = stageHeight;

          htmlLoader.addEventListener(Event.COMPLETE, onHtmlLoaderComplete);

          htmlLoader.load(request);

 

          stage.addChild(htmlLoader);

}

 

private function onHtmlLoaderComplete(e:Event):void

{

          trace("NATIVE WINDOW HTMLLoader complete");

 

          onWindowResize();

}

 

private function onWindowResize(e:Event = null):void

{

          if (htmlLoader)

          {

                    htmlLoader.width = stage.stageWidth;

                    htmlLoader.height = stage.stageHeight;

          }

}

Probably something related to security?

How can I fix this?

Is kinda urgente... deadline is coming...

Thank you!

This topic has been closed for replies.
Correct answer kglad

it's probably related to a path problem.

what's contentURL?

if it's anything other than swfname.swf, you have a problem.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 15, 2014

it's probably related to a path problem.

what's contentURL?

if it's anything other than swfname.swf, you have a problem.

croxoverAuthor
Known Participant
January 15, 2014

Thank you kglad for your fast response...

The reference to the content comes from a XML loaded on the main application.

var xml:XML =      <Content  en="game" >

                                  <ImageSource>assets/images/gallery/resources/gameone.png</ImageSource>

                                  <ContentSource>content/gameone/gameone.swf</ContentSource>

                            </Content>;

contentURL = xml.ContentSource;

So contentURL is: content/gameone/gameone.swf

Am I in trouble?

kglad
Community Expert
Community Expert
January 15, 2014

yes.

when gameone.swf is executed as a stand-alone loads its assets relative to it (or its embedding html's) location.

when gameone.swf is loaded by your main app it loads its assets realtive to the location of the main app.

to remedy, change the paths in gameone.swf.  if gameone.swf needs to work both as a standalone and when loaded by your main app, use an if-statement to check main timeline's parent.

btw, why aren't you loading the embedding html file of gameone.swf?  that would eliminate the problem.

of, if you don't want to load the html file, why are you using htmlloader instead of a loader?