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.
Related
Hopefully someone can help here, more or less looking for a) solution to relative paths or b) insight on another method of loading assets.
We have a standalone web application that is using SDK 4.1 and looks in its relative assets folder for all images and external swfs to be loaded.
on the server, this is the absolute path of the assets directory:
/ApplicationRoot/versionFldr/controls/assets/*
the application uses relative paths in all cases of loading an asset.. and this is continously being added to and updated as we advance versions of the app.
So, in essence, the app is looking for:
assets/*
now forward to the NEW application, lets call it "ParentApp" and the above application "ChildApp".
Parent App is in a different server directory than ChildApp
/ParentApp/version/controls/ParentApp.swf
/ChildApp/version/controls/ChildApp.swf
now, when ChildApp loads into ParentApp, it assumes that it is in the same directory that it's always been in. So, it looks for assets/* and cant find them because
/ParentApp/version/controls/assets/* != /ChildApp/version/controls/assets/*
I need to find a solution to have ChildApp look in an absolute path for ALL loaded assets when it is a child of ParentApp and have it look in paths relative to itself when it is standalone.
The caveats I have are that images are loaded into various controls, caches, and even mx:Text fields (html text with tags). I'm trying to avoid having to globally replace all path links across the application and having to create new coding procedures when new assets are created for the app. ChildApp is in production and has to stay on the 4.1 SDK.
ParentApp is new and has much more flexibility.
I've tried -source-path and -library-path compiler options in childApp, but this lead to compile errors and I have not been able to proceed.
Thank you in advance for any insight and help!
-AJ
I would solve this by having a "baseURL" variable in the child app. Give it a default value so that you can form the usual relative URL's that you are using: `var baseURL:String = "/assets/";
Unfortunately, you then have to modify every asset path in the child app so the path to the assets is something like: baseURL + assetFileName
When the child app is loaded into the parent app, you then give this baseURL variable a non-relative path. Ideally, you do that early in the process, before the child app tries to load any assets.
I have a SL project that is simply the MediaElement. I embed this in my aspx page and do all the controling of the element from the aspx page throught the java to managed code bridge. I had all my video files in the project as resources for testing but now want to move them out to the server where they will live. The server is in a different domain from my development box but I have access. I can see my files by going to the "run" command and typing that path as follows: "\mediaserver.otherdomain.com\Content\MyVideo.wmv" I can access the folder and view the video's fine from my computer. However, when I do my
`mediaElement.Source = new Uri(MediaPath, UriKind.RelativeOrAbsolute);`
in my code to load the video into Silverlight video does not play. The Media path is "\MediaServer.OtherDomain.com\Content\MyVideo.wmv. I have image files that I reference using the same path "\MediaServer.OtherDomain.com\Content\MyVideo.jpg" and they display fine.
When I debug and look at the values set in the .Source propery I see:
Absolute Path = "/Content/MyVideo.wmv"
Absolute Uri = "file://MediaServer.domain.com/Content/MyVideo.wmv"
Host = "MediaServer.domain.com"
This all looks good, so why don't I see the video?
Silverlight does not allow you to use cross domain references out of the box. You need to add an exception to do so.
If you're using SL4, look at Making a Service Call Across Domain Boundaries
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
I want to completely understand how to use relative and absolute url address in static and dynamic files.
~ :
/ :
.. : in a relative URL indicates the parent directory
. : refers to the current directory
/ : always replaces the entire pathname of the base URL
// : always replaces everything from the hostname onwards
This example is easy when you are working without virtual directory. But i am working on virtual directory.
Relative URI Absolute URI
about.html http://WebReference.com/html/about.html
tutorial1/ http://WebReference.com/html/tutorial1/
tutorial1/2.html http://WebReference.com/html/tutorial1/2.html
/ http://WebReference.com/
//www.internet.com/ http://www.internet.com/
/experts/ http://WebReference.com/experts/
../ http://WebReference.com/
../experts/ http://WebReference.com/experts/
../../../ http://WebReference.com/
./ http://WebReference.com/html/
./about.html http://WebReference.com/html/about.html
I want to simulate a site below, like my project which is working on virtual directory.
These are my aspx and ascx folder
http://hostAddress:port/virtualDirectory/MainSite/ASPX/default.aspx
http://hostAddress:port/virtualDirectory/MainSite/ASCX/UserCtrl/login.ascx
http://hostAddress:port/virtualDirectory/AdminSite/ASPX/ASCX/default.aspx
These are my JS Files(which will be use both with the aspx and ascx files):
http://hostAddress:port/virtualDirectory/MainSite/JavascriptFolder/jsFile.js
http://hostAddress:port/virtualDirectory/AdminSite/JavascriptFolder/jsFile.js
this is my static web page address(I want to show some pictures and run inside some js functions):
http://hostAddress:port/virtualDirectory/HTMLFiles/page.html
this is my image folder
http://hostAddress:port/virtualDirectory/Images/PNG/arrow.png
http://hostAddress:port/virtualDirectory/Images/GIF/arrow.png
if i want to write and image file's link in my ASPX file i should write
aspxImgCtrl.ImageUrl = Server.MapPath("~")+"/Images/GIF/arrow.png";
But if i want to write the path hard coded or from javascript file, what kind of url address it should be?
The ~ operator is recognized by asp.net only for server controls and in server code. You cannot use the ~ operator for client elements.
Absolute and relative path references in a server control have the following disadvantages:
•Absolute paths are not portable between applications. If you move the application that the absolute path points to, the links will break.
•Relative paths in the style of client elements can be difficult to maintain if you move resources or pages to different folders.
To overcome these disadvantages, ASP.NET includes the Web application root operator (~), which you can use when specifying a path in server controls. ASP.NET resolves the ~ operator to the root of the current application. You can use the ~ operator in conjunction with folders to specify a path that is based on the current root.
As for the example you posted
aspxImgCtrl.ImageUrl = Server.MapPath("~")+"/Images/GIF/arrow.png";
the above code will render the server physical path (for example - c:\inetpub\wwwroot\mysite\images\gif\arrow.png" which is meaning less on the client side,
you should use this for correct client relative path:
aspxImgCtrl.ImageUrl = "~/Images/GIF/arrow.png";
To reference resources from javascript you may want to consider a one level folders structure to unify access paths. for example:
Pages
JS
Pix
etc...
For more details visit asp.net web site paths
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.