A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Problem loading external files

Threaded View

  1. #1
    A Happy Guy
    Join Date
    Jul 2005
    Posts
    107

    Problem loading external files

    I'm sorry if this is somewhere else on the forum. I searched and couldn't find it anywhere. It seems to me like it should be a simple problem, but I just can't figure it out...

    I have a file that loads an external swf on the click of a button. I am able to load and remove the file perfectly fine, but once I unload it, I can't load it a second time if the button is pressed again.

    Also, I have two separate external files loading when respective buttons are clicked, and whenever one is loaded, the other can't be loaded correctly simultaneously, and once one is removed, the other won't load either.

    So I can load one or the other movie clip once, but once it's been loaded and removed, nothing else will load. My code is below. Does anyone know why this might be?

    Code:
    // this opens the photo gallery.
    
    var photoloader:Loader = new Loader();
    var outside:URLRequest = new URLRequest("index.swf");
    
    this.photo_btn.addEventListener(MouseEvent.MOUSE_DOWN, photoOpen);
    
    function photoOpen(event:MouseEvent):void {
    	photoloader.load(outside);
    	addChild(photoloader);
    	photoloader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    	this.photogal_close_btn.x = 1100;
    }
    
    // end
    
    // this closes the photo gallery
    
    function onComplete(event):void {
    	this.photo_btn.removeEventListener(MouseEvent.MOUSE_DOWN, photoOpen);
    	this.photogal_close_btn.addEventListener(MouseEvent.MOUSE_DOWN, photoClose);
    }
    
    function photoClose(event:MouseEvent):void {
    	this.photoloader.unload();
    	this.photogal_close_btn.x = 1300;
    	this.photo_btn.addEventListener(MouseEvent.MOUSE_DOWN, photoOpen);
    }
    
    // end
    
    // this opens the artist gallery.
    
    var artistloader:Loader = new Loader();
    var artistoutside:URLRequest = new URLRequest("artist.swf");
    
    this.artist_btn.addEventListener(MouseEvent.MOUSE_DOWN, artistOpen);
    
    function artistOpen(event:MouseEvent):void {
    	artistloader.load(artistoutside);
    	addChild(artistloader);
    	artistloader.contentLoaderInfo.addEventListener(Event.COMPLETE, onArtistComplete);
    	this.artist_close_btn.x = 1100;
    }
    
    // end
    
    // this closes the artist gallery
    
    function onArtistComplete(event):void {
    	this.artist_btn.removeEventListener(MouseEvent.MOUSE_DOWN, artistOpen);
    	this.artist_close_btn.addEventListener(MouseEvent.MOUSE_DOWN, artistClose);
    }
    
    function artistClose(event:MouseEvent):void {
    	this.artistloader.unload();
    	this.artist_btn.addEventListener(MouseEvent.MOUSE_DOWN, artistOpen);
    	this.artist_close_btn.x = 1300;
    }
    
    // end
    Thanks!
    Last edited by Marty0473; 01-02-2009 at 12:34 PM.
    Aristotle was famous for knowing everything. He tought that the brain exists merely to cool the blood and is not involved in the process of thinking.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center