Issue loading AS2 .swf that uses XML into AS3 .fla - actionscript-3

I'm making a website for a client where they purchased a flash template that was written in "AS 1.0 & AS 2.0" and then asked me to add a googlemap to the contact us page. However, the googlemap API only works in AS3. My options were to translate the entire website to AS3 OR to make an AS3 file that imported the AS2 website and then added the googlemap bit.
I decided to go with option 2 since it seemed easier...
Anyway, I'm using the Loader class in the AS3 file.
var myLoader:Loader = new Loader(); // create a new instance of the Loader class
var url:URLRequest = new URLRequest("main_v8.swf"); // in this case both SWFs are in the same folder
myLoader.load(url); // load the SWF file
addChild(myLoader);
The problem is the AS2 swf file uses XML to load the background images. It works on its own but when loaded into the AS3 file the background images do not appear. All the buttons and external links work, its just the loading of the XML.
I've been looking all over for help on this and while there are lots of people with issues playing AS2 swf in AS3 I couldn't find anything to help with this.
Any advise or solutions would be appreciated!
Thanks!

Havent face such a problem but, if you find out the problem you ca solve it. You can check some conditions:
check network for , does xml loaded. (might be crossdomain problem)
check if images loaded. ( as3 security problem)
check as2 file really inits. ( you can use as3 bridge to as2)

Related

Flash AS3 unload loaded SWF completely

how do i absolutely and completely unload a loaded SWF.
Here's the case. I have two different SWF, both have the same movieClips in the library with the same name and instance...but...both have different shape. So basically both are different but the names.
So i loaded the first.swf into the main.swf, in the first.swf contains button that order the loaded in the main.swf to unloadAndStop() and load the second.swf. But somehow the objects in the second.swf take the shape in the first.swf.
I hit the wall with this. How do i completely unload the first.swf
Thx guys
Try to load child swfs (first.swf and second.swf) into child application domains of the current application domain (Usage C in this Article Working with application domains, you can also find code sample from this article below). With this technique you'll get:
separate classes (all classes) of first.swf and second.swf from each other
unload all the class definitions for garbage collection after unloading swf
AS3 from the article:
var appDomainC:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
var contextC:LoaderContext = new LoaderContext(false, appDomainC);
var loaderC:Loader = new Loader();
loaderC.load(new URLRequest("module3.swf"), contextC);

Never Have Access to Embedded SWF Content Through Loader

I am working on embedding a SWF that is just a converted PDF created with InDesign. The SWF is 15 pages, 1 page per frame. It does include TLF text and there is no way around that unless the document is completely recreated in Flash. The problem is that when I load the SWF into my application, I never have access to the root MovieClip.
this.loader = new Loader();
this.loader.contentLoaderInfo.addEventListener( Event.INIT, this.loaderInitHandler );
this.loader.contentLoaderInfo.addEventListener( Event.COMPLETE, this.loaderInitHandler );
this.loader.load( new URLRequest( "assets/doc.swf" ) );
When I look at the loader after both the INIT and COMPLETE events as well as later on by stopping the app in debug mode, I do not see a MovieClip. Instead, the loader.content is of type doc_fla.MainTimeline__Preloader__ which contains two children, an empty Shape and another Loader. That loader, when checking INIT and COMPLETE events results in the exact same situation and it appears to be a never ending line of Loaders whose contents are "Preloaders".
Could anyone shed some light as to what is causing this or how I might fix it? I've poured a good 2 hours into solving this and I am no closer to a solution than when I started.
ActionScript Mobile project
Compiling using AIR 3.6
Testing in emulator as well as on iPad and on Nexus 7
I recompiled the SWF and embedded the TLF libraries (under ActionScript settings, just set the TLF swc which was already there to be embedded) in it and this seems to have fixed the issue. I swear I had tried that before to no success, but it worked this time.

Flash CS6 Importing sounds

I'm working on a Flash project in CS6 and need to import a sound to my library but I'm having endless problems with it. I'm using external files in Actionscript 3.0 (e.g. I cannot do a URLRequest as it won't work externally, need to import)
I'm using a sound that should work, some errors go in that it can't be over 160kbps, this is only at 32 in the MP3 file. I converted it to an AIFF, no success, a WAV? no success.
If it's an MP3 I simply get "Couldn't import "
If it's a AIFF or WAV I get "One or more files were not imported because there was a problem reading them"
Adobe suggest you need to files under 160kbps, all are set at 32kbps to be safe.
Another suggestion said you needed Quicktime 7.7.1 (or newer) and iTunes 10.5.5.3 (or newer) for this to work with an MP3 file. I have Quick 7.7.3 and iTunes 11.0 so I really have no idea of the problem.
Can anyone help, this project needs finished quickly.
Thanks.
John.
Could be to do with bitrates.
I was running into issues with some mp3 files that I had converted from wav using Audacity. It was a specific few that wouldn't work, so I went back to Audacity and compared the working-mp3-yielding wavs to the non-working. I noticed that the working wavs had a bitrate of 44100Hz the non-working had 48000Hz. Setting the project rate ( bottom left corner ) to 44100Hz before exporting yielded mp3s that imported into flash with no problem.
In short:
48000 Hz = naughty
44100 Hz = nice
This is a weird problem here's a simple code snippet that load and play an MP3 sound AS3 doesn't support WAV natively :
//sound object
var sound:Sound = new Sound(new URLRequest("music.mp3"))
var soundChannel:SoundChannel = sound.play();
Hope this help :)
This post is kind of old but I thought I would post an answer after running into the same problem. I am also using Flash Pro in CS6. What you want to do is to embed the sound into your FLA so that when your SWF is compiled the sound will go with it. Khaled's answer is great but this issue needs a little more TLC.
What worked for me was to get an application that edits sound clips. I downloaded the open source 'Audacity.' In the bottom left corner of Audacity you can edit the project rate. Take it down to about 1600 or lower. Then save the project and export the sound as an mp3.
Finally, make sure that your sound clip is in the same folder as your FLA. Import into your FLA (this should work now) and export your sound for actionscript by right clicking the sound in the library, going to properties. Change the name of the class to whatever you want (at least get rid of the '.mp3' from the class name).
Then use the following code (which is different from the typical URL loader for sounds):
//sound is a constructor variable under your document class
public class DocumentClass extends MovieClip
{
var yourSound:yourSoundClass;
public function DocumentClass()
{
init();
}
function init():void
{
yourSound = new yourSoundClass();
}
}
Then play your sound by using yourSound.play(); This technique will embed your sound within the SWF so it will go wherever the SWF goes. I hope that helps anyone who runs into this.

Best way to embed Flex-based swf into pure-AS3 project?

I'm working on a AS3 project that required a lot of UI, since Flex was used for time-saving for this part we ended up having a Flex Project (UI) and pure AS3 one (All BackEnd) or, in other words, two different .swf files.
Currently I can successfully comunicate both of them using a common interface and by loading the UI .swf into the AS3 .swf using a Loader class:
var loader:Loader = new Loader();
var request:URLRequest = new URLRequest(“CustomUIModule.swf”);
The actual code contains listeners for SystemManagerHandler so Flex doesn't complain.
Since we are delivering two different files it is not really practical whenever we release a build of the project. For this case the meta tag [Embed] seems to be a better way to achieve this (With no satisfactory results to date).
With the above information (hopefully I made myself clear enough) what would be the best approach to ultimately generate a single swf? Or how should we properly implement the [Embed] tag for Flex swf?
Thanks in advance.
I try to avoid loading SWF into another SWF It just doesnt seem right to me, especially if I have control over all the SWFs. If it was me I would integrate everything into one fat flex project. After all isn't this what OOP is all about.

Flash AS3 Preloader error: 1120 access of undefined property, preloader?

I'm a complete newbie to this, I've been watching tons of tutorials, reading tutorials, reading the Adobe site, etc... The last time I programmed was BASIC on Apple IIe...
I'm trying to create a preloader that my html page will link to, and when the main .swf file (Portfolio.swf) is loaded, it will display and stop (it's a print swf, so I don't want it to "Play" at 24 frames/sec.)
I have errors in my AS3 of 1120, which I will copy the code here:
stop();
var loader : Loader = new Loader ();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.load(new URLRequest ("Portfolio.swf"));
function progressHandler(e:ProgressEvent) {
var percent:Number=Math.round(e.bytesLoaded*100/e.bytesTotal);
preloader.gotoAndStop(percent);
}
function completeHandler(e:Event) {
this.addChild(loader);
this.removeChild(preloader);
}
And here's what I uploaded to my site so far to test:
http://krisbunda.com/templates/portfolio/Portfolio.html
as you can see, it just loops the progress bar, and doesn't load the "Portfolio.swf" file afterward. The actual "Portfolio.swf" can be viewed on this page:
[actually, I'm new, can't post more than 1 hyperlink... you can find the Portfolio on the root of my site.]
it takes a while to download the 6MB+ file, which is why I would like a preloader.
Thanks for your help!
I finally figured it out, albeit the code has evolved (devolved?) to something different.
I'm not at home to copy the AS3 from my workstation, but here's a link to see the code working as I intended it:
http://krisbunda.com/images/portfolio/Portfolio.html
send me a message if you are having a similar problem and would like the AS3 code pasted here.