Flash Gallery | Flash Templates | Flash Menu | Flash Design | Flash Audio & Video

flash page flip

Actionscript 3.0 video tutorials

+ Reply to Thread
Results 1 to 4 of 4

Thread: loadMovie...removed !

  1. #1
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,609
    Rep Power
    9

    loadMovie...removed !

    flash templates
    Gone"loadMovie is gone J I thought it was pretty useless.
    With Actionscript 3.0 and Flash CS3, all those who never had the chance to learn about the MovieClipLoader class of Flash 8 will have that chance now, once and for all!
    AS 3.0 implements the Loader class to allow the loading of files out of the main swf.
    In the following example I"ll explain how to use it at its best and you"ll see how simple it is.
    As always, I create an FLA and save it as test_load.fla
    I create a MovieClip and I call it info_mc, inside of which I create the necessary graphics to give it the look of a "Loader", hence with a text field which will show the percentage of loading and a progress bar to do the same.
    I create an AS file and I call it Loading.as saving it in the same folder where the FLA is.
    Loading.as ( by now it"s clear ) is our Document Class, written this way:
    Code:
    package {
    	import flash.display.MovieClip;
    	import flash.display.SimpleButton;
    	import flash.text.TextField;
    	import flash.display.Loader;
    	import flash.events.*;
    	import flash.net.URLRequest;
    
    	public class Loading extends MovieClip 
    	{
    		private var url:String;
    		private var loader:Loader;
    
    		public function Loading() 
    		{
    			stage.frameRate=31;
    			info_mc.visible=false;
    
    			init();
    		}
    		private function init():void 
    		{
    			url='http://www.flepstudio.org/swf/my_swf.swf"cachebuster='
    			+new Date().getTime();
    			var request:URLRequest=new URLRequest(url);
    			loader=new Loader();
    			initListeners(loader.contentLoaderInfo);
    			loader.load(request);
    		}
    		private function initListeners(dispatcher:IEventDispatcher):void 
    		{
    			dispatcher.addEventListener(Event.COMPLETE,completato);
    			dispatcher.addEventListener(IOErrorEvent.IO_ERROR,seErrore);
    			dispatcher.addEventListener(Event.OPEN,inizia);
    			dispatcher.addEventListener(ProgressEvent.PROGRESS,inCaricamento);
    		}
    		private function initButtonListener():void 
    		{
    			ricarica_btn.addEventListener(MouseEvent.CLICK,scarica);
    		}
    		private function inizia(event:Event):void 
    		{
    			removeButtonListener();
    			info_mc.visible=true;
    			debug_txt.text='INIZIO';
    		}
    		private function inCaricamento(event:ProgressEvent):void 
    		{
    			var n:uint=(event.bytesLoaded/event.bytesTotal)*100;
    			info_mc.loading_txt.text='Loading '+n.toString()+' %';
    			var nn:uint=(event.bytesLoaded/event.bytesTotal)*info_mc.border_mc.width;
    			info_mc.fill_mc.width=nn;
    			debug_txt.appendText('.');
    		}
    		private function completato(event:Event):void 
    		{
    			debug_txt.appendText('FINITO');
    			info_mc.visible=false;
    			addChild(loader);
    			loader.x=10;
    			loader.y=10;
    			loader.width=loader.height=200;
    			initButtonListener();
    		}
    
    		private function seErrore(event:IOErrorEvent):void 
    		{
    			trace("ioErrorHandler: "+event);
    		}
    
    		private function scarica(event:MouseEvent):void 
    		{
    			removeChild(loader);
    			removeListeners(loader.contentLoaderInfo);
    			init();
    		}
    		private function removeButtonListener():void
    		{
    			ricarica_btn.removeEventListener(MouseEvent.CLICK,scarica);
    		}
    		private function removeListeners(dispatcher:IEventDispatcher):void 
    		{
    			dispatcher.removeEventListener(Event.COMPLETE,completato);
    			dispatcher.removeEventListener(IOErrorEvent.IO_ERROR,seErrore);
    			dispatcher.removeEventListener(Event.OPEN,inizia);
    			dispatcher.removeEventListener(ProgressEvent.PROGRESS,inCaricamento);
    		}
    	}
    }
    Result:







    Obviously I"ve created the swf to load where I"ve inserted a 1.7MB image to be able to notice all loading stages.
    Source files:
    Attached Files

  2. #2
    Junior Member Settled In Armitag3 is on a distinguished road
    Join Date
    Apr 2008
    Posts
    8
    Rep Power
    0

    Re: loadMovie...removed !

    Flep thanks for the help but I have small education gap with this.
    How can I load more than one mc into my main movie?

    I want to load preload my menu and my content on the site into one swf but with the method above I can only load one at a time. Please help.

  3. #3
    Junior Member Settled In lovely-mk@hotmail.com is on a distinguished road
    Join Date
    Jun 2008
    Posts
    1
    Rep Power
    0

    Re: loadMovie...removed !

    hello, i don't understand anything....you don't explain very well on what you are exactly doing on the tutorial...can you please make them pictures so that I can understand better?

    thank you very much, bye

  4. #4
    Flasher Settled In xInstinct is on a distinguished road xInstinct's Avatar
    Join Date
    Jun 2008
    Posts
    42
    Rep Power
    0

    Re: loadMovie...removed !

    In a different project, when I set loader.width or loader.height to anything, the loaded SWF file disappears... Any Ideas?

+ Reply to Thread

LinkBacks (?)


Similar Threads

  1. loadMovie, url, and xml
    By Zoltan99 in forum Flash English
    Replies: 0
    Last Post: 26-02-10, 11:58
  2. swapDepths removed !
    By Flep in forum Tutorials
    Replies: 2
    Last Post: 07-08-08, 19:24
  3. attachMovie...removed !
    By Flep in forum Tutorials
    Replies: 5
    Last Post: 19-06-08, 19:39
  4. onRelease...removed !
    By Flep in forum Tutorials
    Replies: 2
    Last Post: 20-11-07, 10:15
  5. DuplicateMovieclip...removed!
    By Flep in forum Tutorials
    Replies: 0
    Last Post: 27-09-07, 12:04

Tags for this Thread

Bookmarks

Posting Permissions

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