generating swf files - apache-flex

I have a flex webservice project 'simpleWebApp' running on the tomcat server. The simpleWebApp.swf file generated is in the webapp root folder of tomcat and it executes perfectly when i double click on the simpleWebApp.swf file
now i need the generated simpleWebApp.swf file to run when placed anywhere, any location.
what i need to do?

Copy the .swf and .html file to a folder(say testApp) inside your server's deploy folder.Then access your application http://localhost:8080/testApp/.swf.This works perfectly for me.

You will need to have correct path to the server where you webservice will be located, it's better to have this as a variable and path it in the flash vars to your swf. Also you may need crossdomain.xml, to be able to access you server from flash in a case if anywhere != yourserver

Another way what i did is, in the flash builder i went to project/Export Release Build which Builds and export an optimized release-quality SWF file. now when i place release build folder anywhere, my swf file works.

Related

Is it possible to upload a complete directory structure with Flex?

Is it possible to upload a complete folder with subdirectories and files (in the subdirectories) in Flex?
I am using a Flex / BlazeDS / Spring application. The question is not how to transfer the data to the server. The question is: if it is possible to get access to the files and subfolders (recursive) with Flex?
If you're working with AIR, then yes. Look a the File class. It is a reference to either a file or directory. You can tell if it is a directory using the isDirectory attribute. You can use getDirectoryListing to get a list of all files and subdirectories in a directory.
As far as I know, you'll then have to upload things one by one to the server, though.
If you are using Flex in a web based app, I do not believe what you're trying to accomplish is possible.
No, not if you are talking about a Flex app running in a web browser. In an AIR application it is probably possible, but not in Flash Player in a browser.
The security sandbox doesn't give that kind of file system access, files are only available when selected by a user, via some user action like clicking a button. And then you only get a reference to the file, so it can be read or uploaded, there is no mechanism to for example get the local path to the file as a string or such, and no way to check for subfolders (unless it's an app for the AIR runtime).

"Add as Link" for JavaScript files returning 404 in debug

Using a Visual Studio 2010 ASP.net web application, I have several projects that share some JavaScript/css files. The most logical way for them to share these files is to place the files in a single folder and each project has them included with the "Add as Link" option. However, if I add the files this way when I'm debugging using either the Visual Studio Development server or debugging using a local IIS web server all requests for these files return 404 Not Found errors. If I publish the site then the files are copied but that obviously doesn't help with debugging.
Is there something I'm missing or is this a failing on VS's part?
To overcome this problem some time ago I created a 'MSBuild.WebApplication.CopyContentLinkedFiles' nuget package. This package adds MsBuild target which copies all content files added as link to project folder during build.
Note: if you use source control then it is better to add copied files (from Web Application folder) to ignore list.
I wouldn't really call that a failing, since you asked for that behavior in the first place: linked items in Visual Studio projects are actual links to external files. Those files can reside anywhere on the disk and are not copied into the project folder.
You might want to copy those files locally yourself during a pre-build event. That way, the files will remain synchronized and you won't duplicate them until your first compile.
The problem seems to be that the website runs right from your source folders, rather than from the bin folder. This means that the file will be missing, whether or not it is copied to the output folder.
It's probable that running from a local or remote web server would not have this problem, though I didn't get that working, and I'd rather not add IIS to my local machine if I don't have to.
Adding a pre-build copy command did work. Note that the current directory will be the bin folder. (You can use cd to echo the current directory to the build window if you want to see it):
If the file is in another solution, your command will look something like (three ..s: one to get out of each of bin, project, and solution folders):
copy ..\..\..\OtherSolution\OtherProject\Scripts\MyJSFile.js ..\Scripts\
If it's in the same solution, but a different project:
copy ..\..\OtherProject\Scripts\MyJSFile.js ..\Scripts
One minor issue is that the link to the file will collide with the new copy of the file, even if you don't add it to your project. As long as you make the link first, it seems to work. If you copied the file first, you'll have to manually delete the copy, and then refresh the solution explorer before before being able to add the link.
Select the link in Solution Explorer and then look at properties window and set Copy To Output Directory to Copy Always. Linked items are set to Do Not Copy by default.
BTW, you can copy many files as links very easily directly from Solution Explorer when using VSCommands 2010 extension.
See this blog post about a simple addition to your project file.
http://mattperdeck.com/post/Copying-linked-content-files-at-each-build-using-MSBuild.aspx

FlexUnit4 in IntelliJ

When I try to run test with FlexUnit4 and IntelliJ, I get this error:
SecurityError: Error #2148: SWF file file:///C|/Users/LIC/Projects/ProgramJef/out/production/Flex%2DClient%2DTests/%5Fflexunit.swf cannot access local resource file:///C|/Users/LIC/Projects/ProgramJef/out/production/Flex%2DClient%2DTests/textLayout_1.1.0.604.swf. Only local-with-filesystem and trusted local SWF files may access local resources.
at flash.net::URLStream/load()
at flash.net::URLLoader/load()
at mx.core::CrossDomainRSLItem/load()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\CrossDomainRSLItem.as:240]
at mx.core::RSLListLoader/loadNext()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\RSLListLoader.as:184]
at mx.core::RSLListLoader/load()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\RSLListLoader.as:156]
at mx.preloaders::Preloader/initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\preloaders\Preloader.as:279]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::initialize()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:1925]
at mx.managers::SystemManager/initHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:2419]
I really wouldn't know what the problem is here, and I can't find anything on it online. Even on IntelliJ and FlexUnit4 there's not much to find...
You must allow the resulting SWF access to your file system. Set the Flashplayer trust settings in a file. On Linux this file must be in
~/.macromedia/Flash_Player/#Security/FlashPlayerTrust/
(for Windows there is a similar path somewhere) and create a file that lists the output path of your project, e.g.
/dev/myproject/target
/dev/anotherproject/target
In case 'target' is our output folder.
Did you set up your test sources folder right? In Project Settings under Modules, add Flex and click Flex and add Text Source Folders using the tree structure on the right hand side.
(IntelliJ 9.0.2)

Running Basic Flex Projects over HTTP?

How do you configure Flex Builder to run basic flex projects over http (http://localhost/MyProject.html)? I can't figure out how to use crossdomain.xml files when running locally via something like file:///Users/Me/Flex/MyProject...
Running this on a Mac with Safari/FireFox.
Thanks!
It would be worthwhile if you mentioned what OS you are developing on: Windows, or Mac OSX?
In general, you'll be asking Flex Builder to deploy your build to a web-accessible location provided already by the IIS web server (if on Windows), or the Apache web server (if on OSX.) Here's how:
choose Properties on your Flex project
select Flex Build Path in the left panel
change the Output folder for your project.
On Windows, you'll typically choose an output folder such as C:\inetpub\wwwroot\xyz ... where xyz is the name for a folder you created to hold your project's output files. That will be accessible as http://localhost/xyz/YourFlexApp.html
On Mac OSX, a good output folder to use is /Users/yourusername/Sites/xyz ... where yourusername is your user name, and xyz is the name for a folder you created to hold your project's output files. That will be accessible as http://localhost/~yourusername/xyz/YourFlexApp.html
Important: Ensure your local web server is installed and enabled.
Additionally, you'll want to change your Run/Debug settings so that Flex Builder launches your project via http:// URL instead of via a file reference. Here's how:
choose Properties on your Flex project
select Run/Debug Settings in the left panel
select your application in the main list
click the Edit button
under URL or path to launch, uncheck Use defaults
change the Debug, Profile, and Run URLs to point to your web-accessible location.
I hope this helps.
This is a Flash setting, actually. You need to make the folder you're trying to run Flash in allowed by Flash. Go to this website, which runs a special component of Flash. http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
Add the local folder location inside the 'locations' piece and make them Allowed. It's not super-intuitive getting it to save your settings, but it shouldn't take more than one try.

Do I need to copy the .compiled files to the production server?

I'm using a deploy project to deploy my ASP.net web application.
When I build the deploy project, all the .compiled files are re-created.
Do I need to FTP them to the production web server?
If I do a small change do I need to copy all the web site again?
From my own research, the .compiled files must be copied to the production server, but not needed to copied every time
from Rick Strahl excellent blog:
The output from the merge utilitity
can combine all markup and CodeBeside
code into a single assembly, but you
will still end up with the .compiled
files which are required for ASP.NET
to associate the page requests with a
specific class contained in the
assembly. However, because the file
names generated are fixed you don’t
need to update these files unless you
add or remove pages. In effect this
means that in most situations you can
simply update the single assembly to
update your Web.
Source
You can get rid of the .compiled files by using the aspnet_merge tool with the -r option.
Removes the .compiled files for the main code assembly (code in the App_Code folder). Do not use this option if your application contains an explicit type reference to the main code assembly.
There's nothing special about .compiled files: it's just the actual file with a .compiled extension on the end so that nothing happens if you accidentally double click it.
But if you're seeing .compiled files, you're publishing your app in such a way that it expects to be formally installed- it's not enough to just copy things to production. You have to run the installer program too. If this is an app you know is already deployed, that seems a bit unnecessary.

Resources