How to make embeddable flash content? - apache-flex

Hi I'm new to adobe flash/flex so please forgive me if my question isn't too clear. I'm developing a website with a flash object that dynamically generates its content and I want the flash object itself to be embeddable into other website like how youtube does it. I have no clue how to approach this and any help would be really appreciated.

You need two things:
1) Distribute the url or embed code for your swf online somewhere (like done in youtube). You get the code by publishing your flash object and then copy paste the html embed tags.
2) If you're dynamically loading stuff into the flash object you will need to allow data loads from all hosts. Lets say that you have a source file at www.domain.com that the flash object loads. Some one takes the Flash application and puts it on their site at www.otherdomain.com. This application then tries to do a cross domain data load www.otherdomain.com <- www.domain.com. That will fail unless you have you explicitly allow cross domain loads for www.domain.com. You do this by adding a crossdomain.xml file to your websites root or preferably the folder where the source file is kept. If you put in the webroot then all content hosted there will be available to load from anywhere. The xml file should contain all the domain that are allowed to load anything from your domain (in this case it should just contain a * to allow any domain to load from your domain).
Here's a basic example that allows any domain to load data
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
More info on that (http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html)

The above answer is better than this one, but if you're brand new to Flash and Flex you might want to look into Adobe's distribution servies - http://www.adobe.com/flashplatform/services/distribution/ - I'm not sure if it will do everything you want but for a newbie it might not be a bad way to go.
=Ryan ryan#adobe.com

Related

ASP.NET MVC Get image path from different module

For sample I got these two modules.
Module.Admin
Module.Web
Then, all images that are uploaded inside the Module.Admin is place inside it, sitemap goes like this.
Module.Admin
- Content
-- Uploads
--- Images
Now, how can I load as source these images inside the Module.Web > View .cshtml file?
As I've notice, these two modules are having two different ports. I hope you understand what I'm saying. Feel free to ask. Thank you
Sounds like you made the module a web project too? That means that they will run in seperate sites and not be able to share information.
You should probably use plugins instead. I've described how you can do it in my blog: http://blog.gauffin.org/2012/05/griffin-mvccontrib-the-plugin-system/
If you only want to access files you have to setup a custom VirtualPathProvider which can access the files from the other library.

ASP.NET Virtual Directory For Common Markup

I have a few applications that need to share a common set of markup.
Scenario: I might have www.site1.com, www.site2.com, and www.site3.com. On all sites, /care/contact-us.aspx and /care/faqs.aspx will be exactly the same, but every other page will be totally different.
Issue: I'm attempting to not duplicate the .aspx files for each of these sites and would like to have a /care virtual directory that would include contact-us.aspx and faqs.aspx that each of these sites would use. I have seen this post from Scott Gu, but I'm looking for any other solutions/ideas.
Question 1: What would be the best way to set this up to share the /care directory?
Question 2: Any ideas about also sharing the code behind.
Background, if you care: In a legacy application (asp classic/vbscript), we have the ability to use a /common virtual directory for sites to share common markup and code (since they're all mixed together in .asp files).
Thanks in advance to any help or ideas!
Simply setup a virtual directory in IIS for each of the apps that points to the same physical directory.
Here's a good reference:
http://support.microsoft.com/kb/324785
This is actually pretty hard, and i'd recommend you either bite the bullet and go with the scott gu answer or use the solution we chose, which was to use the svn:externals property within subversion to import a directory from a "shared" repository. Subversion manual reference. If you use a different version control system i would guess it would have something similar but you're on your own in that case.
I use a virtual directory in order to share HTML and Image files between sites. To share ASPX files, things are a bit different - and harder.
When we share HTML files, we do not just link to that file because it would screw up the menu (different sites have different menus - we just want the content of the HTML files). So I created a page (e.g. "ShowContent.aspx") that opens up the HTML file, reads the contents as a string and assigns the string to an ASP label control. This may work for you as-is if you don't generate the content dynamically in your shared ASPX files.
Even if you do, hope is not lost. First, create a project that incorporates JUST the common ASPX files, build it and place the project files in a known location (http://shared.yoururl.com). Now, instead of pulling the contents by accessing a file, simply read the contents off using a WebRequest object:
WebRequest wrContent = WebRequest.Create("http://shared.yoururl.com/CommonInformation.aspx");
Stream objStream = wrContent.GetResponse().GetResponseStream();
StreamReader objStreamReader = new StreamReader(objStream);
string pageContent = objStreamReader.ReadToEnd();
Then display the pageContent on your blank page.
If your common pages are data entry forms then I'm afraid your only hope is to place them in a common source directory that multiple projects share. You'd share the source but would publish the files with each project. This is likely to be messy though: you may make changes in one that break other projects because they now have the possibility of interdependency.

How to load specific flash while switching different lang in ASP.NET web application?

I've built a multilingual ASP.NET web app and no problem . I'm trying to put a flash header for this website so I've made couple flash in different language ( because they are different not just in language , they have tiny different because of different cultures ) .
But my problem is i don't know how to load specific flash while switching different language .
Any solution ?
If it were me, I would create a resource file for each language (which you might have done already, depending on how you have implemented internationalisation), and simply store the different SWF file name in each file.
Then when you are writing out the SWF embed code, just dynamically read the file name from the resource files and you will get the correct file name for the current culture. Something like:
<embed src="<%=Resources.text.SWFFileName%>.swf" />
I found this article quite helpful when it came to resource files.
if you have a language variable inside your ASP.NET page script, then you can just load
<embed src="flash_header_<%= language_variable %>.swf" />
something like that. Then it will load different swf. I've put down asp.net long time ago, so the code maybe wrong but the concept is there

How do I read from a config file in Flex?

I'm working on a project for school right now and we're trying to get it set up so that it is easily deployable. The webapp portion of it is written entirely in Adobe flex.
However, we need links to certain files / url's within the code which are different on different machines.
For instance, my server might use 8180 as the port while someone else uses 8080.
Or one person is using Windows so a filepath would be C:/... while mine would be /home/...
Is there any way we could put these files into a separate config file and read them dynamically within the mxml files?
It would be really nice if we didn't have to recompile for each individual deployment...
Thanks in advance!
You can use HTTPService to load an XML file (or any text file) that is in a location relative to the Flex application SWF. Simply execute the HTTPService on application startup, parse the file, and make the data available wherever you need it.
Check out appcorelib, the docs will show you how to use a relative URL like from an assets folder:
loadXML("assets/xml/config.xml);
Don't need to worry about crossdomain if the xml and flex app are on same server.
If you have enabled the local-file sandbox, you may be able to use URLLoader to read a local file:
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=05B_Security_176_04.html
However, your SWF must also be local.
If you are loading the SWF remotely, you can connect back to the loading server for a list of resources. That should probably be the preferred solution in most cases.
You can pass in parameters into a SWF by adding FlashVars to the HTML that it's running from.
FLashVars
I strongly agree with brd6644. You will need a cross domain policy file on the server where the config files reside. Just copy the following XML to a file named "crossdomain.xml" and put it on the server root of the server that contains your config files.
<?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>
You may not need this if the swf resides on the same server as the config files. Also, as you can see, this cross domain policy allows access from all domains, so if you care a lot about security (may not be important for a school project), read up a bit on them to see how to configure. Here is a good article
Also, here is some sample HTTPService code:
private function init():void{
get_bands_service.url = yeswewillArtistsURL;
get_bands_service.method = "GET";
get_bands_service.addEventListener(FaultEvent.FAULT, onServiceFault);
get_bands_service.requestTimeout = 20;
get_bands_service.send();
}
<mx:HTTPService id="get_bands_service" result="parseBandsServiceResult();" useProxy="false" />

ASP.NET File uploading-dynamic file names

I have a web page where i have an ASP.NET file upload control to upload files from client machine to Server.Now i want to do the uploading n number of times.Ex : I want to upload 100 files from my local pc to server.The 100 file names i can read from an excel file in my program.But is there any way to assign this file to the file upload control ?
No, as a security feature, FilUpload controls do not allow you to set what to download (imagine if you sign on to a website, and it is set to upload a passwords file or something).
Now there is probably another control, or a way to code around this, buut the FileUpload control will not allow it.
I would recommend using the jQuery Multifile Uploader which would take care of a UI (if you need one). And the actual uploads with Free ASP Uploads which takes care of the actual file transfer. Though it sounds like you are tkaing care of the programs programatically, so you can skip the multifule and just work with free asp upload.
You'll have to make your own Flash object or something to accomplish this, the basic HTML/ASP.Net controls won't let you do what you're looking for.
This will require creating some kind of an active or installable control. In order to get around the security hole of doing this, you're ultimately going to have to be able to execute code on the machine to select and upload the file.
And at that point, you're platform specific, so...
I would strongly suggest that instead of trying to have a web site automatically upload files for you, that you make a WinForms utility to accomplish this task and upload the files wherever you need, communicate with the web site over web services, etc.
This is a security restriction, you cant script the file selection of an upload box as it would allow hackers to write scripts to steal files off your computer.
You could use this silverlight upload utility which is my list of "things to use when I get the chance".
It has a nice UI and supports uploading many files at once. I originally tracked it down doing some research for a photography website that we were quoting for but that project fell through.
Anyway the project can be found here:
http://www.michielpost.nl/Silverlight/MultiFileUploader/
It also has full source code included so even if the control's developers abandon it you still have the choice to edit it yourself.

Resources