Jump to content
Search Community

Cant load external gallery using loadermax

gsFan test
Moderator Tag

Recommended Posts

Hi , i am trying to use loadermax to load a gallery i purchased via activeden site, my problem is that when i use loadermax to load my external swf gallery in my main swf it doesnt work but if i use the native as3 loader it works, what im doing wrong, can someone help me please?

 

Here is the code of my both examples:

 

LOADERMAX

 

package  {
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import flash.display.*;

public class carga extends MovieClip {

public function carga() {
 // constructor code
 var mySwf1:SWFLoader = new SWFLoader("preview.swf", {width:1024, height:750, container:this});
 mySwf1.load();

 }

}

 

NATIVE AS3 LOADER

 

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("preview.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();

Link to comment
Share on other sites

Hi, sorry to hear you are having problems.

 

I really don't know what the problem could be. By any chance do you have access to the fla of the gallery swf that you are using? Has it been compiled with an older version of the greensock library?

 

Are you sure your carga object has been added to the display list?

Do you get any errors?

 

Have you tried putting in some onProgress or onCompleteHandlers to test to see if the loading is happening at all

 

 

 


package  {
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import flash.display.*;

public class carga extends MovieClip {

public function carga() {
 // constructor code
 var mySwf1:SWFLoader = new SWFLoader("preview.swf", {width:1024, height:750, container:this, onComplete:onCompleteHandler});
 mySwf1.load();

 }

public function onCompleteHandler(e:LoaderEvent):void{
trace('loaded ' + e.target);
}

}


 

If its within your usage rights to share the swf with us, feel free to zip it up and send it via a private message to me. I'll give it a look.

Link to comment
Share on other sites

I have some good news for you.

 

The following SWFLoader code will work with your external swf:

 

 

import com.greensock.loading.*;
import flash.display.Loader;
import com.greensock.events.LoaderEvent;

var swf:SWFLoader = new SWFLoader("preview.swf", {onComplete:completeHandler, onProgress:progressHandler});

function completeHandler(e:LoaderEvent):void{
trace("complete");
addChild(e.target.content); 
}

function progressHandler(e:LoaderEvent):void{
trace(e.target.progress); 
} 

swf.load();

 

It appears that the preview swf relied on an ADDED_TO_STAGE event to trigger its initialization routine. When you specify a container in your SWFLoader constructor like so:

 

var swf:SWFLoader = new SWFLoader("preview.swf", {containter:this});

 

the ContentDisplay object that wraps around your loaded swf gets added to the display list BEFORE the swf even loads and I imagine that is why the loaded swf never got the event and thus didn't run its init() method.

 

I think you should be in good shape now. Let me know if you have any trouble updating your code.

 

-Carl

Link to comment
Share on other sites

oh, here is your original code modified:

 

 

package  {
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import flash.display.*;



public class carga extends MovieClip {


public function carga() {
// constructor code
var mySwf1:SWFLoader = new SWFLoader("preview.swf", {width:1024, height:750, onComplete:completeHandler});
mySwf1.load();


} 

public function completeHandler(e:LoaderEvent) {
// constructor code
addChild(e.target.content);

} 


}

}

Link to comment
Share on other sites

Thank you for taking your time to help me Carl . I tried the code and now it works.

 

Now i have another problem, i need that the external gallery be called inside a movieclip . I made a rectangle in the cargaswf.fla and called it contenedor_mc but it dont work it just call the gallery but not inside contenedor_mc.

 

This is my new code:

 

package  {
import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import flash.display.*;



public class carga extends MovieClip {
public var contenedor_mc:MovieClip;


public function carga() {
// constructor code
var mySwf1:SWFLoader = new SWFLoader("preview.swf", {width:1024, height:750, onComplete:completeHandler});
mySwf1.load();


}

public function completeHandler(e:LoaderEvent) {
// constructor code
contenedor_mc.addChild(e.target.content);

}


}

}

Link to comment
Share on other sites

ugh. It seems the gallery you are loading has code in Doc.as that specifically places all of the individual gallery elements on the Stage object. From the AS3 Docs

 

 

 

The Stage of the display object. A Flash runtime application has only one Stage object. For example, you can create and load multiple display objects into the display list, and the stage property of each display object refers to the same Stage object (even if the display object belongs to a loaded SWF file).

 

 

 

So even though you placed the gallery into your own MovieClip, the gallery itself does stuff like:

 

stage.addChild(_imageHolder);

stage.addChild(_infoHolder);

stage.addChild(_controlsHolder);

 

The code above is going to override anything you do and place the elements on the stage of the parent swf (cargaswf.swf)

I imagine it is possible to loop through all the items on the stage and try to place them back into your container, but I am guessing that will also impact how the following resize code is going to work:

 

 

_stageSetup = new StageSetup(stage);

_stageSetup.addEventListener(CustomEvent.ON_STAGE_RESIZE, handleResize);

_stageSetup.addEventListener(CustomEvent.ON_ENTER_FULLSCREEN, inFullScreen);

_stageSetup.addEventListener(CustomEvent.ON_EXIT_FULLSCREEN, outFullScreen);

 

everywhere their code says

stage.addChild(something)

you could try

this.parent.addChild(something)

 

No guarantees that is going to work. They have 1900 lines of code and unfortunately I can't go through it all and experiment with different options.

 

It appears the author of this gallery didn't intend for it to be sub-loaded into another swf :(

 

Perhaps you can contact the author of the file for some ideas.

 

I regret that I can't be of more assistance.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...