Copy link to clipboard
Copied
Hi,
I've recently made the switch from as2 to as3 and am still struggling to get my head around one aspect in particular. I've managed to load one external swf into a blank file via the script
import LoadDisplayObject;
var loader:LoadDisplayObject = new LoadDisplayObject("button_01.swf", true);
addChild(loader);
function onComplete(evt:Event):void {
trace("loaded complete received");
loader.scaleX = loader.scaleY = .75;
}
.....however I'm struggling with the script to make a swfs load into a space when one of my 3 buttons is clicked....
My page currently has three buttons (button_01, button_02 and button_03) and in a local folder three separate swfs with the same names which I wish to load in, when the appropriate button is pressed.
I have managed to get them to load in using a tutorial...however they load over the top of each over...far from ideal. From research on the internet I've found a range of different script...but I just can’t find anywhere I can find script to make this work..hence why I have turned to here.
Any help much appreciated...thanks in advance.
just call butt1Click(null);
Copy link to clipboard
Copied
you must be using different loaders to load more than one swf at the same time. assign them different x,y properties so they don't overlap:
loader.x=whatever;
loader.y=whatever;
Copy link to clipboard
Copied
Your loader holds the loaded swf. By adding it as a child - addChild(loader) - you place it on the stage at the highest level possible. You could manage depths of added children by calling addChildAt(loader, whateverLevelIndex), but you can never addChild under the objects that are already on the stage in layers, added in Flash Professional IDE. You can position and size loaded content ofcourse, move it away from your buttons (loader.x, loader.y, loader.width, loader.height).
If your loaded content is and should be bigger and thus under the buttons, you should create empty movie clip and position it under the buttons at position [0, 0] and call it let's say myLoaderHolder.Then modify script:
myLoaderHolder.addChild(loader);
Copy link to clipboard
Copied
Thanks a lot for the replys...I"ll give it ago this week and let you know how it goes.
Thanks again.
Copy link to clipboard
Copied
replies*
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
Hi,
Just throught I would let you know that I've manged to get this to work this morning. Changed the script slightly and used a different method of:
var home:MovieClip = this;
function butt1Click(evt:MouseEvent):void {
var ldr:Loader = new Loader();
ldr.load(new URLRequest("button_01.swf"));
ldr.contentLoaderInfo.addEventListener(Event.INIT, loaded);
}
function butt2Click(evt:MouseEvent):void {
var ldr:Loader = new Loader();
ldr.load(new URLRequest("button_02.swf"));
ldr.contentLoaderInfo.addEventListener(Event.INIT, loaded);
}
function butt3Click(evt:MouseEvent):void {
var ldr:Loader = new Loader();
ldr.load(new URLRequest("button_03.swf"));
ldr.contentLoaderInfo.addEventListener(Event.INIT, loaded);
}
function loaded(evt: Event):void {
if(contentClip.numChildren > 0){
contentClip.removeChildAt(0);
}
contentClip.addChild(evt.target.content);
}
button_01.addEventListener(MouseEvent.MOUSE_UP, butt1Click);
button_02.addEventListener(MouseEvent.MOUSE_UP, butt2Click);
button_03.addEventListener(MouseEvent.MOUSE_UP, butt3Click);
seems to work well. Only small question is if I want one page to load automatically upon opening...how do I alter the script to do this??? Thanks
Copy link to clipboard
Copied
just call butt1Click(null);
Copy link to clipboard
Copied
Brilliant. Thankyou
Copy link to clipboard
Copied
You're wellcome.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more