Jump to content
Search Community

How to effectively remove a LoaderMax SWFs from the stage?

ngrinchenko test
Moderator Tag

Recommended Posts

I can not figure out a proper coding to remove a loded SWF from the stage.

Here is my set up.

I have a layout segmented into labeled section. In the section labeled "products" I have a layout consisting of product images acting as buttons which bring a user to another labeled section "prdctsPopUps"

In the "prdctsPopUps" section I have placed an instance of LoaderMax placed into an mc container. Placing LoaderMax into an mc container automatically resolved an issue of clearing loaded SWFs from stage when I come back to "products" section.

I specified the variable in the "products" section with the following set up:

 

var sourceVar_ProductsPopUps:String;

 

function onClickSumix1PopUp(event:MouseEvent):void {
 sourceVar_ProductsPopUps="prdcts_popups/sumix1-popup_tl.swf";
 gotoAndPlay("prdctsPopUps");
 }

 

So each button has its own "....swf" URL and they all open fine and I can come back to "products" section without any issues.

 

However inside the swf (which loads through LoaderMax which is placed into an mc) there are other buttons which bring a user to labeled section "xyz". Which also functions properly. It opens as it is supposed to be and without any previously loaded "...swf" on the stage.

At the labeled section "xyz" there is a limited set of buttons repeating from section "products" which has to bring a user back to the same set up in the "prdctsPopUps" labeled section and open a corresponding "...swf" .

However only the last opened "...swf" will appear in that section. Effectively the one which was originally opened from the "prdctsPopUps" section and not the one which was supposed to be opened from the "xyz" section.

 

I can not understand why it would work from one labeled section and not from another. I can not figure out on which section which code/function needed to be placed.

 

Here is the set up from a button from the "xyz" section whcih supposed to bring a user to the same "prdctsPopUps" section but to load a different "...swf"

 

var sourceVar_ProductsPopUps_fromXYZ:String;

 

function onClick_floralytePopUp_fromXYZ(event:MouseEvent) :void {
 sourceVar_ProductsPopUps_fromXYZ="prdcts_popups/floralyte-popup_tl.swf";
 gotoAndPlay("prdctsPopUps");

 }

 

 

Here is the code set up for the LoaderMax from the "prdctsPopUps" section:

 

var loaderProductPopUps:SWFLoader = new SWFLoader(sourceVar_ProductsPopUps, 
 {
 estimatedBytes:5000, 
 container:holderMovieClip,
 onProgress:progressHandler,
 onComplete:completeHandler,
 centerRegistration:true,
 alpha:1, 
 scaleMode:"none",
 width:540, 
 height:730,
 crop:true,
 autoPlay:false
 });


function progressHandler(event:LoaderEvent):void{
 progressBarPopUp_mc.gradientbarPopUp_mc.scaleX = loaderProductPopUps.progress;
}


function completeHandler(event:LoaderEvent):void{
 var loadedImage:ContentDisplay = event.target.content;
 TweenMax.to(progressBarPopUp_mc, 1.5, {alpha:0, scaleX:0.25, scaleY:0.25}); 
 }


loaderProductPopUps.load();

 

 

Is there something which needs to be imported, or specific function needs to be specified in a specific labeled section?

Link to comment
Share on other sites

it is very difficult to visualize how your file is set up, although I think I have a very general understanding.

 

it can become very problematic in Flash to be jumping around from frame to frame and placing code on individual frames. it makes it vey difficult to track down errors and also to explain to others what is going wrong.

instead of using frames on the timeline to show and hide certain elements, you really should be creating movie clips for each section of your application, place all the movie clip sections on frame 1 and create functions that show and hide the necessary sections when applicable.

 

I understand that you are just starting out, but it is in your best interest to break away from having code on multiple frames of your timeline.

 

 

For now I would suggest starting with some trace() functions to see if the code you expect is running is even running at all.

 

For instance, right before the SWFLoader is created, please confirm that it is loading the proper swf:

 

trace("sourceVar_ProductsPopUps = " + sourceVar_ProductsPopUps);

var loaderProductPopUps:SWFLoader = new SWFLoader(sourceVar_ProductsPopUps, 
 {
 estimatedBytes:5000, 
 container:holderMovieClip,
 onProgress:progressHandler,
 onComplete:completeHandler,
 centerRegistration:true,
 alpha:1, 
 scaleMode:"none",
 width:540, 
 height:730,
 crop:true,
 autoPlay:false
 });

 

when you press the button in xyz section do you see the url of the "different swf" show up?

Link to comment
Share on other sites

Hi Carl,

Appreciate you are willing to delve into this issue.

Tracing revealed that when I try to load a different SWF second time around it is still the first one which is being loaded.

I.e first time I load an SWF I have a trace URL of this SWF, when second time I try to load a different SWF with a different URL the first string is still being traced.

Link to comment
Share on other sites

keep in mind you are creating a new variable with a new name from xyz:

 

sourceVar_ProductsPopUps_fromXYZ="prdcts_popups/floralyte-popup_tl.swf";

 

but your SWFLoader is using another variable for the url of the swf it is going to load

 

var loaderProductPopUps:SWFLoader = new SWFLoader(sourceVar_ProductsPopUps, ...})

 

in short, what you are doing with sourceVar_ProductsPopUps_fromXYZ has no effect on what is being loaded.

Link to comment
Share on other sites

instead of using frames on the timeline to show and hide certain elements, you really should be creating movie clips for each section of your application, place all the movie clip sections on frame 1 and create functions that show and hide the necessary sections when applicable.

Hi Carl,

Wanted to came back to the suggestion you have made earlier. Unfortunately it is a foreign concept to me. I would like to grasp it and apply to my site. Are there any samples or tutorials on this principle of building the site which you could recommend or send me a link to?

I started with my flash practice by typing a google search on how properly to built a flash site, it brought me to a lot of you tube videos. None of them I saw was something like you described.

The best way I summarized at that moment was to brake the site into sections and label them (as it makes easier to move things around) and try to dynamically load as much stuff as possible.

 

And of course now I am redoing the site with as much greensock features as possible. Previously I used native flash time line tweening which unfortunately resulted in a horrible performance...

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...