Wednesday, July 22, 2009

CFSELECT Validation

There is a very easy way to force a selection on a select box.
All you have to do is edit a tiny bit of code.

If you have access to your CFIDE/scripts folder, just edit your cfform.js file directly. But if you are on a shared host, there is a simple fix.

First copy your cfform.js file to anywhere on your site. We'll copy it to our webroot/js folder for this example.

Then, if you are using CF8 edit line 59 from this:


if(_b.options[i].selected) {



To this:


if(_b.options[i].selected && _b.options[i].value != "") {



Then you simply have to point your form to use the new cfform.js file. You do that very easily with the scriptsrc attribute of the cfform tag, like this:


<cfform scriptsrc="webroot/js/cfform.js">



Finally, on the cfselect boxes you want to validate, you add a blank option and make the cfselect required.


<cfselect name="mySelect" query="myQuery" display="myField" value="myID" queryPosition="below" required="yes" message="You must choose this field.">
<option value="" selected><option>
</cfselect>



And that's it!
It took me some digging to figure this out, but now that I found it it's very simple and straightforward.

Sunday, March 22, 2009

Eclipse 3.4.2 and Windows Vista 64 Don't Play Well Together

I got a new laptop. I really debated switching to Vista. I've played it safe with XP Pro for a long time, but I thought I might as well get on the bandwagon.
For the most part the transition has been okay.
There have been some quirks. One that was interesting was in Flex Builder 3. If I want to see the build path, I have to pull the window closed as far as possible, click on resources, and then pull it out again to be able to see the path.
But today, I tried to install Eclipse with CFEclipse. Total nightmare! The new 3.4.2 version of Eclipse will not let me install CFEclipse. From what I can tell, it's a Windows 64 issue.
I ended up having to go find my older version of Eclipse (using Europa 3.3.2) and had to find the old Coldfusion_extensions_for_Eclipse.zip file and install it that way. So far it works, but I'll keep my figures crossed just in case!

Wednesday, March 11, 2009

Another Flex site

I forgot to add this to the Blog.
It was finished before the start of the new year.

Really fun! Uses drag and drop and lots of data interaction:

http://www.athenseagles79.com

Scrolling page in html

I always encounter this problem when embedding flex into an html page: the page won't scroll.
Flex builder adds scroll="no" to the body tag,
and adds overflow="hidden" to the style attribute to the body tag in the head.

Remove both and your page will scroll.

;)

Tuesday, February 24, 2009

Using a Flash Component in Flex

There's not a lot of documentation on creating components for Flex in Flash, but it's fairly simple to do.

Prerequisites: CS3, Flex Component Kit for CS3 installed
Basic Steps: Create Flash movieclip (put the movieclip on frame 1 of your main timeline) then click on Commands/Convert Symbol to Flex Component and publish.
Flash will publish a swc file.
Your new Flex component will have the name of your movieclip and will be part of the mx.flash.IUMovieClip base class

In Flex, copy the swc into your libs folder
Then you can reference your new component from within Flex by it's class name (name of MovieClip)
note: new component must have x and y set and be in an absolute container.

With that, you can now control the timeline - play(); stop(); gotoAndPlay();
var myFlashComp:myFlashComp = new myFlashComp();
myFlashComp.x = 0;
myFlashComp.y = 0;
addChild(myFlashComp);
myFlashComp.gotoAndPlay(50);

If you want to reference other things in your movieclip, like maybe a dynamic text field, you need to create an actionscript class by the same name as the movieclip and import the flash.text.TextField

Wednesday, February 18, 2009

Procrastination Surfing

Okay, someone needs to come up with a clever name for this syndrome.
It happens to me all the time. I have tons of work I need to be doing, but instead of tackling it, I will start procrastination surfing.
It always happens when I have something that I dread doing. It's almost a sickness... like I can't help myself. I must surf the web, instead of doing my work.

I could even argue that I'm posting to this blog to procrastinate. Hmmm... I wonder if this is like AA and if I admit I have a problem, it is the beginning of the recovery?

Tuesday, February 10, 2009

ColdFusion Dreamweaver Sharing Violation

Okay, this has frustrated me too many times. Too often I forget what to do and have to google FOREVER to find the answer again, so I thought I'd post it where I can't miss it.

I have CF8 developer edition, Windows XP and have the full suite of Adobe CS3 installed. Often in Dreamweaver, I'll get a "sharing violation" error has occurred which prevents me from saving the file.

The solution: open the ColdFusion Administrator and set the Server Settings/Caching/Maximum number of cached queries to 0. Viola - now you can save!

Update! I recently switched to Windows Vista Home Premium and was having the same issue. I was clearing the cache, unchecking save class files in the CF8 administrator and it still wasn't working. I was only having this problem when trying to save .html files in a Dreamweaver site set up with a Coldfusion server. Once I saved the file with a .cfm extension the problem went away.

Friday, January 16, 2009

Random Number Function

comment posted By Till Schneidereit on Digital Primates


function randRange3 (start:Number, end:Number) : Number
{
return Math.floor(start +(Math.random() * (end - start)));
}

Wednesday, January 7, 2009

New Flex Site



http://www.aircompinc.com/aircompinc.html

This one has some nice page transitions.

Flex Date Formatting

There are lots of different ways to format Dates in Flex.




or you can format on the fly.
In this example I am pulling the data in a RemoteObject and outputting to a TileList/ItemRenderer/Component text field.