addchild from externally loaded swf in Air project - actionscript-3

I am working on an Air app for iOS and looking for a way to load an external swf and then add/remove the movieclips in that library to the main stage.
Normally, I can use an addchild routine in the document class of the external swf which I can access from the main document class. But since document classes in externally loaded swfs are not allowed in Air deployment, I can't use this method.
Each external swf will contain up to 10 separate movieclips and there are over 25 external swf's I want to load in/remove from the main stage, all containing unique artwork/animation.
Can anyone please suggest a way to do this?
THANKS!
matt

I had same problem i also had around 10 different external swfs with code. So the easiest way for me was to compile every file to swc and included them after in project.

Related

Main menu on game

I have created a menu for my game with buttons and whatnot as a separate .fla file named Menu. My actual game is another .fla file called Game.fla. I was wondering what the best way would be of loading this menu before the game plays?
Thanks.
I would suggest that you create a .swc with your Menu.fla, and then just add that .swc to your Game.fla
If you are using CS6, make sure that you are setting linkage for any MovieClips you want to create instances of in your code.
In the actionscript settings on the library path tab, you can add a .swc that will be included into your .swf when compiling.
In your code, you can now create an instance and add to the display list :
// Assuming MainMenu was a movieclip with linkage set in your .swc
var mainMenu:MainMenu = new MainMenu;
addChild(mainMenu);
I should note that this does not load the .swc at runtime, it includes the .swc to your .swf at compile time. I would recommend this method over loading a .swf in most cases. Cases where I might not, is if there was a large amount of content that wasn't needed all at once. That would allow you to minimize the amount of memory you were using and reduce the .swf size of your main .swf so it loads quicker.
Anytime you are loading .swf's in at runtime you are adding another layer of complexity, so I'd not recommend it unless you do have a good reason to do so. From what you have described, this doesn't sound like a situation where I'd load an external .swf at runtime.
Load the swf output from Menu.fla and keep a check on the progressEvent from loader. Don't show the game screen until Menu.swf is completely loaded and initialized.
Some more details wrt comment from OP:
You can you http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html#load%28%29 to load external swfs. init Event would mark that the swf's actionscript has started executing. OTOH, complete event would tell that all the swf bytes have been loaded.

FLASH : get inputtext value in AS2 SWF that running/load from AS3 swf

I made an e learning app in flash and I use AS3 in this elearning, in this app, I call / load a eksternal swf what I make with AS2.
in that external swf, I have an input text for user, and when submit button clicked, I get the value of the input text and parse it to a global variable and then show it to a certificate.
Its working if I run the as2 swf independently, but if I load that as2 swf from the as3 swf, I can't getting value from the inputtext. its say undefined variable.
can anyone help / explain about my problem ?
thanks befor, sorry for my grammr. :)
AVM1 and AVM2 are incompatible this way. Therefore if you need to communicate between both, you have to use LocalConnection. This is the only option to establish communication between ActionScript 2 and ActionScript 3 movies.

How to debug/step through external/loaded swf - FlashProfessional?

(Flash Professional / AS3)
I have a main fla file that loads a game (with a Loader) and adds it to the stage (addChild(myLoader)). Is there a way to step through/debug the loaded swf? If so, how? My game.swf breakpoints aren't hitting.
Did you debug (Control > Debug Movie) both files?
You need to debug both Main and Game to be able to get breakpoints in the loaded SWF to work. When you Debug a SWF, extra information is added to the file. If you just publish the file there will not be any debug info.
You could try using MonsterDebugger.

AS3: How to dynamically load movieclip from library without exporting in frame 1?

I have some fairly large movieclips in the library which need to be dynamically loaded at runtime. I don't want to export them all in frame 1, because that would slow down initial loading of the movie.
I tried putting an instance of each of these clips later in the timeline where they wouldn't normally be encountered. When I then tried to load one from the library dynamically, I was able to successfully get an instance of the movieclip, but its currentFrame property was 0 and I couldn't see anything on the stage. As soon as I enabled "Export in frame 1", it worked properly.
Does this old trick of putting an instance on the timeline somewhere no longer work in AS3?
I have had similar issues with large library assets and to solve my issue I would always just put the assets into separate swf's and load the external swf file when I needed it.
Check out the Loader class 'content' property - http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html#content
The only downfall to this is managing the assets in separate files.
I hope this helps.

Can an actionScript2 app be used inside a AS3 app?

I've inherited an AS2 app that has a lot of functionality. I need to embed this thing somehow in my AS3 app so I can execute function calls etc and basically control it. Has anyone ever tried something like this? I'm assuming I'll have to URLLoader the AS2 SWF into a MovieClip and take it from there.
AS3 SWF (AVM2 movie) can load AS2 movies (AVM1 movie) using the Loader class, but cannot access the methods/properties of it. The loaded AS2 movie will be of type AVM1Movie (and not MovieClip).
Livedocs page about AVM1Movie
The two movies can communicate with each other using the LocalConnection class. See sending data from avm2 to avm1
Grant Skinner has a very useful pair of classes that simplify AS3<->AS2 communications over LocalConnection. We've used it to great success.
http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html