|
|
ActionScript 2 in ColdFusion MX 7 |
| by Niklas Richardson 12:07 pm Thursday, 3 March 2005. |
So, if you’re already started using the Flash Forms in CFMX 7 and you are writing AS2 (ActionScript2) in some of the Form controls to do more advanced “stuff”, then you’re probably getting tired of writing all your AS2 in one line in the onChange=”", etc… attributes.
I’ve been using a small little trick to get around the unreadability of writing your AS2 code in one line by using CFSAVECONTENT.
Here’s a snippet:
<cfsavecontent variable="actionscript">
if (actionslist.dataProvider.length == 1 && actionslist.dataProvider[0]['Action'] == null)
{
var gridPos = 0;
}
else
{
GridData.insertRow(actionslist);
var gridPos = actionslist.selectedIndex;
}
actionslist.dataProvider.editField(gridPos, 'Action', action.text);
actionslist.dataProvider.editField(gridPos, 'ActionByWhom', actionbywhom.text);
if (clientagreed.selected == true)
actionslist.dataProvider.editField(gridPos, 'ClientAgreed', 'Yes');
else
actionslist.dataProvider.editField(gridPos, 'ClientAgreed', 'No');
actionslist.dataProvider.editField(gridPos, 'ClientNotes', actionnotes.text);
</cfsavecontent>
I then just do the following in my CF tags:
<cfinput type="button" name="AddAction" value="Add Action" visible="Yes" enabled="Yes" onclick="#actionscript#"/>
I love this technique as it’s like my own little script block for ActionScript, and I dont’ have to cram all my AS onto one line! Yikes!
Enjoy!
RSS feed for comments on this post. TrackBack URL
Nik,
This is way cool. It is much more readable than that single line trick. I guess what I would like to see is a page listing all of the things you can and can’t do in CFMX7 vs. Flex. That would be a very good resource.
I’m sure it is being done somewhere, maybe I’ll ask Flexcoders.
Comment by Al — Thursday, 10 March 2005 @ 9:21 am
When I try this trick no form appears. A cfdump of #actionscript# shows [empty string].
What am I doing wrong?
Thanks
Comment by Mark Ireland — Tuesday, 2 August 2005 @ 2:00 am
Hi Mark,
Could you explain a bit more in detail your problem?
Regards
Niklas
Comment by Niklas — Wednesday, 10 August 2005 @ 11:56 am
Hi Niklas
I’ve just started messing around with flash forms. My question is how do you inspect variables in the middle of an ActionScript block?
To take your example above, if I was unsure about the value of ‘gridPos’ at any point, and this was pure CF, I’d just cfdump it to the screen. Is there some way of doing the equivalent in AS?
Michael
Comment by Michael — Thursday, 18 December 2008 @ 3:00 pm