When I zip up my demo FlashDevelop project..why does it break? - actionscript-3

I built an AS3 image gallery using FlashDevelop.
Before I zip up the application, I can run the image gallery in my browser by simply opening the index.html for the project. Everything works perfectly.
I then zip up the project as proj-0.1.2.zip using winrar.
I then unzip this newly created zip and try to load the application using the project index.html like above. The gallery doesn't function properly. From seeing what happens, it appears as though the image metadata is not present(but I'm not sure, see below).
There are other applications as well that are broken. Videos don't load. If an application doesn't depend on any external assets then everything looks fine.
Another thing..If I then build the FlashDevelop project and republish the swf..then it works in the index.html like I want. What is going on here?
I want people to be able to fire up my demo apps out of the box by just running the index.html. If that doesn't always work and they have to figure out that they need to rebuild the SWF then that's pretty bad.

I don't think zipping is the problem, I think moving to a different folder is a problem.
I assume you are running this index.html on your local PC, and not on a webserver?
By default, Flash cannot access from a local SWF to load other local files. However, FlashDevelop / Flash CS3 / Flex Builder, in order to get around this restriction, set some flags in the flash player telling him "This SWF is a trusted SWF, allow him to open local files". But it's based on the exact location of the SWF.
There's a setting somewhere in the compiler, that sets a flag in the SWF saying "This SWF can access local data", but there's one downside: It blocks all access to network resources. So it's either/or: access local data, OR access network resources (anything that goes over HTTP, Socket, etc). I'm not sure where this setting is offhand. It may be that the default setting for Flash CS3 is different than the default setting for FlashDevelop.
Anyway, the easy way to avoid all this issue is to not run the file locally. Put it on your webserver before testing.

Related

Database content not retrieved in the exported SWF and published HTML

I have this problem that when i am running my project in Flash cs6 using ctrl+enter, the project is ok, the flash player is retrieving the files from mysql database. but when i run the independent swf file outside, there is no retrieval happening. the text box that suppose to be showing the retrieved data is empty. how can i fix this?
Make sure you are running the published html from an actual page in the browser and not from the local file system.
Just make sure that the URL doesn't start with file:///
You must be having a security sandbox error, but you probably don't have the Debugger version of the Flash Player, so it's not telling you anything.
Just go to http://www.adobe.com/support/flashplayer/downloads.html and choose the proper one for your operating system and browser.
If you STILL want to run the files from your local file system, you can have a look at Flash Player's Global Configuration, to give access to the files/directories you want. Just right click on your swf file in the browser, and when the Menu opens, select Global Configuration.
The reason it is working when running inside Flash CS6 is that the player has less security restrictions in there.
Let me know if you were able to solve your problem.

Flash swf publishing

I have a problem here regarding flash+as3.
I'm makin an application that take data from XML file and show it on flash.
Now here's my problem.
When I preview the file, it went just fine. All the data been shown on the flash.
When I published it into .exe file, it also went just fine. All data been shown.
But...
When I published it into .swf file, there's a problem. All the graphical images been show, but data that i got from the XML file does not shown.
But when I took the published file and drag it into flash, it went just fine. All the data been shown.
I'm not quite sure what happen. Is there any setup that I have to do to solve this problem?
Thanks guys.
2 possible problems:
your path to the xml data is relative and your published swf can't find it.
More likely your xml data is on a web server and you are looking at the swf through a local webpage using file:///myfile.html. This fails because of security. Adobe have decided that local swfs can only look at local content, and network swfs can only look at network content. This rule is disregarded in the flash ide because if you have the flash ide you are a developer and you should know what you are doing.
Check out your swf on a web server and report back.

Load an image in flash/actionscript from a different origin domain

I'm a complete noob when it comes to flash coding.
I have a flash swf file that I'm loading from an S3 assets bucket. Inside the flash swf it should be displaying a "Browse" button, images also courtesy of the same bucket. This works fine when I host the images and swf file from the same domain that the site is on, but not when loaded from S3.
I have added a crossdomain.xml file to the assets bucket as follows (I'm trying with '*' to start just to get it working, and will narrow it down to my actual host when it appears to be doing anything):
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
I also have a cross-origin resource sharing configuration in the bucket so that the fonts will correctly load for our stylesheets (This is working).
What am I doing wrong to make the button images load in the actionscript? Do I need to modify the actionscript code itself? The code is located here (public library anyone can use, not authored by me): s3-swf-upload-plugin
You can see here that it is instantiating a new browseButton defined here. Like I said I'm not totally familiar with actionscript but believe I could fumble through it if someone could show me what's going wrong :) What's a good way to get actual error reporting? Firebug in Firefox and Chrome's console don't have any kind of messages from Flash about errors going on.
EDIT:
There were some quirkinesses going on in the setting up of the flash object and setting the paths for the button images. I updated BrowseButton.as to do this:
Security.loadPolicyFile("http://s3.amazonaws.com/my-bucket/crossdomain.xml");
I placed this before any of the URLRequest calls in the BrowseButton() function. However it's still not displaying the images :( I also hardcoded the values in the URLRequest to be things like:
upLoader.load(new URLRequest("http://s3.amazonaws.com/my-bucket/assets/s3_up_button.gif"));
but nothing seems to happen. When I set it to /assets/s3_up_button.gif to pull from the local file then it works fine. What am I doing wrong! How can I get error messages displaying from the flash video? :\ I compiled with <debug>true</debug> but I'm not sure how to get actual exception messages.
Check what sandbox your swf is in:
The Security.sandboxType property
An author of a SWF file can use the read-only static
Security.sandboxType property to determine the type of sandbox to
which Flash Player has assigned the SWF file. The Security class
includes constants that represent possible values of the
Security.sandboxType property, as follows:
Security.REMOTE--The SWF file is from an Internet URL, and operates under domain-based sandbox rules.
Security.LOCAL_WITH_FILE--The SWF file is a local file, but it has not been trusted by the user and was not published with a networking designation. The SWF file can read from local data sources but cannot communicate with the Internet.
Security.LOCAL_WITH_NETWORK--The SWF file is a local file and has not been trusted by the user, but it was published with a networking designation. The SWF can communicate with the Internet but cannot read from local data sources.
Security.LOCAL_TRUSTED--The SWF file is a local file and has been trusted by the user, using either the Settings Manager or a Flash Player trust configuration file. The SWF file can both read from local data sources and communicate with the Internet.
You probably want Security.LOCAL_WITH_NETWORK, although Security.LOCAL_TRUSTED will also work.
An explanation, along with details of how to set the sandbox in Flex, is here: http://livedocs.adobe.com/flex/3/html/help.html?content=05B_Security_04.html
If you're working in the Flash IDE, it should just be part of the publish settings.

Pass file from AS3 into embedded AS2 wrapper to load

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)

ImageLoading relative path problem in Flash

I'm trying to load images from a relative folder /media/one.jpg but it never loads, I use the same script to load from my local folder and it does.
The absolute path e.g c:/mydir/one.jpg does not work either. Earlier I used to throw things at my server and get jpegs from there. But for testing purposes I need these images locally available.
Any Idea?
Just solved it Use loadImage("media\ears.jpg"); double slash instead to single and it works :)
For security reasons flash files can access only web or only local files, with can be set in the project properties. If you want to build a web application like a webpage or just a part of a webpage, than you should choose network only, but this way you can test your work only on a webserver (that can be localhost too ). If you want to build a desktop application, witch has no relation to web, then select the "local only" option in your project properties.