Loading different swf in the same container

Publishing Print2Flash Documents embedding them in Flash movies
calbertazzi
Posts:6
Joined:Wed Oct 06, 2010 3:03 am
Loading different swf in the same container

Post by calbertazzi » Wed Jul 13, 2011 3:44 am

Hi everyone! I'm a novice with AS3 and I've a problem with some buttons.
The first button (btn1) loads an external swf clip (SWF1.swf - not made with Print2Flash) and the second one (btnA) load another clip made with Print2Flash (SWFA.swf).
I need to put all clips in the same container because I need that, when I press one button (eg. btn1), the swf loaded with the other one (SWFA.swf) is removed and only SWF1.swf is displayed.
Hope to be clear enough.
I tried this way:
First I set up a container and load an empty swf:

Code: Select all

var box:MovieClip = new MovieClip();
addChild (box);
box.x = 0;
box.y = 0;

var myLoader:Loader = new Loader();
var myURL:URLRequest = new URLRequest("emtpy.swf");
myLoader.load(myURL);
box.addChild(myLoader);
then setup the button (btn1) for the SWF1 clip:

Code: Select all

btn1.addEventListener(MouseEvent.CLICK, btn1Clicked);
 
function btn1Clicked(event:MouseEvent):void
{
var myURL:URLRequest = new URLRequest("SWF1.swf");
myLoader.load(myURL);
}
The code for the btnA button is:

Code: Select all

btnA.addEventListener(MouseEvent.CLICK, sds_ClickEvent);
	function sds_ClickEvent(event:Event) {
		import Print2Flash.*;
		stage.scaleMode=StageScaleMode.NO_SCALE;
		stage.align=StageAlign.TOP_LEFT;
		var P2FDoc3:Print2FlashDoc3=new Print2FlashDoc3("SWFA.swf",0,0,600,500, this);
	}
Pressing buttons the different SWF clips display well but the clip made with Print2Flash (SWFA.swf) is not uloaded and remains visible.

Any help? Thanks in advance.

Post Reply