Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-02-2012, 02:50 PM   #1
JRibeiro
Registered User
 
Join Date: Dec 2011
Posts: 14
Default Removing external *.swf from child

Hello!

I have a main_mc that loads and external xml slideshow on frame 1 via this code:
ActionScript Code:
stop(); import fl.transitions.Tween; import fl.transitions.easing.*; import fl.transitions.TweenEvent; import flash.utils.Timer; import flash.display.*; import flash.events.*; import flash.net.*; import flash.xml.*; import flash.display.MovieClip; import flash.text.TextField; var my_speed:Number; var my_total:Number; var my_images:XMLList; var my_loaders_array:Array = []; var my_success_counter:Number = 0; var my_playback_counter:Number = 0; var my_slideshow:Sprite = new Sprite(); var my_image_slides:Sprite = new Sprite(); var my_timer:Timer; var my_prev_tween:Tween; var my_tweens_array:Array = []; var my_xml_loader:URLLoader = new URLLoader(); var lbar_txt_mc:TextField; my_xml_loader.load(new URLRequest("slideshow.xml")); my_xml_loader.addEventListener(Event.COMPLETE, processXML); function processXML(e:Event):void {     var my_xml:XML = new XML(e.target.data);     my_speed = my_xml. @ SPEED;     my_images = my_xml.IMAGE;     my_total = my_images.length();     loadImages();     my_xml_loader.removeEventListener(Event.COMPLETE, processXML);     my_xml_loader = null; } function loadImages():void {     for (var i:Number = 0; i < my_total; i++)     {                 var my_url:String = my_images[i]. @ URL;         var my_loader:Loader = new Loader();         my_loader.load(new URLRequest(my_url));  my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);    my_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progresshandler);         my_loaders_array.push(my_loader);         function progresshandler(myevent:ProgressEvent):void         {             var myprogress:Number = myevent.target.bytesLoaded / myevent.target.bytesTotal;             lbar_txt_mc.text = Math.round(myprogress * 100) + "%";         }     } } function onComplete(e:Event):void {     my_success_counter++;     if (my_success_counter == my_total)     {         startShow();     }     var my_loaderInfo:LoaderInfo = LoaderInfo(e.target);     my_loaderInfo.removeEventListener(Event.COMPLETE, onComplete); } function nextImage():void {     var my_image:Loader = Loader(my_loaders_array[my_playback_counter]);     my_image_slides.addChild(my_image);     my_image.x = (0);     my_image.y = (150);     my_image.width = (stage.stageWidth);     my_image.height = (600);     my_tweens_array[0] = new Tween(my_image,"alpha",Strong.easeOut,0,1,1,true); } function startShow():void {     addChild(my_slideshow);     my_slideshow.addChild(my_image_slides);     nextImage();     my_timer = new Timer(my_speed * 1000);     my_timer.addEventListener(TimerEvent.TIMER, timerListener);     my_timer.start(); } function timerListener(e:TimerEvent):void {     hidePrev();     my_playback_counter++;     if (my_playback_counter == my_total)     {         my_playback_counter = 0;     }     nextImage(); } function hidePrev():void {     var my_image:Loader = Loader(my_image_slides.getChildAt(0));     my_prev_tween = new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true);     my_prev_tween.addEventListener(TweenEvent.MOTION_FINISH, onFadeOut); } function onFadeOut(e:TweenEvent):void {     my_image_slides.removeChildAt(0); }


Inside that same main_mc I have another mc with 5 buttons that open a different swf each (code bellow). They are loaded on top of the slideshow and I'm not being able to remove it and reload it when necessary (when CLICK home).

I am trying to make buttons #2,3,4 and 5 to unload any previous loaded SWF in child (myloader) and also the slideshow itself, and I want to set #1 button (home) also to remove all swfs from child and reload the slideshow.

So... any previous content should be removed before loading the new content. In case of button #1, unloads any content and loads XML slideshow.

I red 98734435435 articles regarding "Loader.unloadAndStop()" / "this.removeChild(clip);" and I simply cant make it work!!

What do?


ActionScript Code:
stop(); //Listeners Menu_1 menu_1_btn_1.addEventListener(MouseEvent.MOUSE_OVER, goDrop_1); menu_1_btn_1.addEventListener(MouseEvent.MOUSE_OUT, goUndrop_1); menu_1_btn_1.addEventListener(MouseEvent.CLICK, goHome_1); menu_1_btn_2.addEventListener(MouseEvent.MOUSE_OVER, goDrop_2); menu_1_btn_2.addEventListener(MouseEvent.MOUSE_OUT, goUndrop_2); menu_1_btn_2.addEventListener(MouseEvent.CLICK, goEmenta_2); menu_1_btn_3.addEventListener(MouseEvent.MOUSE_OVER, goDrop_3); menu_1_btn_3.addEventListener(MouseEvent.MOUSE_OUT, goUndrop_3); menu_1_btn_3.addEventListener(MouseEvent.CLICK, goLoc_3); menu_1_btn_4.addEventListener(MouseEvent.MOUSE_OVER, goDrop_4); menu_1_btn_4.addEventListener(MouseEvent.MOUSE_OUT, goUndrop_4); menu_1_btn_4.addEventListener(MouseEvent.CLICK, goEve_4); menu_1_btn_5.addEventListener(MouseEvent.MOUSE_OVER, goDrop_5); menu_1_btn_5.addEventListener(MouseEvent.MOUSE_OUT, goUndrop_5); menu_1_btn_5.addEventListener(MouseEvent.CLICK, goRes_5); // Menu_1 Botão 1; function goDrop_1(myevent:MouseEvent):void {     menu_1_drop_bgd_1.gotoAndPlay(2); } function goUndrop_1(myevent:MouseEvent):void {     menu_1_drop_bgd_1.gotoAndPlay(11); } function goHome_1(myevent:MouseEvent):void {     var myrequest:URLRequest = new URLRequest("home.swf");     var myloader:Loader=new Loader();     myloader.load(myrequest);     stage.addChild(myloader);     myloader.x = 0;     myloader.y = 150;     var xmlHomeData:XML = new XML();     var xmlHomeLoader:URLLoader = new URLLoader();     xmlHomeLoader.addEventListener(Event.COMPLETE, LoadHomeXML);     xmlHomeLoader.load(new URLRequest("home.xml"));     function LoadHomeXML(e:Event):void     {         xmlHomeData = new XML(e.target.data);         ParseBooks(xmlHomeData);     }     function ParseBooks(bookinput:XML):void     {         trace("XML OUTPUTS HOME");         trace("----------------------");         trace(bookinput.titulo);         txt_infofield_1.text = bookinput.titulo;     } } //Menu_1 Botão 2 function goDrop_2(myevent:MouseEvent):void {     menu_1_drop_bgd_2.gotoAndPlay(2); } function goUndrop_2(myevent:MouseEvent):void {     menu_1_drop_bgd_2.gotoAndPlay(11); } function goEmenta_2(myevent:MouseEvent):void {     var myrequest:URLRequest = new URLRequest("ementa.swf");     var myloader:Loader=new Loader();     myloader.unloadAndStop();     myloader.load(myrequest);     stage.addChild(myloader);     myloader.x = 0;     myloader.y = 150;     var xmlHomeData:XML = new XML();     var xmlHomeLoader:URLLoader = new URLLoader();     xmlHomeLoader.addEventListener(Event.COMPLETE, LoadHomeXML);     xmlHomeLoader.load(new URLRequest("ementa.xml"));     function LoadHomeXML(e:Event):void     {         xmlHomeData = new XML(e.target.data);         ParseBooks(xmlHomeData);     }     function ParseBooks(bookinput:XML):void     {         trace("XML OUTPUTS Ementa");         trace("----------------------");         trace(bookinput.titulo);         txt_infofield_1.text = bookinput.titulo;     } } //Menu_1 Botão 3 function goDrop_3(myevent:MouseEvent):void {     menu_1_drop_bgd_3.gotoAndPlay(2); } function goUndrop_3(myevent:MouseEvent):void {     menu_1_drop_bgd_3.gotoAndPlay(11); } function goLoc_3(myevent:MouseEvent):void {     var myrequest:URLRequest = new URLRequest("loc&hor.swf");     var myloader:Loader=new Loader();     myloader.load(myrequest);     stage.addChild(myloader);     myloader.x = 0;     myloader.y = 150;     var xmlHomeData:XML = new XML();     var xmlHomeLoader:URLLoader = new URLLoader();     xmlHomeLoader.addEventListener(Event.COMPLETE, LoadHomeXML);     xmlHomeLoader.load(new URLRequest("localizacaoehorarios.xml"));     function LoadHomeXML(e:Event):void     {         xmlHomeData = new XML(e.target.data);         ParseBooks(xmlHomeData);     }     function ParseBooks(bookinput:XML):void     {         trace("XML OUTPUTS Localização & Horários");         trace("----------------------");         trace(bookinput.titulo);         txt_infofield_1.text = bookinput.titulo;     } } //Menu_1 Botão 4 function goDrop_4(myevent:MouseEvent):void {     menu_1_drop_bgd_4.gotoAndPlay(2); } function goUndrop_4(myevent:MouseEvent):void {     menu_1_drop_bgd_4.gotoAndPlay(11); } function goEve_4(myevent:MouseEvent):void {     var myrequest:URLRequest = new URLRequest("eventos.swf");     var myloader:Loader=new Loader();     myloader.load(myrequest);     stage.addChild(myloader);     myloader.x = 0;     myloader.y = 150;     var xmlHomeData:XML = new XML();     var xmlHomeLoader:URLLoader = new URLLoader();     xmlHomeLoader.addEventListener(Event.COMPLETE, LoadHomeXML);     xmlHomeLoader.load(new URLRequest("eventos.xml"));     function LoadHomeXML(e:Event):void     {         xmlHomeData = new XML(e.target.data);         ParseBooks(xmlHomeData);     }     function ParseBooks(bookinput:XML):void     {         trace("XML OUTPUTS Eventos");         trace("----------------------");         trace(bookinput.titulo);         txt_infofield_1.text = bookinput.titulo;     } } //Menu_1 Botão 5 function goDrop_5(myevent:MouseEvent):void {     menu_1_drop_bgd_5.gotoAndPlay(2); } function goUndrop_5(myevent:MouseEvent):void {     menu_1_drop_bgd_5.gotoAndPlay(11); } function goRes_5(myevent:MouseEvent):void {     var myrequest:URLRequest = new URLRequest("reservas.swf");     var myloader:Loader=new Loader();     myloader.load(myrequest);     stage.addChild(myloader);     myloader.x = 0;     myloader.y = 150;     var xmlHomeData:XML = new XML();     var xmlHomeLoader:URLLoader = new URLLoader();     xmlHomeLoader.addEventListener(Event.COMPLETE, LoadHomeXML);     xmlHomeLoader.load(new URLRequest("reservas.xml"));     function LoadHomeXML(e:Event):void     {         xmlHomeData = new XML(e.target.data);         ParseBooks(xmlHomeData);     }     function ParseBooks(bookinput:XML):void     {         trace("XML OUTPUTS Reservas");         trace("----------------------");         trace(bookinput.titulo);         txt_infofield_1.text = bookinput.titulo;     } } }

Will much appreciate any help or suggestion
Thx in advance!
JRibeiro is offline   Reply With Quote
Old 01-02-2012, 07:27 PM   #2
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,397
Default

Add the swf files to a Sprite on the stage.
When a button is clicked, use a while loop to clear the contents of the Sprite, before adding new content.
ActionScript Code:
function removeContent():void {     while (sprite.numChildren > 0)     {         sprite.removeChildAt(0);     } }

In order for a button within a child swf to remove its own parent or siblings, you should dispatch a custom event to the main timeline and handle the removal from there.

child swf
ActionScript Code:
btn1.addEventListener(MouseEvent.CLICK, onClick); function onClick(e:MouseEvent):void {     dispatchEvent(new Event("remove content", true)); }

main timeline
ActionScript Code:
addEventListener("remove content", removeContent); function removeContent(e:Event=null):void {     while (sprite.numChildren > 0)     {         sprite.removeChildAt(0);     } }

BTW, you can set this up to require only a single click event handler to serve all of the buttons.
ie: you don't need multiple copies of essentially the same click function.
[afz]snickelfitz is offline   Reply With Quote
Old 01-03-2012, 09:53 AM   #3
JRibeiro
Registered User
 
Join Date: Dec 2011
Posts: 14
Default

Thanks for the push snickelfitz, it did help allot!

I successfully removed the slideshow and I'm now adapting the rest of the code so that every button clears the recently added sprite before it triggers myloader.load(myrequest);.
For now I only manage to unload the slideshow, but I guess the rest will come along eventually. I'll be looking into this for the next few days, I still have a long way to go till all works as I want to... F.Ex, I don't know how 1 listener can monitor all the buttons at the same time. I am aware that I have a ton of listeners, and at the time I created them it did seemed redundant... In the slideshow I managed to kill some of those listeners when I don't need them any more. Still, I'm saving the "clean the house" part to the end. All I want for now is to get this thing running and polish on a later stage.

Once again thanks for the help, I'll keep monitoring this thread and will feedback!
JRibeiro is offline   Reply With Quote
Old 01-05-2012, 10:37 AM   #4
JRibeiro
Registered User
 
Join Date: Dec 2011
Posts: 14
Default

Here's a fresh update:

I have all my AS on frame 1.
I got this loader definition:

ActionScript Code:
var _swfLoader:Loader; var _swfContent:MovieClip; function loadSWF(path:String):void {     var _req:URLRequest = new URLRequest();     _req.url = path;     _swfLoader = new Loader();     setupListeners(_swfLoader.contentLoaderInfo);     _swfLoader.load(_req); } function setupListeners(dispatcher:IEventDispatcher):void {     dispatcher.addEventListener(Event.COMPLETE, addSWF);     dispatcher.addEventListener(ProgressEvent.PROGRESS, preloadSWF); } function preloadSWF(event:ProgressEvent):void {     var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;     swfPreloader.percentTF.text = _perc + "%"; } function addSWF(event:Event):void {     event.target.removeEventListener(Event.COMPLETE, addSWF);     event.target.removeEventListener(ProgressEvent.PROGRESS, preloadSWF);     _swfContent = event.target.content;     _swfContent.addEventListener("close", unloadSWF);     addChild(_swfContent); } function unloadSWF(event:Event):void {     _swfLoader.unloadAndStop();     removeChild(_swfContent);     _swfContent = null; }

And then I have these 2 buttons that, on CLICK, should unload previous swf and load a new one:
ActionScript Code:
function goEmenta_2(myevent:MouseEvent):void {     while (_swfContent.numChildren > 0)     {         _swfContent.removeChildAt(0);     }     loadSWF("ementa.swf"); } function goLoc_3(myevent:MouseEvent):void {     while (_swfContent.numChildren > 0)     {         _swfContent.removeChildAt(0);     }     loadSWF("loc&hor.swf"); }

I cant make this work! It keeps giving me error #1009 cannot access a property or method of a null object reference. I understand that I cannot unload a child (_swfContent) that has not been loaded, but if instead of using the while loop I try to call the unloadSWF() function on CLICK, it then outputs Error 1136: Incorrect number of arguments. Expected 1.

Damn I feel dumb!
JRibeiro is offline   Reply With Quote
Old 01-05-2012, 11:18 AM   #5
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,397
Default

You really should only have 1 button CLICK handler.
The value for the swf path should be linked to the button in some way, such as an id number used to access an array of swf paths, or as a custom String property of the button itself.

Generally speaking, I tend to use the button CLICK handler as a means for removing content and updating variables; the loading of new content occurs after this other stuff is finished.

A very common way to handle this is to load an XML file that contains all of the structured site data.
For example, this XML file passes three greensock "SWFLoaders" into the Flash application. These SWFLoaders automatically run when the xml is loaded.
Progress and Complete events are dispatched and are handled within Flash.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<nav>

	<item title="Home">
		<SWFLoader 
		load="true" 
		name="HOME"
		centerRegistration = "true"		
		url="home.swf"/>
	</item>
	
	<item title="Contact Us">
		<SWFLoader 
		load="true" 
		name="CONTACT US"
		centerRegistration = "true"
		url="contact.swf"/>
	</item>
	
	<item title="About Us">
		<SWFLoader 
		load="true" 
		name="ABOUT US"
		centerRegistration = "true"
		url="about.swf"/>
	</item>
	
</nav>
In Flash you just load the XML file and handle the progress and complete events for the xml and for the swf files.
This example uses the greensock loading classes and a site setup I'm experimenting with right now.
Much of the manual coding and cleanup normally associated with loading and unloading files, is handled automatically in the LoaderMax classes.
ActionScript Code:
import com.greensock.*; import com.greensock.easing.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.display.*; import flash.display.Sprite; import flash.display.MovieClip; import flash.events.Event; import flash.display.Shape; import flash.display.Graphics; LoaderMax.activate([ImageLoader, SWFLoader]); /*-----------------------------------------------------------------------------------*/ stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; stage.addEventListener(Event.RESIZE, resizeHandler); var sw:Number = stage.stageWidth; var sh:Number = stage.stageHeight; var swCenter:Number = sw * .5; var shCenter:Number = sh * .5; var appW:Number = 860; var appH:Number = 560; var appX:Number = swCenter - appW * .5; var appY:Number = shCenter - appH * .5; var appBounds:Rectangle = new Rectangle(appX,appY,appW,appH); /*-----------------------------------------------------------------------------------*/ var swfArray:Array = new Array(); var buttonsArray:Array = new Array(); var bar:Shape = new Shape(); drawBar(); var buttons:Sprite = new Sprite(); buttons.x = buttons.y = 0; var pages:Sprite = new Sprite(); pages.x = swCenter; pages.y = shCenter; var pt:PageTitle; var p:Preloader = new Preloader(); p.progressText.text = ""; p.childText.text = ""; p.childP.scaleX = 0; p.x = swCenter; p.y = shCenter; addChild(p); var prevPage:ContentDisplay; var targetPage:ContentDisplay; var pageIndex:int; var titleX:Number; var targetBtn:MovieClip; var prevBtn:MovieClip; var xml:XML; var xmlLoader:XMLLoader = new XMLLoader("data/nav.xml", {     name:"xmlData",     maxConnections:1,     onProgress:appLoading,     onComplete:appLoaded,     onChildProgress:childLoading,     onChildComplete:childLoaded }); xmlLoader.load(true); function childLoading(e:LoaderEvent):void {     p.childP.scaleX = e.target.progress;     p.childText.text = "loading " + e.target.name + " page"; } function appLoading(e:LoaderEvent):void {     var s:int = int(e.target.progress * 100);     p.progressText.text = "progress: " + s.toString() + "%"; } function childLoaded(e:LoaderEvent):void {     var swf:ContentDisplay = e.target.content as ContentDisplay;     swfArray.push(swf); } function appLoaded(e:LoaderEvent):void {     xml = new XML(LoaderMax.getContent("xmlData"));     trace(xml);     p.progressText.text = "";     p.childText.text = "";     TweenMax.to(p.childP, .5, {scaleX:0, ease:Strong.easeIn});     TweenMax.to(p, 1, {alpha:0, onComplete:initApp, onCompleteParams:[swfArray.length]}); } function initApp(n:int):void {     removeChild(p);     var b:MovieClip;     for (var i:int = 0; i < n; i++)     {         b = makeButton(i);         buttonsArray[i] = b;         buttons.addChild(b);     }     pageIndex = 0;     prevPage = ContentDisplay(swfArray[pageIndex]);     targetPage = prevPage;         prevBtn = MovieClip(buttonsArray[pageIndex]);     disable(prevBtn);     pt = new PageTitle();     pt.x = buttons.width;     pt.y = (buttons.y + buttons.height/2) - (pt.height/2);     pt.pageTitleText.text = "> " + String(prevPage.name);     buttons.addChildAt(pt, 0);     titleX = pt.x;     pages.addChild(prevPage);     addChild(pages);     addChild(buttons);     resizeHandler();     TweenMax.from(pages, 1, {alpha:0});     TweenMax.allFrom(buttonsArray, .2, {alpha:0}, .05); } function makeButton(index:int):MovieClip {     var _b:MovieClip = new Btn();     _b.page = ContentDisplay(swfArray[index]);     _b.id = index;     _b.btnLabel.text = String(_b.page.name);     _b.btnLabel.width = _b.btnLabel.textWidth + 40;     _b.btnBase.width = _b.btnLabel.width;     _b.addEventListener(MouseEvent.CLICK, btnClick);     _b.buttonMode = true;     _b.useHandCursor = true;     _b.mouseChildren = false;     _b.x = buttons.width;     _b.y = 0;     return _b; } function btnClick(e:MouseEvent):void {     targetBtn = MovieClip(e.currentTarget);     targetPage = targetBtn.page;         enable(prevBtn);     disable(targetBtn);     pageTransition(); } function disable(mc:MovieClip):void {     mc.mouseEnabled = false;     TweenMax.to(mc.btnLabel, .2, {tint:0x333333});     TweenMax.to(mc.btnBase, .2, {tint:0xFFFFFF}); } function enable(mc:MovieClip):void {     mc.mouseEnabled = true;     TweenMax.to(mc.btnLabel, .2, {removeTint:true});     TweenMax.to(mc.btnBase, .2, {removeTint:true}); } function pageTransition():void {     pt.pageTitleText.text = "> " + String(targetPage.name);     pages.addChild(targetPage);         var dur:Number = .5;     TweenMax.fromTo(pt, dur*3, {alpha:0, x:"-pt.width"},{alpha:1, x:titleX, ease:Expo.easeOut});     TweenMax.from(targetPage, dur*2, {scaleX:0, scaleY:0, ease:Cubic.easeOut});     TweenMax.to(prevPage, dur, {scaleX:0, scaleY:0, ease:Cubic.easeIn, onComplete:removePage}); } function removePage():void {     pages.removeChild(prevPage);     TweenMax.to(prevPage, 0, {scaleX:1, scaleY:1, onComplete:swap}); } function swap():void {     prevPage = targetPage;     prevBtn = targetBtn; } function resizeHandler(e:Event=null):void {     sw = stage.stageWidth;     sh = stage.stageHeight;     swCenter = sw * .5;     shCenter = sh * .5;         var _dur:Number = 1;     TweenMax.to(bar, _dur, {delay:_dur, width:sw});     TweenMax.to(pages, _dur, {delay:_dur, x:swCenter, y:shCenter});     } function drawBar():void {     var g:Graphics = bar.graphics;     g.beginFill(0xFF9900, 1);     g.drawRect(0,0,sw, 30);     g.endFill();     bar.scaleX = 0;     addChild(bar); }

Here's a link to a live demo of this code:
Loading Demo
[afz]snickelfitz is offline   Reply With Quote
Old 01-23-2012, 09:08 AM   #6
JRibeiro
Registered User
 
Join Date: Dec 2011
Posts: 14
Default

Hey snickelfitz.

First of all I want to thank you for your time in helping me. My will and determination to learn AS3 are huge, but my basis are extremely weak.... I had a hard time going trough all that code you posted. I understood only part of it, and I'm one of those guys who needs to understand every single line to figure the whole thing out. That's usually a good thing because it makes me go deeper, but it has the downside of taking too much time to get anywhere.

I have achieved what I intended, but I went in different direction of what you said regarding the CLICK handlers. I know it might not be the best solution, but for now this thing works, and I can justify to my boss why I'm taking 3-4 weeks assembling a site in AS3 when I could do it in 2 days using AS2...

As a future reference, and for those facing the same difficulties, I'll leave the solution I found:
ActionScript Code:
var Xpos:Number = 110; var Ypos:Number = 180; var swf:MovieClip; var loader:Loader = new Loader(); var defaultSWF:URLRequest = new URLRequest("swfs/reservas.swf"); loader.x = Xpos; loader.y = Ypos; addChild(loader); //Btns Universal Function function btnClick(event:MouseEvent):void{     removeChild(loader);     var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");     loader.load(newSWFRequest);     loader.x=Xpos;     loader.y=Ypos;     addChild(loader); } //Btn listners ementa.addEventListener(MouseEvent.CLICK, btnClick); eventos.addEventListener(MouseEvent.CLICK, btnClick); locEhor.addEventListener(MouseEvent.CLICK, btnClick);

For detailed info on this code please copy this info: "Load & Unload Multiple External SWF files Tutorial in Flash ActionScript 3.0 CS3 CS4 CS5.5" and paste it on youtube search (yeah I cant post direct links due to low post numbers). The first result will be the tutorial.

I got this info from that tutorial, and I consider it very accessible for those who are new in AS3 and don't comprehend much about fetching parameters via XML.

The trick here is to use the swf name files to assign instance names on your buttons and load / unload them on the stage (f.ex. if you want to load a movie called "externalMovie.swf" using this code you would name your button "externalMovie").

For now I'm just happy it works... but... I will try to implement the code you gave me in the future. I do want to learn how to do things in a most practical way, namely in what concerns to site updates, and loading the info from a XML has the advantage of easily changing any type of dynamic content of it.
Regardless, considering that 1 month ago I didn't know what an array was, it's been productive

Cheers! Thx again!

Last edited by JRibeiro; 01-23-2012 at 10:36 AM.
JRibeiro is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT. The time now is 11:38 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.