Friday, November 21, 2008

Easy way to handle form in Flex 3

The easiest way I've found to post a form is to use the HTTPService tag with a method="post".

Here's the HTTPService tag (and some email validation as well) Note the code embedding tags I'm using mess this up. The EmailValidator should be closed before the HTTPService call.







{fullName.text}


{email.text}


{comment.text}







Here's the form. Again the embedder adds three closing formitem tags that shouldn't be there.























And here's the script. This validates that the email address isn't empty and pops up an alert message saying the form has been submitted. Then it clears out the fields.





import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;

public function resultHandler(event:ResultEvent):void
{

if (email.text == "")
{
mx.controls.Alert.show("Please enter an email address")
} else
{
mx.controls.Alert.show("Thank you. Your information has been sent.");
fullName.text = "";
email.text = "";
comment.text = "";
}
}
]]>


My second Flex site



My second flex site.
Much more use of data - and again a full ColdFusion cms

You can see it live at http://www.decorativeartstrust.com

My first Flex website



You can see it live at http://www.eastmemphisallergy.com

The site has a full content management system in ColdFusion

Easy way to pull text file into Flex 3

Super easy!
Just call a service with GET and specify the resultFormat as text.





Then, in your script tag make a bindable variable and assign the value of the service call to the variable



import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;

[Bindable]
public var myTextVariable:String;

public function txtHandler(event:ResultEvent):void
{
myTextVariable = myTextService.lastResult.toString();
}
]]>



Then bind your variable to your text field





Finally, don't forget to call your service from your application tag.

creationComplete="myTextService.send()"

Hand Cursor

Okay - I know this is simple, but I keep forgetting the right combination to make a hand cursor appear on an object.

useHandCursor = true;
mouseChildren = false;
buttonMode = true;