Copy link to clipboard
Copied
I have a wierd problem. everything is ok in Preview Mode but when I Publish the file external swf will not load in main swf.
I didnt change the location of main file and swf file are locally available. SO i have no idea what is the problem.
Is it related to AS3 setting or something ?
Copy link to clipboard
Copied
what are you publishing? web-based, ios, android, air, projector app?
Copy link to clipboard
Copied
"swf" with flash cc
it is not a network project just locally will be used . and "access local files" is chosen..
Copy link to clipboard
Copied
what's the code in the main swf used to load?
what's the location (relative to the main swf) of the loaded swf?
is there any code that would cause the loaded swf to be unloaded or no longer seen?
Copy link to clipboard
Copied
// loading external swf
// We'll store our buttons in an array to make it easier to register for events.
var btns:Array = [
btn_octapus,
btn_shark,
btn_dolphin
]
// Now cycle over them in bind to our listener
for each (var btn:MovieClip in btns) {
btn.addEventListener("mouseUp", btnEvents);
}
function btnEvents(e:MouseEvent):void {
// With one event listener, we can sort out each condition
switch (e.currentTarget.name) {
case "btn_octapus":
loadGame("001.swf")
break;
case "btn_shark":
loadGame("002.swf")
break;
case "btn_dolphin":
loadGame("0013.swf")
break;
}
}
function loadGame(url:String):void {
// Now we only have to write our loader code once (for all buttons)
trace("Loading " + url);
// Because we're unloading our swfs (and unloaded assets get garbage collected),
// we'll want to make a new loader each time we call a load op
var loader:Loader = new Loader();
loader.name = "current_game";
loader.load(new URLRequest(url));
addChild(loader);
loader.x=100;
loader.y=100;
}
I just added external swf to main folder for test..
It works for preview in flash correctly but after Publishing, No external swf will be loaded.
Copy link to clipboard
Copied
that's problematic if you intend to reference any loaders and you failed to answer the 2nd and 3rd questions.
Copy link to clipboard
Copied
2nd Question:In the main folder where the FLA file is.
3rd Question : No
In Preview Mode it works fine but only when I publish the fla I have problem with that...
Copy link to clipboard
Copied
no? then why do you have this comment
// Because we're unloading our swfs (and unloaded assets get garbage collected),
and why are you using different loaders and why are you making them local to loadGame?
unless you have reasons for the above and know what you're doing, change your loadGame code to:
var loader:Loader=new Loader();
addChild(loader);
loader.x=100;
loader.y=100;
function loadGame(url:String):void {
// Now we only have to write our loader code once (for all buttons)
trace("Loading " + url);
loader.load(new URLRequest(url));
}
Copy link to clipboard
Copied
I want to use 1 loader for all external swf. there are 13 swf that i want to load. there is 13 button for every swf.
and I want when one external swf are loaded , others should be unloaded(to reduce memory use and cpu&...)
So whats your suggestion ?
we have 13 btn and 13 swf .
buttons named differently
btn_octapus
btn_shark
....
but swf are in sequence of 001.swf to 0013.swf
Copy link to clipboard
Copied
then use the code i suggested in message 7.
though, if there are open streams (video/sound etc) in a loaded swf, use:
var loader:Loader=new Loader();
addChild(loader);
loader.x=100;
loader.y=100;
function loadGame(url:String):void {
if(loader.content){
loader.unloadAndStop();
}
loader.load(new URLRequest(url));
}
Copy link to clipboard
Copied
thank you.
but still I have Problem with the external swf...
By the way , Is there any protected swf ?
you know , I create slideshow with program named "UltraSlideshow" and I can not load them.Can it be the problem or not ?
Copy link to clipboard
Copied
what swf is failing to load?
Copy link to clipboard
Copied
swfs that I created as an slide show ... they are not loading in main SWF. but in preview mode they load but not in Published. .
Copy link to clipboard
Copied
what are the problematic swf names?
Copy link to clipboard
Copied
001.swf
002.swf
0013.swf
Copy link to clipboard
Copied
what's the url to your main swf's embedding html?
Copy link to clipboard
Copied
it is a local project and I need to make a .exe or at least swf. not html version...