Jump to content
Search Community

Swf Loading Overlapping content? load/unload

minusone test
Moderator Tag

Recommended Posts

Hey all/Jack.

 

Im having an issue here and im scratching my head, I did do some research and after messing around with the flush parameters it still did not do what I wanted to accomplish So I have to ask for some help on this one.

 

Basically what I am doing is loading in an array of swfs so I can flow through them in a carousel style, with next and previous arrows,logically you click the next arrow,it fades out one swf,and loads in the following swf.

 

However when I use loaderQueue.unload(); and once again load. it will fade out the current swf,but when it loads in the new one it has the new swf overlapping the second one,if i press next again,it has 3 swfs,and so on. So it seems it is not removing my initial content.

 

Hopefully someobody can help me out here :(

 

Inside of swfVisualView I have

 public function createListeners():void
	{
		  BedrockDispatcher.addEventListener( SiteEvent.PREVIOUS_DONE, this.onUnloadSwf );
		  BedrockDispatcher.addEventListener( SiteEvent.NEXT_DONE, this.onUnloadSwfFinal );
		  BedrockDispatcher.addEventListener( SiteEvent.NEXT_READY, this.createLoader );
	}

	public function createLoader($event:SiteEvent):void
	{
		this.createLoaderQueue();
	}

	public function createLoaderQueue():void
       {
           trace("Creating Loader Queue");
           var loaderQueue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:this.onProgressHandler, onComplete:this.onCompleteHandler, onError:this.onErrorHandler});
           this.appendLoaders(this.data.swfSource);
      }

       // Append Several Loaders
       public function appendLoaders($url:String):void
       {

           var urlRequest:String = (BedrockEngine.config.getEnvironmentValue( BedrockData.SWF_PATH ) + this.data.swfSource );
           loaderQueue.append( new SWFLoader(urlRequest, {name:"mainClip", estimatedBytes:3000, container:this, autoPlay:false}) );
           loaderQueue.load(true);
           loaderQueue.autoDispose = true;
       }


       public function onUnloadSwf($event:SiteEvent):void
       {
       	trace("I heard it was time to unload?");
       	 loaderQueue.unload();
       	 loaderQueue.dispose(true);
       	 loaderQueue = null;
       }

       public function onLoadSwf():void
       {
           loaderQueue.load(true);
       }


       /*
       Event Handlers
       */
       public function onProgressHandler($event:LoaderEvent):void
       {
           trace("progress: " + $event.target.progress);
       }
       public function onCompleteHandler($event:LoaderEvent):void
       {
           trace($event.target + " is complete!");

           //this.onLoadSwfFinal();
       }
       public function onErrorHandler($event:LoaderEvent):void
       {
            trace("error occured with " + $event.target + ": " + $event.text);
       }

 

Inside of the initial container,where I make my index switches to reload a new swf to load I have

 


               public function intro($data:Object=null):void
       {
       	//BedrockDispatcher.dispatchEvent( new SiteEvent( SiteEvent.NEXT_READY, this) );
               TweenLite.to(this.container, 3, {delay:0.5,alpha:1});
       }

       public function outro($data:Object=null):void
       {
           TweenLite.to(this.container, 1, {alpha:0,onComplete:this.outroDone});
       }

       public function outroDone():void
       {
       }


	public function clear():void
	{

	}
 /*
	Create Functions
	*/

	public function createListeners():void
	{
		  ButtonUtil.addListeners( this.leftArrow, { down:this.onPrevious} );
                          ButtonUtil.addListeners( this.rightArrow, { down:this.onNext} );
	}


	public function outroDoneNext():void
             { 
        BedrockDispatcher.dispatchEvent( new SiteEvent( SiteEvent.NEXT_DONE, this) );

        trace("new index number is " + this.indexNumber++);

        var currentObject:Object = ReachModel.getInstance().brushes.data[this.indexNumber];
        var swfContainerClip:SwfVisualView = new EmptyContainer;
        this.container.removeChildAt(0);
        this.container.addChild(swfContainerClip);
        swfContainerClip.initialize(currentObject);
        this.intro();

       }

	public function outroDonePrev():void
       {
        BedrockDispatcher.dispatchEvent( new SiteEvent( SiteEvent.PREVIOUS_DONE, this) );

        var currentObject:Object = ReachModel.getInstance().brushes.data[this.indexNumber];

        var swfContainerClip:SwfVisualView = new EmptyContainer;
        this.container.removeChildAt(0);
        swfContainerClip.initialize(currentObject);
        this.container.addChild(swfContainerClip);
        this.intro();

       }


       /*
       Event Handlers
       */

	public function onPrevious($event:MouseEvent):void
       {
           TweenLite.to(this.container, 1, {alpha:0,onComplete:this.outroDonePrev});
           trace("new index number is " + this.indexNumber--);
              //BedrockDispatcher.dispatchEvent( new SiteEvent( SiteEvent.PREVIOUS_DONE, this) );
       }

       public function onNext($event:MouseEvent):void
       {
           TweenLite.to(this.container, 1, {alpha:0,onComplete:this.outroDoneNext});
              //BedrockDispatcher.dispatchEvent( new SiteEvent( SiteEvent.PREVIOUS_DONE, this) );
       }

 

So basically when I unload I just re initilize a new index so it can load in the next swf in my array.

Which ultimately it does do,but it will have every previous swf loaded into it behind it.

 

Thanks in advance

Link to comment
Share on other sites

Hm, something seems odd with your code - you defined loaderQueue as a local variable inside your createLoaderQueue() method but then you accessed it in other methods as though it was an instance property. That wasn't your real code, right?

 

It sounds like you're not really unloading the content, or you're calling unload() on the wrong instance(s). Please post a sample FLA that demonstrates the issue. It doesn't need to be your production file(s) - just something super simple that shows it breaking. That makes troubleshooting MUCH, MUCH faster and easier.

Link to comment
Share on other sites

Hey Jack,

Yes stupid me after revising the code and seeing the set up that was given to me, I figured it out. After taking a break from a long days worth of coding :ugeek:

 

Great product,saves us loads of time,Thanks very much

Link to comment
Share on other sites

Hey Jack,

Yes stupid me after revising the code and seeing the set up that was given to me, I figured it out. After taking a break from a long days worth of coding :ugeek:

 

Great product,saves us loads of time,Thanks very much

 

Super. Glad to hear you figured it out. Load away.

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