Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

loadMovie...removed !

This is a discussion on loadMovie...removed ! within the Tutorials forums, part of the Flash English category; Gone"loadMovie is gone J I thought it was pretty useless. With Actionscript 3.0 and Flash CS3, all those ...


Go Back   Forum Flash CS3 Flash CS4 > Flash CS3 Flash CS4 > Flash English > Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 12-10-07, 17:05
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
loadMovie...removed !

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
File Type: zip CaricareSWFesterno.zip (3.44 MB, 159 views)

__________________

 


I recommend: Essential Actionscript 3.0

- I do not reply technicians pvt messages. Open a thread !
- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !

Last edited by Flep; 28-08-08 at 06:27..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 22-04-08, 11:00
Junior Member
 
Join Date: Apr 2008
Posts: 1
Rep Power: 0
Armitag3 is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 20-06-08, 16:51
Junior Member
 
Join Date: Jun 2008
Posts: 1
Rep Power: 0
lovely-mk@hotmail.com is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-07-08, 22:40
xInstinct's Avatar
Flasher
 
Join Date: Jun 2008
Location: Texas
Posts: 42
Rep Power: 0
xInstinct is on a distinguished road
Send a message via AIM to xInstinct
Re: loadMovie...removed !

In a different project, when I set loader.width or loader.height to anything, the loaded SWF file disappears... Any Ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
swapDepths removed ! Flep Tutorials 2 07-08-08 20:24
attachMovie...removed ! Flep Tutorials 5 19-06-08 20:39
swf sterni loadmovie as3 gianlucafg Actionscript 3.0 base 1 14-05-08 12:40
onRelease...removed ! Flep Tutorials 2 20-11-07 11:15
DuplicateMovieclip...removed! Flep Tutorials 0 27-09-07 13:04


All times are GMT. The time now is 19:13.

Powered by vBulletin version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap