Setting a swf file to only work from a specific domain - actionscript-3

I have an as3 swf, and I want to make sure it can only be loaded from a specific domain. So for example if the my file is f.swf and my specific allowed domain is www.google.com, you would only be able to load the f.swf from www.google.com, and not from any other domain. How can this be achieved?

Check this out - http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html. This should resolve your issue.

Related

Java EE Web App - Image path configuration

I have implemented image upload feature but I am facing issue with its path configuration.
I want to store the uploaded the images outside of webapp root directory because every time I un-deploy the application, it deletes the images within the application.
Now, I can store the the uploaded file by getting the path from property file [say C:\images] but when I use that path in it doesn't show the file in web page.
Can you please let me know how to get the absolute path in img src tag.
For security reasons, you can't reference files outside of the webapp root. You're going to need to use virtual directories. These will map outside paths into accessible URLs so c:\images will be accessible as myapp.com/myapp/images/
This sort of thing is specific to the application server you are running, so you'll need to check the documentation for your system to make this work.

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.

Problem retrieving a file that is outside root directory

I have a problem retrieving a flash file that is outside of the root directory.
What I have are 5 websites that use the same flash file, so I created a folder outside (one level up) of the 5 domains on my server. In the folder I have my flash file.
I am using the relative path below, but no worky worky.
"../resources/helpful_info.swf"
If I move the resource file and website files under a single domain it works fine. So, it seems I have a problem when I use a relative path and jump outside the domain to search for a file.
I don't want to use absolute path because files and paths change too much here.
Any ideas? I need it to worky worky
THANKS!
Your path does not make sense.
Relative paths are interpreted by the client, and they're used to compose a path within your domain.
You cannot use a relative path to tell the client to fetch a file outside the domain.
You also cannot reference outside your site at server side. Think security.
I see 2 fast solutions:
1) Create a new domain put the flash there. Other security problems like cross site scripting might occur.
2) Make a copy of the flash for all 5 domains. It is it update often create a script to copy it to every domain.

AS3 physical path problem in linux environment

Am developing a video player in as3 , everything is fine, but finally i got a prob in basic itself.
Question is How to specify the path to loading xml into flash. FOr example
urlreq.load("hostname/filename");
instead of host name i have to specify my physical path infact i should. so how to specify this.
means i have to load a xml file from root directory, something like
"/opt/adobe/fms/applications/vod/media/moviename/chapters.xml"
here i couldnot get the file.
Please some one help me out.
I'm not sure I understand the question correctly, but as far as I know there is no way to specify an absolute path for the filesystem; When using an absolute path (/...) it is actually relative to the root URL of the web-site where this SWF is being served from (or the folder where it is being run from during debug process).

Flash AS3 - Access external swf on the same domain

I ran into this problem and could not solve it, so I have a swf file that loads assets from
another swf file, everything's fine, until I put them on the server, they are under the same
domain, relative path doesnt work nor does absolute path. This is not even a cross domain
problem, since both files are on the same server.
Did anyone ever have the same problem?
Thanks.
If you're using Flex Builder you can set the right -use-network compiler flag.
If you're using Flash IDE and the content is on the same server, make sure
you've got the Local playback security set to 'Access local files only', in the Flash
tab under Publish Settings.
alt text http://www.adobe.com/devnet/flash/articles/local_network_playback/fig01.jpg
That should do it. As Dru stated, what is the error message you are receiving ?
The images comes from this article which might come in handy.
Goodluck!
http://www.ultrashock.com/forums/actionscript/loader-problem-with-swf-from-same-domain-123692.html
try this , maybe can help