Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

website loading external swfs

This is a discussion on website loading external swfs within the Actionscript 3.0 newbies forums, part of the Flash CS3 eng category; Okay, I'm learning your example, and have a problem. In your example, you have a first button that loads ...


Go Back   Forum Flash CS3 Flash CS4 > English Forums > Flash CS3 eng > Actionscript 3.0 newbies

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 15-10-07, 22:46
Member
 
Join Date: Jul 2007
Posts: 33
Rep Power: 0
jimbo is on a distinguished road
website loading external swfs

Okay, I'm learning your example, and have a problem. In your example, you have a first button that loads the home page - I tried to remove all references to this, and have the home page load from the init function, but have failed - carciaHome gives me:
Cannot access a property or method of a null object reference.

I am still struggling to understand what is happening . . . is it necessary to have the opening button for this kind of site to work? Can the main.swf become the home page, or load the home page without any button push?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 15-10-07, 23:01
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,486
Rep Power: 6
Flep is on a distinguished road
Re: website loading external swfs

It's simple,
into init() function comment the line:
Code:
//aggiungiListenerEntra();
and add:
Code:
entra();
also, comment the function
Code:
/*private function aggiungiListenerEntra():void
{
	logo_mc.entra_mc.buttonMode=true;
	logo_mc.entra_mc.addEventListener(MouseEvent.MOUSE_DOWN,entra);
}*/
last, the entra() function becomes:
Code:
private function entra():void
{
	//this.gotoAndStop(2);
	caricaHome();
}
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 15-10-07, 23:07
Member
 
Join Date: Jul 2007
Posts: 33
Rep Power: 0
jimbo is on a distinguished road
Re: website loading external swfs

Okay,
I tried almost that - I commented out what you said, plus the entra fuction - then put the entra statements in the init function, and it didn't work.

Now, I did as you say, and the compiler tells me that entra(); needs 1 argument?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 15-10-07, 23:10
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,486
Rep Power: 6
Flep is on a distinguished road
Re: website loading external swfs

Yes, you must delete the argument.
Watch the new entra() i wrote:
Code:
private function entra():void
{
	//this.gotoAndStop(2);
	caricaHome();
}
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 15-10-07, 23:14
Member
 
Join Date: Jul 2007
Posts: 33
Rep Power: 0
jimbo is on a distinguished road
Re: website loading external swfs

Ahhh, my bad. I did not notice that you removed the mouse event from entra(); - my old eyes are not working too good :)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Flash Multi Gallery
  #6 (permalink)  
Old 15-10-07, 23:17
Member
 
Join Date: Jul 2007
Posts: 33
Rep Power: 0
jimbo is on a distinguished road
Re: website loading external swfs

hmmm, now I get the similar error as when I removed all entra references and moved caricaHome(); up to init function:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/::caricaHome()
at Main/::entra()
at Main/::init()
at Main$iinit()
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #7 (permalink)  
Old 15-10-07, 23:21
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,486
Rep Power: 6
Flep is on a distinguished road
Re: website loading external swfs

Sorry dude, or us mediterranean people it's too late i'm going to sleep.

Here is the entire class i've modified:
Code:
/*
 ********************************
 * http://www.FlepStudio.org    *
 * @ Author: Filippo Lughi      *
 ********************************
 */
package
{
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.display.Loader;
	import flash.net.URLRequest;
	import flash.events.*;
	
	public class Main extends MovieClip
	{
		private var sezioni_array:Array;
		private var bottoni_sezioni_array:Array;
		
		private var loader:Loader;
		
		private var swf:String;
		
		private var id:int=0;
		
		public function Main()
		{
			init();
		}
		
		private function init():void
		{
			stop();
			stage.frameRate=31;
			
			home_btn.visible=false;
			menu_mc.visible=false;
			preloader_mc.visible=false;
			preloader_mc.fill_mc.width=0;
			
			sezioni_array=new Array('sezioni/home.swf',
			'sezioni/sezione1.swf',
			'sezioni/sezione2.swf',
			'sezioni/sezione3.swf',
			'sezioni/sezione4.swf',
			'sezioni/sezione5.swf');
			bottoni_sezioni_array=new Array(menu_mc.sezione_1_mc,menu_mc.sezione_2_mc,
			menu_mc.sezione_3_mc,menu_mc.sezione_4_mc,
			menu_mc.sezione_5_mc);
			
			//aggiungiListenerEntra();
			aggiungiListenerTornaHome();
			aggiungiListenerMenu();
			entra();
		}
		
		/*private function aggiungiListenerEntra():void
		{
			logo_mc.entra_mc.buttonMode=true;
			logo_mc.entra_mc.addEventListener(MouseEvent.MOUSE_DOWN,entra);
		}*/
		
		private function aggiungiListenerTornaHome():void
		{
			home_btn.addEventListener(MouseEvent.MOUSE_DOWN,tornaHome);
		}
		
		private function aggiungiListenerMenu():void
		{
			for(var i:int=0;i < bottoni_sezioni_array.length;i++)
			{
				bottoni_sezioni_array[i].id=i;
				bottoni_sezioni_array[i].addEventListener(MouseEvent.MOUSE_DOWN,moveNestedClip);
			}
		}
		
		private function entra():void
		{
			//this.gotoAndStop(2);
			caricaHome();
		}
		
		private function tornaHome(m:MouseEvent):void
		{
			id=0;
			loader.unload();
			removeChild(loader);
			rimuoviListeners(loader.contentLoaderInfo);
			caricaHome();
		}
		
		private function caricaHome():void
		{
			swf=sezioni_array[0];
			var request:URLRequest=new URLRequest(swf);
			loader=new Loader();
			initListeners(loader.contentLoaderInfo);
			loader.load(request);
			id=0;
		}
		
		private function moveNestedClip(m:MouseEvent):void
		{
			var loadedSWF:MovieClip=loader.content as MovieClip;
			var nested_clip:MovieClip=loadedSWF.benvenuti_mc as MovieClip;
			nested_clip.gotoAndPlay(32);
			nested_clip.addEventListener(Event.ENTER_FRAME,moveMyTimeLine);
			function moveMyTimeLine(evt:Event):void
			{
				if(evt.currentTarget.currentFrame==62)
				{
					evt.currentTarget.stop();
					evt.currentTarget.removeEventListener(Event.ENTER_FRAME,moveMyTimeLine);
					cambiaSezione(m);
				}
			}
		}
		
		private function cambiaSezione(m:MouseEvent):void
		{
			id=m.target.parent.id+1;
			loader.unload();
			removeChild(loader);
			rimuoviListeners(loader.contentLoaderInfo);
			caricaSezione(m.target.parent.id+1);
		}
		
		private function caricaSezione(n:int):void
		{
			swf=sezioni_array[id];
			var request:URLRequest=new URLRequest(swf);
			loader=new Loader();
			initListeners(loader.contentLoaderInfo);
			loader.load(request);
		}
		
		private function initListeners(dispatcher:IEventDispatcher):void 
		{
			dispatcher.addEventListener(Event.OPEN,inizia);
			dispatcher.addEventListener(ProgressEvent.PROGRESS,inCaricamento);
			dispatcher.addEventListener(Event.COMPLETE,completato);
		}
		
		private function rimuoviListeners(dispatcher:IEventDispatcher):void 
		{
			dispatcher.removeEventListener(Event.OPEN,inizia);
			dispatcher.removeEventListener(ProgressEvent.PROGRESS,inCaricamento);
			dispatcher.removeEventListener(Event.COMPLETE,completato);
		}
		
		private function inizia(event:Event):void 
		{
			menu_mc.visible=false;
			preloader_mc.visible=true;
		}
		private function inCaricamento(event:ProgressEvent):void 
		{
			var n:uint=(event.bytesLoaded/event.bytesTotal)*100;
			preloader_mc.fill_mc.width=n;
		}
		private function completato(event:Event):void 
		{
			addChild(loader);
			swappa();
			preloader_mc.visible=false;
			if(id!=0)
				home_btn.visible=true;
			else
				home_btn.visible=false;
			menu_mc.visible=true;
		}
		
		private function swappa():void
		{
			swapChildren(loader,menu_mc);
			swapChildren(home_btn,loader);
		}
	}
}
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #8 (permalink)  
Old 15-10-07, 23:25
Member
 
Join Date: Jul 2007
Posts: 33
Rep Power: 0
jimbo is on a distinguished road
Re: website loading external swfs

Your version works, I will study what I did wrong. I am sorry to keep you awake. Sweet dreams.
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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Actionscript 3 loading external swf, help please scorptique advanced Actionscript 3.0 1 15-10-08 05:25
Actionscript 3 Loading mulitple external .swf files mrentschler Actionscript 3.0 newbies 1 09-10-08 22:24
Problem with loading external swf madmad Actionscript 3.0 newbies 2 28-05-08 21:36
Simple:Loading external SWF mabron Actionscript 3.0 newbies 1 14-05-08 23:02
Loading external XML files with Flash CS3 Flep Tutorials 14 19-11-07 15:23


All times are GMT. The time now is 22:50.


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


FlepStudio
by Filippo Lughi
P.IVA 03605860406