I'm building a slide-show like application in Flex and I'm trying to load images dynamically. The images are in a folder outside the application folder. This is the folder structure:
/Bildvisare-debug/
Bildvisare.html
Bildvisare.swf
/Images/
01_02_01_01_B.jpg
01_02_01_01_T.JPG
I'm reading the image names from an XML file and get them with a path of ../Images/01_03_01_01_B.jpg. In my mxml-file I've got an SWFLoader named picture and I try to load the images with the following code:
this.picture.source = images[currentImg]; //E.g. ../Images/01_03_01_01_B.jpg
this.picture.load();
The problem is that the images never show up, I only get the icon for a missing image. Can anyone help?
Edit to add: I've tried this both with and without the use-network flag set to false when compiling.
I believe this is relevant to your case.
A SWF file can access one type of external resource only, either local or over a network; it cannot access both types. You determine the type of access allowed by the SWF file using the use-network flag when you compile your application. When the use-network flag is set to false, you can access resources in the local file system, but not over the network. The default value is true, which allows you to access resources over the network, but not in the local file system.
From Flex Image Control
Related
I'm using an Azure storage account to store images and files as block blobs.
Browsers seem to be able to serve images correctly without an extension as long as the content type property is set. For example this will show up as a normal image: https://navhomeprod.blob.core.windows.net/facilityroomphotos/12
Would it be better for any reason to save the blob name with an extension: https://navhomeprod.blob.core.windows.net/facilityroomphotos/12.jpg
The reason I chose not to have extensions is so that I didn't need an extension field in the database, I could just use ids to serve the images.
Simple answer is no. You don't really need to specify a file extension in order to serve images. The catch here is that content type should be set properly. Content type tells browsers how to serve the content.
Even if you have the extension set but content type not set, some browsers will not be able to serve the content in that case. I have seen many questions where Chrome prompted to download an image file instead of showing the content inline if the content-type of that image file not set properly.
One use case that I could think of where the file extension will be handy is when you download these files on your local computer. Based on the file extension, your local computer would decide the application to use to view/edit these files.
I am trying to load a SWF file that is generated externally (Pano2VR) into my main Flex app.
I use the SWFLoader MXML object and everything works fine locally.
I really want to put the child SWF into another domain though (cloud). That works fine too (once I setup the crossdomain.xml file), but there is a rub.
The child SWF application itself requests additional images - problem is that the file paths requested are relative. Looking at a network call trace (in browser), I see that the child SWF file now thinks it's base URL path is the base URL path of my parent SWF.
For example: my (parent) Flex app is hosted at www.xyz.com, and my "child" SWF file is hosted at www.123.com. Technically, the "child" SWF file needs to look for its resources based on a base path of www.123.com - however I see it is querying my parent app's base path, www.xyz.com. I cannot control the "child" SWF, only the containing one I am writing.
Is there any way I can override the base url path of the loaded SWF file (in SWFLoader) from within my app?
Thanks for any help!
Fred.
You must decide what application domain your child module will be loaded into. Take a look at this documentation
By default, the application domain loads into the parent one, thus getting the behavior you are seeing.
In flex 3 web application how to set default save location for images?
Thanks.
From the FileReference documentation:
The FileReference and FileReferenceList classes do not let you set the default file location for the dialog box that the browse() or download() methods generate. The default location shown in the dialog box is the most recently browsed folder, if that location can be determined, or the desktop. The classes do not allow you to read from or write to the transferred file. They do not allow the SWF file that initiated the upload or download to access the uploaded or downloaded file or the file's location on the user's disk.
If you're using AIR, you have more control using the File class.
I'm working on a flex app, and I have Flash & AS3 experience up to now. I have text file I need to request using URLLoader, so I placed it in the same directory as the SWF
deploy > maps > map1.txt
but when run the SWF I get the following error
*** Security Sandbox Violation ***
SecurityError: Error #2148: SWF file file:///Users/him/Documents/Clients/Geekery/Bounce/deploy/Bounce.swf cannot access local resource /maps/map1.txt. Only local-with-filesystem and trusted local SWF files may access local resources.
at flash.net::URLStream/load()
at flash.net::URLLoader/load()
at com.geekery.Bounce::BounceMap()
at Bounce/loadMap()
at Bounce()
Which seems odd to me. Is there a special place I should be keeping files like this? Or is there some way I can allow files to be loaded form the same directory as the SWF?
Are you using a relative or absolute url? Have you tried loader.load( new URLRequest( 'maps/map1.txt' ) ) ?
If the file is static, you can use the #Embed tag to do this. See this example.
What you need is a crossdomain.xml to set the permissions for the .swf application on the same server. More info at below links
Cross-domain policy file specification
loadPolicyFile()
If this is not really what you are looking for then you can just go for the [Embed] solution.
I have a swf that is run from C:/ in the browser instead of a server (long story) and that swf loads a video that it located at ../../videos/video in relation to that swf.
Problem is, When I run it in Flex, everything is cool. Running locally, it can't find the file (not a security error) and is throwing a connectionError.
Any ideas?
NOTE: This seems to be a Windows specific problem, it's running on my mac with the same security settings just fine.
Flex Builder has a file that it adds all of your bin directories to in order to allow the debug player to get around the local security restrictions.
Here's a blog post on the subject.
Essentially Flexbuilder tells Flash that it should trust the bin folder... if you do a search on your development machine for the file flexbuilder_plugin.cfg, you should find it in a folder called FlashPlayerTrust in roughly the same area you normally find SharedObject files. If you open this file in a text editor, you should see pretty much every path to every bin folder for every flex project you have ever worked on. And suddenly everything gets so much clearer.
You can do as fenomas suggests and add any directory to your trusted list. You can also follow the advice from the above blog post.
So I created a new file and placed it next to this flexbuilder_plugin.cfg file, and called it MyProggy.cfg. Flash is configured to read in all files in this folder and parse all paths out of it, and any applications run from these paths will be considered "localTrusted" and will act as they would when run from Flexbuilder. Inside this text file I put one line: "c:\program files\my proggy" and saved it. I then had to restart Firefox for the change to take effect. I also had added a text label to my application and bound the text property to {Security.sandboxType}.
I would suggest getting HTTPFOX for Firefox which is a sniffer. Then you can see what is failing. In my own search I found that FLV's are always relative to the SWF, even when loaded on the WEB. Every asset that I have loaded is relative to the index.html file except for FLV's which always remain relative to the SWF. Being able to watch the data flowing, or attempting to flow to your site is invaluable.
This also explains why some people have no issue loading thing locally but then run into problems on the web. If their html file that is loading the swf is in a different location than the swf then every asset other than FLV's have a different relative path when viewed online then they do when viewed locally.