View Full Version : External SWF
Watsup everyone.. I got a big problem right now. I'm making this interface for my final project in school and its due in 12 hours.
I'm loading external swf's when you click the buttons in the interface. The problem is that I click the first button and the swf loads good, but when I click the next button the first swf is still on the stage while the second one is playing. I tried add/removeChild and thats not working. If anyone could help me out soon that would be Awesome!
sgartner
03-20-2008, 06:37 AM
Watsup everyone.. I got a big problem right now. I'm making this interface for my final project in school and its due in 12 hours.
I'm loading external swf's when you click the buttons in the interface. The problem is that I click the first button and the swf loads good, but when I click the next button the first swf is still on the stage while the second one is playing. I tried add/removeChild and thats not working. If anyone could help me out soon that would be Awesome!
Faet,
It certainly sounds like you are doing the right thing. Removing the loaded SWF from the display list should cause it to no longer be shown. I would suggest that either you are not removing the child that you think you are, or you are not hitting the removeChild code. I assume you are trace()ing to prove that you are removing the children you think you are?
amarghosh
03-20-2008, 06:57 AM
u mind posting some code?
Well I'm not tracing, but heres an example of my code:
var loadit = new Loader();//puzzle_game.swf
var loadit2 = new Loader();//educational_game.swf
//Button 1
function puzzleFunc(myEvent:MouseEvent):void
{
addChild(loadit2);
removeChild(loadit2);
addChild(loadit);
loadit.load(new URLRequest("puzzle_good.swf"));
loadit.x = 130;
loadit.y = 140;
loadit.scaleX = 0.8;
loadit.scaleY = 0.8;
}
btn_1.addEventListener(MouseEvent.CLICK,puzzleFunc );
and the other button looks the same but the loadit's are flipped.
Never mind guys I just add and removed in order and it suddenly works.
function puzzleFunc(myEvent:MouseEvent):void
{
gotoAndPlay(2);
addChild(loadit2);
removeChild(loadit2);
addChild(loadit3);
removeChild(loadit3);
addChild(loadit4);
removeChild(loadit4);
addChild(loadit);
sound.load(new URLRequest("sound1.swf"));
loadit.load(new URLRequest("puzzle_good.swf"));
loadit.x = 130;
loadit.y = 140;
loadit.scaleX = 0.8;
loadit.scaleY = 0.8;
}
Sorry everyone.. I do have another question though if anyone is interested.
amarghosh
03-20-2008, 07:24 AM
function puzzleFunc(myEvent:MouseEvent):void
{
if(contains(loadit2))
removeChild(loadit2);
loadit.contentLoaderinfo.addEventListener(Event.CO MPLETE, function(e:Event):void
{
addChild(loadit);
loadit.contentLoaderinfo.removeEventListener(Event .COMPLETE, arguments.callee);
});
loadit.load(new URLRequest("puzzle_good.swf"));
loadit.x = 130;
loadit.y = 140;
loadit.scaleX = 0.8;
loadit.scaleY = 0.8;
}
btn_1.addEventListener(MouseEvent.CLICK,puzzleFunc );
That works pretty good too, thanks alot.
Can I load an external swf into a MovieClip so I can place it exactly where I want?
amarghosh
03-20-2008, 07:34 AM
yeah, and i think u r doing that right now with loader.x and loader.y properties
Yea but it would just make it so much easier if I could load it into something. Because when its loaded my interface document is 700x450 but my games are 550x400 so you can see everything thats off stage thats not supposed to be shown.
amarghosh
03-20-2008, 08:00 AM
either u can scale up ur games once they r loaded or set the visible property of unwanted stuff to false
hi.. just mask the loaded swf..
var myMask:Sprite = new Sprite();
myMask.graphics.beginFill(0x000000);
myMask.drawRect(0,0,550,400);
myMask.graphics.endFill();
myLoader.mask = myMask
amarghosh
03-20-2008, 10:24 AM
mask --- its a nice thing. i didn't know that. thanks a lot jaga :)
A note about masks, cuz its annoying.. add it to the display list, and it moves with the movieclip it is masking. If you don't, it still works, but its topleft is at 0,0 of the movieclip it is masking's parent
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.