Jump to content
Search Community

mico86

Members
  • Posts

    6
  • Joined

  • Last visited

mico86's Achievements

0

Reputation

  1. YOU ARE MY FU**** ANGEL! This is my complete code, with preload function and animation. I hope it can serve some desperate like me who has lost his head for days! var swf1:SWFLoader = new SWFLoader("bio.swf", {name:"bio_bt",onProgress:progressHandler,onComplete:completeHandler}); var swf2:SWFLoader = new SWFLoader("contatti.swf", {name:"contatti_bt",onProgress:progressHandler,onComplete:completeHandler}); var previousLoader:SWFLoader function progressHandler(event:LoaderEvent):void { //Display the % loaded in textfield preload_bg.visible = true; addChild(preload_bg); addChild(perc_txt); TweenLite.to(preload_bg,0.5,{x:stage.stageWidth, y:stage.stageHeight/2, alpha:1}); TweenLite.to(perc_txt,0.5,{x:stage.stageWidth-148, y:stage.stageHeight/2-33, alpha:1}); perc_txt.text=Math.ceil(event.target.bytesLoaded/event.target.bytesTotal * 100) + "%"; } function completeHandler(e:LoaderEvent):void{ //the first time you load something, there will be no previousLoader //make sure a previousLoader exists. TweenLite.to(e.target.content, 1, {alpha:1}); if(previousLoader) { if(previousLoader != e.target) //This is to ensure that the contents do "unload" if you click the button again active { previousLoader.unload(); } } previousLoader = e.target as SWFLoader; TweenLite.to(preload_bg,0.5,{x:stage.stageWidth+180, y:stage.stageHeight/2, alpha:1}); TweenLite.to(perc_txt,0.5,{x:stage.stageWidth, y:stage.stageHeight/2-33, alpha:1}); removeChild(perc_txt); removeChild(preload_bg); } bio_bt.addEventListener(MouseEvent.CLICK, onMouseClick); contatti_bt.addEventListener(MouseEvent.CLICK, onMouseClick); function onMouseClick(event:MouseEvent) { var swf:SWFLoader = LoaderMax.getLoader(event.target.name); swf.load(); addChildAt(swf.content,0); }
  2. great solution! But I get an error 1118 on previousLoader = e.target Implicit coercion of a value with static type Object to a type com.greensock.loading: SWFLoader that may not be related. this is my complete code: var swf1:SWFLoader = new SWFLoader("bio.swf", {name:"bio_bt",onComplete:completeHandler}); var swf2:SWFLoader = new SWFLoader("contatti.swf", {name:"contatti_bt",onComplete:completeHandler}); var previousLoader:SWFLoader function completeHandler(e:LoaderEvent):void{ //the first time you load something, there will be no previousLoader //make sure a previousLoader exists. if(previousLoader) { previousLoader.unload(); } previousLoader = e.target.content; //I try with content and compile correctry but unload of previousLoader doesn't work } bio_bt.addEventListener(MouseEvent.CLICK, onMouseClick); contatti_bt.addEventListener(MouseEvent.CLICK, onMouseClick); function onMouseClick(event:MouseEvent) { var swf:SWFLoader = LoaderMax.getLoader(event.target.name); swf.load(); addChildAt(swf.content,0); }
  3. Great! But my the problem is that I want a preloader that it loaded over the content already loaded (and this I get it already), so as not to leave you with empty content waiting to load. Only when the new content will be uploaded, will be replaced by the old. But now this happens: I click for example on "Home", the preloader (preload_bg perc_txt for graphics and for the loading rate), it loads the contents of "Home", but now if I click on "Bio" disappears "Home "appears and the preloader. I would like instead of Home vanish only when the preloader is 100% This is my code now: home_bt.addEventListener(MouseEvent.CLICK, onMouseClick); bio_bt.addEventListener(MouseEvent.CLICK, onMouseClick); contatti_bt.addEventListener(MouseEvent.CLICK, onMouseClick); var ContentLoader:SWFLoader = new SWFLoader("",{name:"ContContainer", container:this, onProgress:progressHandler, onComplete:completeHandler}); function progressHandler(event:LoaderEvent):void { //Display the % loaded in textfield preload_bg.visible = true; addChild(preload_bg); addChild(perc_txt); TweenLite.to(preload_bg,0.5,{x:stage.stageWidth, y:stage.stageHeight/2, alpha:1}); TweenLite.to(perc_txt,0.5,{x:stage.stageWidth-148, y:stage.stageHeight/2-33, alpha:1}); perc_txt.text=Math.ceil(event.target.bytesLoaded/event.target.bytesTotal * 100) + "%"; } function completeHandler(event:LoaderEvent):void { removeChild(perc_txt); removeChild(preload_bg); TweenLite.to(event.target.content, 1, {alpha:1}); //var mcTemp:MovieClip = ContentLoader.content; trace(event.target + " is complete!"); trace("La posizione di ContentLoader è: " + getChildIndex(ContentLoader.content)); } function onMouseClick(event:MouseEvent){ if(event.target.name =="home_bt") { ContentLoader.url = "index2.swf"; } if(event.target.name == "bio_bt") { ContentLoader.url = "bio.swf"; } if(event.target.name == "contatti_bt") { ContentLoader.url = "contatti.swf"; } addChildAt(ContentLoader.content,0); ContentLoader.load(); }
  4. The site usually loads the menus and content. When I click for example on bio should remove "home" and load the contents of "bio". When I click on "disco", should remove the contents of organic or home and load the "disco". How can I design this structure? I created a file containing the menu index.swf (loaded in the foreground) and loads home.swf in the background. Now when I click on "organic" content overlaps with that of home. I would like to unload and bio home.swf did take his place. http://imageshack.us/photo/my-images/84/examplesite.jpg/
  5. thank you very much! I'm noob, sorry I'm doing a site of 3 external swf with unique menu for all always on top. How do I set the 3 swf always in the background? I created a variable var oldLoader: SWFLoader = null; For now I have written this code (this is only for "bio_bt" in the external class of main swf container), but unfortunately does not work well! : ( bio_bt.addEventListener(MouseEvent.CLICK, onMouseClick0); function onMouseClick0(e:MouseEvent):void { var BioLoader:SWFLoader = new SWFLoader("bio.swf", {name:"BioLoad", container:this, alpha:0, onComplete:completeHandler2, onProgress:progressHandler2}); addChildAt(BioLoader.content,0); BioLoader.load(); function progressHandler2(event:LoaderEvent):void { //Display the % loaded in textfield preload_bg.visible = true; addChild(preload_bg); addChild(perc_txt); TweenLite.to(preload_bg,0.5,{x:stage.stageWidth, y:stage.stageHeight/2, alpha:1}); TweenLite.to(perc_txt,0.5,{x:stage.stageWidth-148, y:stage.stageHeight/2-33, alpha:1}); perc_txt.text=Math.ceil(event.target.bytesLoaded/event.target.bytesTotal * 100) + "%"; } function completeHandler2(event:LoaderEvent):void { removeChild(perc_txt); removeChild(preload_bg); TweenLite.to(event.target.content, 1, {alpha:1}); var mcTemp:MovieClip = BioLoader.rawContent oldLoader.unload(); removeChild(oldLoader.content); oldLoader=BioLoader; trace(event.target + " is complete!"); trace("La posizione di BioLoader è: " + getChildIndex(BioLoader.content)); } } How can I do to make all entries correctly? please help me, there are days that I'm puzzling: D
  6. Hello, congratulations for the project and the forum! how can I prevent a swf that loads every time I click on the button? I have a site that loads of SWFLoader via the menu buttons. Unfortunately though I am already in the SWF loaded and I click on the same menu button that loads the SWF, it is loaded again instead of being ignored. How can I do? I tried to set a variable oldLoader and compare it with an if statement: if (oldLoader! = NewLoader) {} but does't work ... Thanks
×
×
  • Create New...