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;

Thursday, October 23, 2008

Accessing Variables

You know, I'm just learning blind here so there may be a better way to do this... but was trying to access data pulled in from a remote object in the application (master page) from a component page. It turned out to be very easy.



In the master page make your variable bindable and public


[Bindable]
public var myFooter:String;


Then in your component page, import the application scope





import mx.core.Application;
]>




Then to spit it out, you can bind to the variable through your Application scope:




Friday, October 17, 2008

Type Coercion failed: cannot convert flash.events

I ran into this error while trying to insert an img tag into the htmlText field of a flex mx:text tag. The solution is very simple - you have to include the width and height properties in your img tag.

Tuesday, September 9, 2008

RSS feeds

I admit, I'm stubborn. That's probably why most of the time I can work my way through problems. But no matter what I try, I can't pull an rss feed from a third party (no access to their server) into Flex.

I guess I could pull it into a ColdFusion page on my server with an HTTP request, and then pull it into Flex, but it seems like there ought to be a way in Flex to do that.

Anyone?

Monday, September 8, 2008

Posting Source Code on Blogger

Here's a helpful post if you want to post your source code on blogger
http://pleasemakeanote.blogspot.com/2008/06/posting-source-code-in-blogger.html

Flex - Passing Form Data through HTTPS

I kept getting errors trying to pass a Flex form through HTTPS.
The whole key to the problem was a crossdomain.xml file.
You must put secure="false" on your domain or it won't work.



SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">






The wording secure="false" bothers me though. Doesn't that defeat the whole purpose of running it through HTTPS in the first place? Or does secure="false" mean something else?
Can someone enlighten me?

Passing Date Object to CF

I must preface my first post with this disclaimer:
I am not a programmer, I just play one online.

While building my second Flex app, I had a problem passing the date object to coldfusion with HTTPservice. It passed fine when I left it alone, but when I tried to format it with CF using DateFormat, it gave me the year 2000 instead of 2008.

After a bit of trial and error, I found that if I change the date to a string in Flex, then I can format it using DateFormat in CF.

So in Flex:
var myDate:String = myDate.selectedDate as String;

And in CF:
#DateFormat(myDate, "mmm dd, yyyy")#

I would really like to know why it works this way, so if any of you "programmers" out there can shed some light on it, I would be most appreciative.