How to make a Flex Builder project to work on an existing Flex non-project with ant build? - apache-flex

I want to do some development on a Flex project that uses Ant: http://svn.openstreetmap.org/applications/editors/potlatch2/ . I can build it from the command line but now want to use Flex Builder 3.0.2 to build, debug, etc.
I can see a few different paths to follow, but nothing that screams out "this is the right way":
create new project, SVN checkout in there (but then the directory structures won't match, and not sure how to tell FB to build using the existing build.xml)
create new project, create external source links to another directory with the files in it
Surely people do this all the time? (Never done Flash development before...)

Ok, here's what ended up working for me. It turns out I didn't need to use ant to build the project after all. This is for the specific project (Potlatch2) but lots of the principles are probably common.
File | New Flex Project (no server), save it somewhere, eg "c:\pot"
SVN checkout the potlatch2 files inside, so you have c:\pot\potlatch2\potlatch2.mxml etc...
Rename version.as.template to version.as and make up some stuff inside
Remove the "..." line from potlatch2-config.xml. Don't ask me why.
Set Flex SDK version - configure it to point to SDK 3.5
Project | Properties | Flex Build Path:
set source folder to potlatch2
set output folder to potlatch2\resources
set library path to potlatch2\lib
Update Flash global security settings to allow access to c:\pot\potlatch2\resources (otherwise you get 1. SWF security errors)[1]
Update browser settings (Window | Preferences...) to use a browser that has Flash Debug Player installed (ie, not Chrome).
Under debug settings (click the bug drop down, Other...): Turn off "Use defaults", make debug (and possibly run and profile) point to an HTML host file that passes the right settings to potlatch2.swf, passing lat/long coordinates of a place you want to edit.

Related

Importing a subversion repository

I'm having problems: I create a new repository in Subclipse that points to a URL. When I check out the code and it creates a Flex Builder project, I am getting errors that relate to issues with the .actionscriptProperties and .flexProperties files.
So, I was told to just create a new FB project and point the src folder to where SVN is on my machine.
I'm new at this. But I'm guessing that until I do something like import my repository....it's nowhere on my machine. But when I imported it, it appeared to try and take every existing FB project I had and add it to SVN. That's not what I want.
How do I do this right? What am I missing?
Thanks for any helpful tips!
right click in the navigator, new -> other
Under SVN, select Checkout projects from SVN
Select the location of your repo with the FB project, hit next
there should only be one radio button available, if not, you didn't select the correct trunk location with the project files
Check "Check out HEAD revision", depth: fully recursive, uncheck ignore externals, check allow unversioned obstructions
click "finish"
If it complains about anything, let me know what the error is. You may have a different default, for instance, if the project was configured using "default SDK" and the project creator's default SDK was different than your default SDK you'd get errors.

how can i clear or reset the preferences for Adobe Flash Builder?

I am using Flash builder 4 to both build and manage (via cvs) projects. In recent days my designer has been having trouble committing to CVS, leaving a project blocked.
I have troubleshooted troubleshot tested CVS and it is working fine (others can commit and retrieve without a hitch).
in an effort to start from scratch - I have removed the flash builder application (dragging it to the trash, its a Mac) as well as using the uninstaller (which does not work as well as I would have thought), but on reinstall - all preferences are still there - CVS connection and all.
is there a file or set of files I can delete to reset all of the prefs for Flash Builder (built on eclipse if that helps)?
Go to your workspace directory and remove the .metadata directory. This is where Eclipse stores all preferences and project-settings.
You can find the workspace directory by navigating through the preferences:
Preferences->General->Startup and Shutdown->Workspaces
Note: this will remove all configuraton for FB, not just those settings pertaining to a specific project.

Flex / Flash Builder SVN: what files and folders should not be checked into subversion?

Background: Trying to set up my dev. environment in new job. Have subversion installed ok in Flash Builder 4, and checked out the project folders I will be working on. Work to date was developed in FB3, I'm going to be using FB4.
The folders/files that get imported to the project also include .flexProperties, .actionScriptProperties, .project, html-template etc (basically everything).
I would have thought that just the src, libs, lib-rsl etc should be part of the svn?
UPDATE:
Here is a good link to setup details for sharing svn flex projects using 2 folders, one of which has the checkout code, the other of which has folders linked to the first (but without the project/setup files)
It depends on the the development group. If everyone is provided the exact same set of tools in the exact same environments it can be ok to include the IDE project files. But if there is any chance that anyone is going to use a different environment (this includes a rolling upgrade of tools) then it is a bad idea. I recommend against putting these files in source control.

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.

Post Build Actions in Flex Builder

How do I add post-build actions in Flex Builder? For example, I'd like my build to work as normal, and execute from the bin folder; but I'd also like a copy of the final SWF to be copied to another folder automatically (I'm sick of doing it myself).
Thanks!
I know this post has been answered, but I found something simpler. I'm sure the Ant solutions are the way to go, but I didn't feel like messing with ant for my small project. All I really want is to have my html files and swf files in different directories. I guess that's a lot to ask.
I'm building on windows, so I created a simple batch file that performs my post-build steps (namely some move commands). I then created a new builder in flex using windows cmd.exe. I just told it to call the batch file using the /C option. It works perfectly and was very simple to set up. I tried adding screen shots, but I guess I'm too new to the site.
You can extend or replace the builder used by Flex Builder 3 with extenal programs - ant is a good choice.
If you run "Flex Builder 3 standalone" (which is a minimalist Eclipse version + the Flex builder plugin) as opposed to the Flex builder plugin in a standard Eclipse, you first need to install ant support. I didn't find ant separately packaged, so I just selected the Java build environment from Help / Software Updates.
Now you can go to your project properties (Right-Click on your Project, Properties) and chose Builders. You'll notice there is a Flex Builder per default, which you cannot remove nor change. However, you can deselect it and you can add other builders.
So in your case: "add" a new builder, ant builder, select a build.xml (can be named differently), preferably from within your project folder, and set the correct targets. This will continue to use the internal IDE builder while running your ant task just before or afterwards. The ordering on the screen will be the build order, which you can change using the arrow buttons.
I used this to copy required libraries into my /lib folder, compile the Flex sources using the IDE build (which has Eclipse-integration with error messages, which a pure ant-based commandline build would miss), and copy the result to a common deploy directory, renaming the wrapper html file in this process.
For details of how to write an ant file, please refer to the ant documentation.
I would also recommend using ant.
I posted a big article on how to get it set up for flexbuilder here http://dispatchevent.org/mims/ant-for-flex-part-1/ I think there is even an example in my build script of copying files from one place to another after compiling.
Good luck!
You'll have to create a custom build script. For whatever reason, the included, default 'builder' is not editable through the interface, so you'll have to replicate a lot of its functionality. Luckily, (or maybe not) Flex Builder uses Apache Ant for its build scripts, so this may or may not be a familiar way to do this for you.
To create a custom build script:
In the Flex Navigator view, select a project and then right-click (Control-click on Macintosh) to display the context menu and select Properties.
Select the Builders properties page. If you're using other Eclipse plug-ins, there may be more than one builder listed. Flex Builder provides a builder named Flex, which you cannot modify.
Select New.
In the Choose Configuration Type dialog box, select the appropriate configuration type. Flex Builder supports the program type. Select it and click OK to continue. From the new builder properties page you define the builder properties and reference the Ant script (an XML file).
Click OK to apply it to the project.
Flex builder is based on Eclipse 3.1, so documentation for Ant integration for that release is relevant here.
Note: Ant support must be enabled in Flex Builder first. I usually use Flex Builder as a plugin, rather than the standalone version, and the standalone version doesn't come with it out of the box. Here's a tutorial on how to do this.
Steve,
If you want use Ant in Flex Builder, you may see:http://www.peterelst.com/blog/2006/09/03/flex-builder-2-ant-support/
but I am not sure this is work in flex builder 3 or not.
Steve,
Here is a bit more detail on the post build script. It will be a simple bat file. For instance add the below line to a simple text file postbuild.bat (name doesn't matter).
copy bin/*.* 'someother location'
This would copy everything in the bin folder to another folder, just change the 'someother location'.
The least elegant solution but it will work on linux.
Create cron task to be executed every minute.
Use cp command with "-u" option.
From "man cp".
-u, --update
copy only when the SOURCE file is newer than the destination
file or when the destination file is missing
In crontab -e add
* * * * * cp -u /path/to/bin-debug/*.swf /path/to/destination/
For more elegant solution - Ant the way to go.

Resources