ActionScript and Adobe Flex Reload the Flex Application

Create an ActionScript function to reload a page that can be called from Adobe Flex / Flash.  This uses javascript to call a page reload.

private function reloadPage(event:Event):void
{
var ref:URLRequest = new URLRequest("javascript:location.reload(true)");
navigateToURL(ref, "_self");
}

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Ant Build from Eclipse - File Not Found Error

You might be thinking that getting Ant errors of a file not found on Windows is due to spaces in file names.

Actually, Ant and Eclipse are probably handling spaces on Windows fine, it’s the backslashes on Windows directories that are causing the problems.

Because Eclipse and Ant are Sun Java based, backslashes are interpreted as string literals, so a \g, might mean g, while a \n means a newline.

To get around this problem, simply double backslash encode your string.  So, for C:\Program Files\My Application\Test 1, change it to C:\\Program Files\\My Application\\Test 1\\.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Saving Excel Files in ActionScript and Flex

In saving to an Excel (xls) file from Adobe Flex / Flash using ActionScript code, make sure to include

import com.as3xls.xls.ExcelFile;
import com.as3xls.xls.Sheet;

Then, make sure to require Flash Player 10.0.0 or higher or the application will not build in Flex Builder 4.  Project->Properties->Flex Compiler -> Check Require Flash Player version: 10 0 0.

Wire your event listener appropriately.

var sheet:Sheet = new Sheet();
//  Set the size of the sheet.
sheet.resize(10, 10);
//  Add data to the sheet or loop over contents of grid.
sheet.setCell(1, 1, "Test");
var xls:ExcelFile = new ExcelFile();
xls.sheets.addItem(sheet);
var bytes:ByteArray = xls.saveToByteArray();
var saveFileRef:FileReference = new FileReference();
saveFileRef.save(bytes, "Report.xls");

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

File Uploader In Flex

This is a great example of a file uploader for Adobe Flex.  It’s in com.everythingflex.components.Uploader.mxml.

<?xml version=”1.0″ encoding=”utf-8″?>
<!– Authored by Rich Tretola (rich@richtretola.com) EverythingFlex.com
Feel free to use within your appplications.  Track changes at EverythingFlex.com

Sample Syntax:
<eFlexComponents:Uploader uploadButtonLabel=”Browse for New Image”
uploadToURL=”http://www.yourdomain.com/uploads/uploader.cfm”
imagesFilter=”*.jpg;*.gif;*.png”
displayNewImage=”true”
displayImagePath=”http://www.yourdomain.coms/uploads”
maxUploadSize=”100000″/>

–>
<mx:Canvas xmlns:mx=”http://www.adobe.com/2006/mxml” width=”100%” height=”100%”>
<mx:Script>
<![CDATA[
import mx.controls.Label;
import mx.controls.Alert;
import flash.net.FileFilter;
import flash.net.FileReference;
import flash.net.URLRequest;

private var uploadURL:URLRequest;
private var file:FileReference;

[Bindable]
public var uploadButtonLabel:String = “Browse for New Image”;
public var uploadToURL:String = “”;
public var imagesFilter:String = “*.jpg;*.gif;*.png”;
public var displayNewImage:Boolean = true;
public var displayImagePath:String = “”;
public var maxUploadSize:Number = 100000000;

public var fileName:String;

public function getFile():void {
if(this.uploadToURL.length > 0){
this.uploadURL = new URLRequest();
this.uploadURL.url = this.uploadToURL;
this.file = new FileReference();
this.configureListeners(file);
this.file.browse(new Array(new FileFilter(”Images”, this.imagesFilter)));
} else {
Alert.show(”uploadToURL is undefined”, “Syntax Error”);
}
}

private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
dispatcher.addEventListener(Event.SELECT, selectHandler);
}
private function selectHandler(event:Event):void {
this.file = FileReference(event.target);
this.fileName = file.name;
this.file.upload(uploadURL);
this.uploadButton.visible = false;
this.progressBar.visible = true;
}
private function completeHandler(event:Event):void {
if(this.displayImagePath.length > 0 && this.displayNewImage == true){
this.newImage.source = this.displayImagePath+’/'+this.fileName;
this.BTN_fileDownload.label = “Try Download”;
this.BTN_fileDownload.visible = true;
this.fileDownloadsuccess.text = “Successfully Uploaded”;
this.fileDownload.text = this.fileName;
this.fileDownloadurl.text = this.displayImagePath+’/'+this.fileName;
/*var u:URLRequest = new URLRequest(”{this.displayImagePath+’/'+this.fileName}”);
this.BTN_fileDownload.change =”navigateToURL(u,’_self’)” */
}
this.progressBar.visible = false;
this.uploadButton.visible = true;
}
private function progressHandler(event:ProgressEvent):void {
if(event.bytesTotal > this.maxUploadSize){
this.cancelUpload();
Alert.show(”Max size allowed: ” + this.maxUploadSize + ” bytes. \nYour file is ” + event.bytesTotal + ” bytes”, “Upload cancelled, File too large”);
} else {
this.progressBar.setProgress(event.bytesLoaded,event.bytesTotal);
this.progressBar.label = event.bytesLoaded + ” of ” + event.bytesTotal + ” bytes loaded”;
}
}
private function ioErrorHandler(event:IOErrorEvent):void {
Alert.show(”ioErrorHandler: ” + event, “IO Error”);
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
Alert.show(”securityErrorHandler: ” + event, “Security Error”);
}
private function cancelUpload():void{
this.file.cancel();
this.progressBar.visible = false;
this.uploadButton.visible = true;
}
private function linkTo():void{
var linkurl:URLRequest = new URLRequest(this.fileDownloadurl.text);
navigateToURL(linkurl,”_self”);
}
]]>
</mx:Script>
<mx:Button id=”uploadButton” click=”this.getFile()” label=”{this.uploadButtonLabel}” visible=”true” />

<mx:ProgressBar width=”200″ id=”progressBar” mode=”manual” visible=”false”/>

<mx:VBox x=”10″ y=”30″>
<mx:Image id=”newImage” visible=”false”/>
<mx:Text id=”fileDownloadsuccess”/>
<mx:Text id=”fileDownload”/>
<mx:Text id=”fileDownloadurl”/>
<mx:Button id=”BTN_fileDownload” visible=”false” label=”Download” click=”linkTo()”/>
</mx:VBox>

</mx:Canvas>

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Crossdomain.xml file for ColdFusion

If you’re getting an error like “Security error accessing url” from Flex, try editing the crossdomain.xml file in ColdFusion.  For a non-production, global access quick test to see if this solves your problem try the following.

Adobe ColdFusion Cross-Domain File for Global Access

This cross domain file allows any connection to CFC’s.

crossdomain.xml

<?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="*.nasa.gov" to-ports="*" />
</cross-domain-policy>

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Cool Flex 3d Rotating Effects

Image to Ascii:

http://livedocs.adobe.com/flex/3/html/help.html?content=09_Working_with_Strings_11.html

Cool Adobe Flash / Flex 3D Graphics Effects

http://blog.flexexamples.com/2008/10/25/incrementally-3d-rotating-objects-in-flex-using-the-fxrotate3d-in-flex/

http://help.adobe.com/en_US/flex/using/WSF0D55C84-17E0-456a-A977-04BFE1E23BA8.html

http://www.selikoff.net/2010/03/17/solution-to-flex-image-rotation-and-flipping-around-center/

http://www.joelconnett.com/flex-rotation-around-a-point.html

http://lucamezzalira.com/2008/02/07/little-tricks-to-rotate-images-in-flex/

Matrix based image manipulation:

http://insideria.com/2008/03/image-manipulation-in-flex.html

http://blog.flexexamples.com/2007/09/14/rotating-images-using-the-matrix-class/

Other:

http://www.bjw.co.nz/developer/flex/86-flex-3-rotating-image-script

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

MH’s Birthday

Mary-Helen’s 40th Birthday!

We went to the museum in the morning, then for dinner we met family and friends at Churrascos on Westheimer to celebrate her birthday.  Megan had sent a cake and I took that with us to Churrascos and they served it for free.  We had a great dinner!  People who came included Grand D, Mom, Doug, Cas, Evan and Allison, Sarah and Leo with Jamie and Connor, Gerald and Amita, Yael, and Dana.  The restaurant gave us a room and Alden, Jamie, and Connor had fun playing.  We got to sing a big happy birthday and the restaurant brought out her cake and cut it for us.  We got some tres leches to go.

Alden went to stay in Industry and Mary-Helen and I went down to Galveston.  We got there about 9pm and checked into our room at the Galvez Resort.  We kept the extra cake on ice.  We had room service for breakfast which was very yummy.   It was a lot of food for a bread and cereal fruit order and then an all american breakfast, which we split.  We then walked on the seawall and on the beach.  I got some new cheap sunglasses, and I could finally see.  Then we scheduled brunch for Sunday and got changed into bathing suits.  We went down to the pool bar and had a beer and pina colada.  We ordered lunch from there and hung out until after 3pm and took a nap.

Next we drove down to the strand and wandered about for a bit.  We went to the Olympia Grill for dinner at the Galveston Harbor and it was really yummy!  We split a sampler platter and MH tried some of their wine.  We headed back and crashed early.

Sunday morning brunch at the Galvez was something else!  It was fantastic.  We had juice, mimosas, coffee, omelets, fresh boiled crab and shrimp, waffles and more.  I definitely want to do it again!

We then headed to Industry to pick up the kids.  They had a good weekend.  We all were tired and went home to rest.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Museum and Imax

On Friday the 30th Mary-Helen, Alden, Meredith and I had a lazy morning and made breakfast.  We met up with Grand D. and went down to the Houston Museum of Natural Science.  We met at the Houston house and then went from there.

We saw the Hubble 3-D Imax film, it was great!  Alden got a little bored toward the end, but he liked it.

Next we went to see the Magic exhibit and got to see a real magician.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

American Pale Ale - 1

This beer looks good.  Just finished the original brewing.  We’ll see how this beer turns out.  My OG 1.054.  Try it in a 5-6 weeks!
AMERICAN PALE ALE
Effervescent, light amber tint, floral hop bite
6 lbs. light malt extract

1 1/2 lb. pale malt
1/2 lb. cara-pils malt
1/2 lb. medium crystal malt
1 oz. Centennial or Perle hops (bittering)
1/2 oz. Cascades hops (flavoring)
1/2 oz. Cascades hops (finishing)
1 pkg. Burton water salts
3/4 cup corn sugar (for priming)
1 pkg. White Labs California or California V Ale yeast
1 pkg. Bru-Vigor (yeast food)
O.G. - 1.050
F.G. - 1.012

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Change SVN Revision Properties on Windows Machine

Suppose you’ve made a wrong comment on an SVN commit and now you wish to change it.  You are using Windows or your SVN server is on a Windows based machine.

To fix an SVN error message, use the following command:

svn propset svn:log –revprop  -r <revision#>  ”<Corrected Message>” <URL>

example:

C:\src>svn propset svn:log –revprop -r 393 “Reverted to revision 350″ file:///T:/SVN_Repositories/R

Whoops, you might get the error message:
svn: Repository has not been enabled to accept revision propchanges;
ask the administrator to create a pre-revprop-change hook

This means that you don’t have administrator access or the pre-revprop-change hook has not been created.

If you have admin access you can create a hook.  Simply go to the repository directory on the URL of the server, in this case T:\SVN_Repositories\R

Then find the hooks directory, and create a file

pre-revprop-change.bat

Add contents:

@ECHO OFF

SET REPOS=%1
SET REV=%2
SET USER=%3
SET PROPNAME=%4
SET ACTION=%5

REM ECHO %REPOS% %REV% %USER% %PROPNAME% %ACTION%

REM IF “%ACTION% %PROPNAME%”==”M svn:log” EXIT /B 0

ECHO “Changing revision properties other than svn:log is prohibited” >&2

EXIT /b 1

Now the svn revprop command should work!

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • MySpace
  • Turn this article into a PDF!
  • Reddit
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz