ColdFusion Muse

Coldfusion Flash Forms Limitation Too Draconian (film at 11:00)

You probably know that when you use flash forms in Coldfusion MX 7 you are not allowed to use the word "new" in any of the actionscript event handlers you choose to create. For example, you could not write "myvar = new Object();" in your actionscript. If you tried, you would get a message saying that it was an "illegal use of actionscript". What you may not know is that you cannot even use the "new" keyword as a string!

In this example from Tyler Clendenin on CF-Talk he is trying to rebuild an array drop-down based on selections in a different nearby drop down list. He's looping through the data and adding it to the drop down.

subArray.push('New York');

Believe it or not, this code throws the "illegal use of Actionscript" error - even though the word "new" is clearly not being used as a code keyword. It gets better. According to Ryan Guill, even if you try and use it in a label it will error out - as in the following.

..... label="use new somethingorother" />
According to the always knowledgeable Barney Boisvert, a workaround is to concatenate any key word inline as in:
subArray.push("Ne" + "w York");
This seems quirky and irritating. I should think the compiler would be smart enough to differentiate a string from a keyword in use inside the syntax. It seems to me that the limitations imposed on the flex engine were not well planned. The thread on CF-Talk is titled "what were they thinking". In my view, it is aptly named.

Todd's Gravatar It only took me about an hour of banging my head against the wall to figure this out the first time I ran acrossed it. There are other 'dirty' words too, like delete...Don't know why that's forbidden, but it wouldn't work when I tried it in a label.
# Posted By Todd | 8/29/05 6:19 PM
mark's Gravatar Todd - I know what you mean. The docs are clear that they are reserved words, but it doesn't follow that they should be disallowed in variables (sigh). I think flash forms 1.0 shows promise, but it also leaves much to be desired eh?
# Posted By mark | 8/29/05 6:55 PM
Ryan Guill's Gravatar Hey Mark, not really a big deal, but my last name is spelt Guill. Thanks for this solution though, that will work great.
# Posted By Ryan Guill | 8/29/05 8:07 PM
Mark's Gravatar Ryan - right. sorry. I fixed that.
# Posted By Mark | 8/29/05 8:15 PM
Ryan Guill's Gravatar no big deal ;)
# Posted By Ryan Guill | 8/29/05 9:11 PM
Justin Cook's Gravatar Here's a fix to this problem from Laura of taken from our original emails::::

How you did that is not recommended (will cause recompiling of the form every time that value changes), however, I see why you did it that way. Now, to avoid that... the cleanest way is to use an extra hidden field to store the original value and then use it in the bind: bind="{sameAddress.selected ? subscriberEdit.bCity : myFormName.MyHiddenField}"

Otherwise use a hack (not recommended)
bind="{sameAddress.selected ? subscriberEdit.bCity : remoteObject_myFormName.getData.result['sCity']}" value="#qExample.cityName#"

Hope that helps,

Justin Cook wrote:

I think it has to do with this particular code:

<cfinput name="sCity" type="text" width="150" maxlength="50" required="yes" validateat="onsubmit" message="Please provide the subscriber's city." label="City: " bind="{sameAddress.selected ? subscriberEdit.bCity : '#qSubscriber.sCity#'}"/>

I have the bind because there's the option of having the same address on business and shipping. How can I change this and it still work?
# Posted By Justin Cook | 8/11/06 7:52 AM

Blog provided and hosted by CF Webtools. Blog Sofware by Ray Camden.