Jump to content
Search Community

Hanti

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by Hanti

  1.  

    I don't think it should be necessary, but it seems if I remove the code that queue.unload(), the other swfs don't load. This again seems odd as your loader_child should have no relation to the queue.

     

    If you remove the code that queue.unload(), the other swfs are loaded but they are behind the home.swf (loaded via LoaderMax). If you change x of loader_child to 120 you can see them.

     

    I wait for your news! Thanks Carl!  :-P

  2. Hi Carl and thanks again for your help!

    I have rewritten the code with SelfLoader but I know you can do better...

     

    I would like to ask you a few things:

     

    - When I click on a button I unload the queue of LoaderMax, is the right thing to do?

    - Why the total_bar seems to start loading from the middle of the line? Is there a way to have a more linear animation?

    - Why I receive "progress: 0" when I click on a button? This is contained in progressHandler() and not in child_progressHandler()

     

    This is a files link: http://we.tl/RshuyeKD0F

     

    Thanks!  :-P

    package  {
    	
    	import flash.display.MovieClip;
    	import flash.events.*;
    	import flash.display.*;
    	import com.greensock.loading.*;
            import com.greensock.events.LoaderEvent;
    	
    	
    	public class main extends MovieClip {
    		
    		var queue:LoaderMax = new LoaderMax({name:"mainQueue", onInit:initHandler, onProgress:progressHandler, onComplete:completeHandler});
    
    		var loader_child:SWFLoader = new SWFLoader("",{onInit:child_initHandler, onProgress:child_progressHandler, onComplete:child_completeHandler,  container:this, x:100, y:50});
    		
    		public function main() {
    			// constructor code
    			init_totalLoader();
    			
    			var swf:Array = new Array(works,about,contact,home);
    			for (var i:int=0; i<swf.length; i++) {
                            swf[i].addEventListener(MouseEvent.CLICK, openSwf);
    			swf[i].visible=false;
                }
    			
    			child_bar.visible=false;
    		}
    		
    		
    		public function init_totalLoader() {
    			 
                 //append the SelfLoader and several other loaders
    			 var loader:SelfLoader = new SelfLoader(this, {name:"self"});
                 queue.append( loader );
                 queue.append( new SWFLoader("swf/home.swf", {name:"home", container:this, x:100, y:50}) );
                 //start loading the LoaderMax queue
                 queue.load()
    			 
    		}
    		
    
    		
    		
    		function openSwf(e:MouseEvent): void{
    			
                 var newURL:String = "swf/" + e.target.name + ".swf";
                 loader_child.url = newURL;
                 loader_child.load(true); // reload SWFLoader and flush/unload old content
            }
    		
    		
    		
    		///////////////////TOTAL LOADER FUNCTIONS///////////////////////////
    		 
            public function initHandler(event:LoaderEvent):void {
    			
    		total_bar.visible=true;
    		
            }
    		
    		
            public function progressHandler(event:LoaderEvent):void {
    		
    		percent.text=String(Math.floor(event.target.progress*100))+"%";
    	    total_bar.totalprogress.scaleX = event.target.progress;
            trace("progress: " + event.target.progress);
    		
            }
    		
    		
    		public function completeHandler(event:LoaderEvent):void {
    			
             trace(event.target + " is complete!");
    		 percent.visible=false;
    		 child_bar.visible=true;
    		 total_bar.visible=false;
    		 home.visible=true;
    		 works.visible=true;
    	     contact.visible=true;
    		 about.visible=true;
    		 
            }
    		
    		
    		
    		///////////////////CHILD LOADER FUNCTIONS///////////////////////////
    		 
            public function child_initHandler(event:LoaderEvent):void {
    			
    			queue.unload()
            
            }
    		
    		 
            public function child_progressHandler(event:LoaderEvent):void {
    			
    		child_bar.childprogress.scaleX = event.target.progress;
    		
            }
    		
    		public function child_completeHandler(event:LoaderEvent):void {
    			
    			
            }
    		
    	}
    	
    }
    
    
  3. Hi Carl, thanks for your help!  :-P

    I'm sorry but maybe I did not understand, I should do it on main.swf or should I create another swf file (for example index.swf) that loads the main.swf and home.swf?

     

    I would like to load main.swf and home.swf on a different progress bar from "progress_mc"...

     

     

    This is what I would do:

    flow.jpg

     

    Do you show me an example?

    Thanks for your time Carl!

  4. Hello!

    I have a swf "main.swf" with four button that loads four external swf. 

    When I open "main.swf" load the first swf "home.swf" 

    import com.greensock.*;
    import com.greensock.loading.SWFLoader;
    import com.greensock.events.LoaderEvent;
    import flash.events.MouseEvent;
    
    
    var loader:SWFLoader = new SWFLoader("home.swf",{onInit:initHandler, onProgress:progressHandler, onComplete:completeHandler, container:this});
    var swf = new Array(home,about,contact,works);
    
    
    for (var i:int=0; i<swf.length; i++) {
    swf[i].addEventListener(MouseEvent.CLICK, openSwf);
    }
    
    
    function openSwf(e:MouseEvent): void{
    var newURL:String = e.target.name + ".swf";
    loader.url = newURL;
    loader.load(true); // reload SWFLoader and flush/unload old content
    }
    
    function initHandler(event:LoaderEvent):void {
    //fade the swf in as soon as it inits
    TweenLite.from(event.target.content, 1, {alpha:0});
    }
    
    
    function progressHandler(event:LoaderEvent):void {
    progress_mc.progressBar_mc.scaleX = event.target.progress;
    trace("progress: " + event.target.progress);
    }
    
    function completeHandler(event:LoaderEvent):void {
    trace(event.target + " is complete!");
    TweenLite.to(progress_mc.progressBar_mc, 1, {alpha:0});
    }
    
    //load the first swf 
    loader.load();
    

    I would like to write a code to preload my site and at the same time the first content (Home.swf) in a different total progress bar for for example "total_bar". I suppose that should be used a queue:LoaderMax and append all I want to load...is that right?

     

    But I should do it on main.swf or should I create another swf file (for example index.swf) that loads the main.swf and home.swf?

     

    Thanks for your help and sorry for my english!  :-P

     

     

  5. Hi Carl! Thank for your reply! I implement your code with the progress bar, is correct? Or you could do better? I'm a student and I would like to learn to use loaderMax for loading a site section (by external swf).
     

    import com.greensock.*;
    import com.greensock.loading.SWFLoader;
    import com.greensock.events.LoaderEvent;
    import flash.events.MouseEvent;
    
    
    var loader:SWFLoader = new SWFLoader("swf1.swf",{onInit:initHandler, onProgress:progressHandler, onComplete:completeHandler, container:this});
    var swf = new Array(swf1,swf2);
    
    
    for (var i:int=0; i<swf.length; i++) {
    swf[i].addEventListener(MouseEvent.CLICK, openSwf);
    }
    
    
    function openSwf(e:MouseEvent): void{
    var newURL:String = e.target.name + ".swf";
    loader.url = newURL
    loader.load(true); // reload SWFLoader and flush/unload old content
    }
    
    function initHandler(event:LoaderEvent):void {
    //fade the swf in as soon as it inits
    TweenLite.from(event.target.content, 1, {alpha:0});
    }
    
    
    function progressHandler(event:LoaderEvent):void {
    progress_mc.progressBar_mc.scaleX = event.target.progress;
    trace("progress: " + event.target.progress);
    }
    
    function completeHandler(event:LoaderEvent):void {
    trace(event.target + " is complete!");
    TweenLite.to(progress_mc.progressBar_mc, 1, {alpha:0});
    }
    
    //load the first swf 
    loader.load();
    
    
     

     
    I would have some question:

    - In LoaderMax is not necessary flush/unload old swf with removeChild?

    - How i can to do convey the estimatedBytes for each swf?

    - This is the right way to work for load a different section of my site?

     

    Thank you so much!  :-P

  6. Hi people! Help me please! :cry:

     

    I have this package code for a section menù. I have on the stage 4 menù item (name:swf1,swf2,swf3,swf4) and have one progress bar (name:progress_mc). I have in the folder "swf" 4 swf (name:swf1,swf2,swf3,swf4).

     

    I start with load swf and then when I click on one of the buttons load the swf corresponding (by the istance name).

     

    I would like to implement this code whit LoaderMax for load/unload this external swf and mark the progress bar. But I can not do! 

     

    someone can help me? Tnx!

     

     

     

     

    package  {
     
        import flash.events.MouseEvent;
        import flash.net.URLRequest;
        import flash.display.*;
        import flash.events.Event;
     
    public class caricaredatiesterni extends MovieClip {
     
            var defaultSWF:URLRequest = new URLRequest("swf/swf1.swf");
            var loader:Loader = new Loader();
     
    public function caricaredatiesterni() {
     
            var swf=new Array(swf1,swf2,swf3,swf4)
     
            for(var i:int=0; i<swf.length; i++)
            {
            swf.addEventListener(MouseEvent.CLICK, openSwf);
            }
     
            loader.load(defaultSWF);
            addChild(loader);
     
    }
     
    public function openSwf(e:MouseEvent)
            {
            removeChild(loader);
            var newSWFRequest:URLRequest = new URLRequest("swf/" + e.target.name + ".swf");
            loader.load(newSWFRequest);
     
            addChild(loader);
    }
    }
    }
     

     

×
×
  • Create New...