I'm trying to load the swf created by 'flip book maker' into my project.
the files created by flipbook maker are
book.swf
framework.swf
I used the following code
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("book.swf");
myLoader.load(url);
addChild(myLoader);``
the framework.swf is linked with book.swf, so it cannot run alone.
When I run the movie it shows the Error #2032, Stream error to framework.swf
book.swf and framework.swf both are in the same directory.They are generated by flip book maker What I needed is to load the book.swf into my project at a particular frame. I need help in AS3 for this purpose.
How to fix it..?
please help me..!
Error #2032 means that your Flash application could not load the framework.swf for some reason (you know this already of course). What you need to find out is why. Possible reasons are: you have the wrong URL, the framework.swf is not in the place you expect, there are crossdomain restrictions on the file you are trying to access ( you did not state where frameworks.swf).
What I would suggest doing is using a web debugging proxy tool like Fiddler (http://www.telerik.com/fiddler) or Firebug (is a Firefox extension) and take a look at the http requests to get more information on your error. You may find out that frameworks.swf is not in the location you expect.
This is just a IOError event triggered by Adobe Flash. Most likely the file just isn't found. Check your path and make sure you place the .swf file in your bin-debug directory if you're doing this from within Adobe Flash Builder
Related
I have been developing a Web type Flex project in Flash builder. In this project I have been trying to load a swf file using the SWFLoader. I have had trouble getting the debugger working, so I have instead created an identical Air project that I can run and debug with (I keep it up to date with a script). I have successfully loaded the swf file in my Air project with no trouble. But, when I went to test this in my Web project, the SWFLoader does not seem to work, I just get a blank area where my SWFLoader element should display the loaded swf file.
private function get_swf_file_binary_amf(event:ResultEvent):void {
Alert.show("SWF Returned");
var decoder:Base64Decoder=new Base64Decoder();
decoder.decode(event.result);
var swf_bytes:ByteArray=decoder.toByteArray();
var context:LoaderContext=new LoaderContext();
context.allowLoadBytesCodeExecution=true;
context.parameters = {myval: "test_string"};
swf_loaded_file.loaderContext = context;
swf_loaded_file.addEventListener(Event.COMPLETE, loadComplete);
swf_loaded_file.load(swf_bytes);
}
private function loadComplete(completeEvent:Event):void{
trace("load Complete")
}
Above is the code that works in my Adobe Air project. I am receiving the binary data of my swf file and converting it into a ByteArray, not using the URLLoader like so many example suggest. Could this be the cause of my problems when I try to run this in my Web project?
Edit/Update: I have found the particular line where the Web project fails:
context.allowLoadBytesCodeExecution=true;
I am still not sure why my Web project does not like this line, yet my Air project doesn't care.
I have removed the accursed line:
context.allowLoadBytesCodeExecution=true;
This seems to have fixed the problem. I am not even quite sure what this line does, I had just carried it over from a tutorial. Getting rid of it didn't seem to break anything that worked in my Air project, so I think that solved my problem.
I'm making a music player using AS3, but I'm having one problem; when I try to find a song outside the project folder using the AS3 script it simply doesn't work.
I've searched in the Internet and all the examples I've found used the relative location like this:
loadedSong = new Sound(new URLRequest("music.mp3"));
And it works for me, but with it I need always to have the songs in the root folder of the project. And I want to read them wherever they are without having to duplicate them to the root folder.
I tried to alter the code to use the absolute location like this:
loadedSong = new Sound(new URLRequest("c:\Users\pc\My Music\Artist\Album\music.mp3"));
But it fails with this error: "SecurityError: Error #2000: No active security context."
What am I doing wrong?
This is security restriction of Flash Player. If you need a desktop player, you'd better use Adobe AIR. Otherwise, you can use web server and store files there. Or you can just add allow Flash Player to read from hard drive by adding trusted locations here.
So I have run into an issue and I think it is mostly because I haven't worked with as2 in about 5 years so things are pretty hazy. Anyway, my problem is that I need to display PDF files within the flash movie. To do so I have resorted to running SWFTools in my backend and converting pdfs to swf for display. SWFTools, though, outputs AS2 files which I can load into AS3 but I can't actually control (for example, calling stop()).
Thus I have resorted to using an AS2 loader which gets loaded into the AS3 project which is responsible for loading the converted pdf swfs. The problem I am running into is that the listener does not seem to be firing when I load the AS2 file in via AS3 but it fires just fine when run on it's own.
This is the code I am running. To summarize when I run this code on it's own "LOADED" correctly prints to the output and the loaded SWF stops. However, when I run it via an AS3 container the swf loads in correctly but the "LOADED" trace never occurs and the stop is not executed.
thanks so much for any help!
var loader:MovieClipLoader
var listener = new Object();
listener.onLoadComplete = function(loadedClip) {
trace("LOADED");
loadedClip.stop();
}
loadFile("data/testing.swf");
function loadFile(target){
loader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(target, holder_mc);
}
SWF Tools does support AS3, you need to change it in the options.
1. Open your PDF in swf tools
2. Edit=>Options
3. Viewer tab
4. Check "No viewer" and flash version 9. (Or use the simple viewer)
- You can also do the "Insert stop after each frame"
I know this because I've done the same thing with a PDF. If you don't have those options, then it's time to download the latest version!
I am using AS3 to make a game. I use RequestURL( filename ) to obtain the music I want to play. However, this means the music file has to be in the same folder as the .fla file. How can I use it to get a music file from a different folder? I don't really like having to leave my music outside of a Music folder or properly organised somehow....
EDIT: Should have mentioned this earlier. I tried to use simply something such as "whatever/filename", but I got this security error:
SecurityError: Error #2000: No active security context.
Why?
Have you tried using the flash.media.Sound.load() method yet?
//Make a new sound object
var s:Sound = new Sound();
//Load it
s.load(new URLRequest("someDifferentMusicFolder/loop.mp3"));
//Play it
s.play()
If you are loading it via another method, such as URLLoader + URLRequest, please post your code and we should be able to help a little better.
Generally speaking though URLRequests should allow you to specify different folders, so your problem may not be in the methodology you are using but may be in your implementation? Perhaps you are getting a security error? Whatever it may be, if you post your code we can help you narrow it down.
I have a Flash AS3 application that uses FileReference.browse() to request a SWF from the user. If the chosen SWF is AS3, I'm good to go. However, if it's AS2, I need to load it into an AS2 wrapper first (so my app can alter it). All of these files (including my app and wrapper) are intended to exist locally on the user's machine, but the file they select can exist in any directory. So to be clear: Main application (AS3) -> Wrapper (AS2) -> User's file (AS2)
I know how to get the uploaded file's ActionScript version from the Loader's loaderInfo.actionScriptVersion variable, and that's working correctly. My issue is how to pass the file from the AS3 application to the AS2 wrapper so it can load it.
My first thought was to dump the ByteArray from the FileReference's load() function into a SharedObject "cookie". This method seemed pretty bad from a user-experience point of view, but it seemed most likely to work. However, I've been unable to find any method within AS2 to load the ByteArray as a movie (in fact, AS2 doesn't even seem to have a ByteArray class). So the first potential solution to my problem would be if anyone knew of a method for loading a movie from a ByteArray in AS2.
My second thought was to pass the uploaded file's path to my wrapper via the already-setup LocalConnection bridge, and then just have it load the file from that. However, I can't find any way to get the file's path, and my Googling suggests the security model intentionally prevents it. Not to mention, I'm not sure I can load an arbitrary file from the user's machine.
My "hands up in the air; I give up" solution was to just create separate buttons for loading AS3 and AS2 files (leaving it up to the users to guess which it is!) and have the AS2 button actually within the AS2 wrapper. However, it looks like AS2 doesn't have a file browsing uploading API, and the PHP-hybrid solutions I've found aren't an option (because this is meant to be run locally).
So, I would be eternally grateful if anyone could point me in the right direction for solving any of these three roadblocks. Alternative workarounds are of course welcome.
(Edit)
Ok, I found the documentation for AS2's version of the FileReference class. It supports the same file-browsing capability, but does not support directly loading the selected file into the SWF.
However, the security sandbox doesn't seem as strict for local files as I expected, and it looks like I can load any SWF on the user's machine once I have a path to it. So I should be able use JavaScript and an HTML form with a file input to get and pass the file path to my application. It's not ideal having to do all of this from within a web browser, but it should work. If it turns out satisfactorily I'll submit it as an answer.
(Edit 2)
Scratch the HTML-form idea. Looks like the path is hidden from JavaScript for the same reasons Flash hides it. The only option I can think of now is to have the user copy and paste the path to the file...
After reading over your post, you may be able to retry one of your previous attemps with some new information. Actionscript 2 DOES have a method for looking up files from a browser, same as AS3 does. AS2 also has a FileReference class. Check out the documentation here:
http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001040.html
Also, here is a tutorial:
http://markshu.ca/imm/flash/tutorial/fileReference.html
Well, all of my other leads have dried up, so I'm submitting the two answers that will actually work, although neither is ideal:
A) Use Adobe AIR, which will give more access to the filesystem (such as for getting path info) at the cost of requiring the separate AIR runtime to be installed.
B) Have the user enter the path to the file themselves (cumbersome for the user)