Adding an as2 swf to the stage in an as3 swf - actionscript-3

I have a menu control (as2), that is completely self-contained and doesn't rely on any interaction with the parent (as3). The menu control does load an external xml file that is in the same directory as the swf.
The menu control works fine when I run it on its own. But when I import it into the Library of my as3 fla, add it the stage and run it, it just sits and does nothing.
I can see the images that are part of the control, which leads me to believe it can't load the xml, but I'm not sure.
Does anyone have any ideas about:
Loading an as2 swf into and as3 swf where they don't need to interact
Loading an external file into an swf inside of another swf

Have you tried with flash.net.Loader or if you are going for a Flex app: SWFLoader?

Related

Adobe Flash CS6 gives me an error when importing image sequence to timeline

It will import the first 10 images but anything after that just won't work and the workspace turns completely blank and I need to restart Flash CS6.
How ever if I import the images in a new project, nothing wrong happens. I tried to export it as a swf and import that to the original swf file but it didn't work. It just imported the images that I was able to import earlier.
Is there any solution with AS3 where I can load another swf and close the current one opened? Or any other solution to importing the images.
Thanks!
but anything after that just won't work and the workspace turns completely blank and I need to restart Flash CS6
I assume you export big images, so you have out of memory in your development environment.
Do you need Image Gallery? It isn't hard to create simple image gallery, and of course you don't need to import images to the library and publish with application.
So I found out how to load a swf file, but how would I unload it/get rid of it?
If you decided to wrap your images in swf. By referencing Loader that you have used for loading swf, you could unload child SWF — Loader.unloadAndStop

Single-swf preloader wrapper in Flash

I have a .swf that I'd like to create a preloader for. In the end, I want a single file which combines both the preloader and the content .swf.
Every tutorial I can find on Flash preloaders offers one of two options:
Using a URLRequest in the preloader wrapper to load an external content .swf. This will not work because I do not want two .swfs.
A "single-swf" solution like this one which works for assets which you have created in the Flash IDE. I assumed I would easily be able to go this route, but I'm having trouble. I cannot use the Flash IDE to import my content .swf. I can use an embed tag like so:
[Embed(source="content.swf")]
private var MyContent:Class;
But it seems like this embedded content is exported on the first frame, so my preloader only appears after the content .swf is loaded. I'm guessing it's something along these lines. Any thoughts?
But it seems like this embedded content is exported on the first frame
You are absolutely correct, all Ebmed do embedding in the first frame by default but mxmlc provides solution by creating two frames swf with preloader in the first frame via the metatag:
[Frame(factoryClass="Preloader")]
You can find step by step guide here http://www.bit-101.com/blog/?p=946.

Load Flex4 application in Flash as3

I have created a plugin-enabled flash which reads a configuration file and loads several other flash files. All the files have been created by Adobe Flash CS5 . Recently i had to create a flex application which i want to load on stage of the main flash.
this.addChild(this.movieLoader);
this.movieLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, LoadedM);
this.movieLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
this.movieLoader.load(new URLRequest(fmovie));
The LoadedM(..) is triggered every time and the loaded flash is placed into stage and positioned in LoadedM(..) .
When i load a FlashCS5 created swf, the loader.content is of type [object MainTimeline] while when i load the Flex4 application the loader.content is of type [object _Main_mx_managers_SystemManager]
My problem is that the flex application is not visible on stage nor the initialized/created events of the flex app are triggered even thow debug shows full load of the file.
I have already tried this solution but didnt do any good. i've checked the Event.INIT event of the loaded instead of Event.INIT and it's being triggered. But the anthropod debugged doest not report the the initialization of the flex app take place.
What am i missing?
Thanks in advance
You can read more about the problem at http://old.troygilbert.com/2009/05/loading-flex-based-swfs-in-as3-only-swfs/
If the above does not work, make sure that you are publishing your swf for flashplayer 10.2+

How to constrain loaded swf?

I load swf files continuously, but if one of the swfs has some defective code such as Mouse.hide() the mouse disappears when the swf is loaded. I want to constrain such malicious code in loaded swfs.
There is also another problem related to containing loaded or loading swfs. When I load a swf which loads another swf to operate, It never completes loading (Event.Complete of contentLoaderInfo) because it needs another swf to load. However, the swf should be loaded before it runs. Since loaded swf is as-2, loader does not give any error. I am also suspicious whether or not it will give error if it is as-3.
Check the LoaderMax classes from greensock.com . This should help solve the problem of swf loading other swf before running, since you can listen to the overall loading progress and react accordingly.

Adding an intro to a swf without access to the fla OR: differences between top-level and loaded swfs

I've got to (quickly!) add an intro to an existing flash masthead on a site that I've inherited. I don't have access to the source .fla's, so I approached the problem by putting the intro in a wrapper swf and loading the current masthead and adding it to the display list on Event.INIT. So far, so good. (Incidentally, the swfs are built for flash player 9 and use AS3.)
The problem I'm having is that although the intro plays fine and loads / displays the beginning of the masthead swf, which is a loading animation, the masthead itself never actually plays. Essentially, my question is: what would cause an actionscript 3-based swf to behave differently when it's the child of another swf as opposed to at the top level of the embedded swf?
Potentially important details: Embedding is being handled with swfobject, and no flashvars are being passed in. There are two params, which are base: "/flash/" and wmode: "opaque". All the swfs and flash data live in /flash/. The flash elements (minus the intro I built) were constructed using the Inky flash framework, with which I'm not familiar.
UPDATE: I've reconsidered my approach to the problem and gotten it working by using ExternalInterface; I'm having the intro swf call a js function when it finishes playing, which swaps out the intro swf and replaces it with the current masthead (the approach is outlined here). I'd still like to know why I was witnessing the behavior I was seeing earlier, though, so any ideas and suggestions would be welcome.
There could be a couple of potential problems with your flash files.
If your swf was compiled in AS2, it could be referencing _root which would be messed up when it is loaded into another swf. In AS2, you can get around it by using _lockroot. In AS3, this is not longer a problem because _lockroot is inheritted.
If your movie was a timeline based movie, you can try to invoke the play() function.
If your intro loads external assets, you will want to make sure your paths are set correctly for all your external assets. Try to put the swf file of your container and the intro in to the same directory. Or troubleshoot by using the Safari Activity window to see if you have any "404 not found".
Another thing is inconsistent flash version. You could run into problem if you load a Flash version 9 with a Flash version 10.
Hope these pointers help.