Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

Can't get to Max, don't miss online Keynote

After admitting I had a little Adobe Max jealousy @ryanstewart DM'd me to let me know you can catch the keynote online. All you have to do is register at http://max.adobe.com/online/keynotes/

Actually, after a little digging around Ryan even posted about this yesterday.

Comments Comments (0) | Print Print | Send Send | 219 Views

My blog has moved

Please update your bookmarks and feeds for my site.

I now have a Mango Blog at:

http://www.andyjarrett.com/blog

Feed URL: http://feeds.feedburner.com/andyjarrett

Comments Comments (0) | Print Print | Send Send | 1196 Views

Batch Processing word docs to FlashPaper

Recently for work I have had to convert quite a few word docs to the FlashPaper format.

Realising how long this would take I looked into an undocumented feature of the FlashPrinter.exe of calling it from the command line and passing the required arguments.

You can easily take my code and get any language like Java or even Ant to do the following.

The command you need to run is:

view plain print about
1FlashPrinter.exe {PATH TO DOCUMENT} -o {OUTPUT PATH & FILE with SWF extention}

All the CF code below does is filter on the directory query looking for word documents. If you have any changes or suggestions contace me here

view plain print about
1<!--- Path to Flash Paper exe --->
2    <cfset flashPrinter = "C:\Program Files\Macromedia\FlashPaper 2\FlashPrinter.exe">
3    <!--- Path to documents --->
4    <cfset originalPath = expandPath(".") />
5    <!--- Can be either doc|pdf --->
6    <cfset filter = "doc">
7    
8    <!--- Path to the exported swf's' --->
9    <cfset outputPath = expandPath(".") />
10    
11    <!--- get a query list of all the fiels --->
12    <cfdirectory action="list" name="qry" directory="#originalPath#" filter="*.#filter#" />
13    
14    <cfoutput>
15        <cfloop query="qry">
16            <cfset fileLoc = qry.directory&"\"&qry.name />
17            <cfset outputFile = outputPath & "\" & replace(qry.name, ".#filter#", ".swf")>
18            
19            <!--- Set the arguments to be passed to CFEXECUTE --->
20            <cfset args = '"#flashPrinter#" "#fileLoc#" -o "#outputFile#"' />
21            
22            <!--- Output the args to the screen to see what got passed --->    
23            #args#
24            <hr/>
25            <!--- Use the command line to execute the function --->
26            <cfexecute name = "#flashPrinter#"
27             arguments = "#args#">

28            </cfexecute>
29            
30        </cfloop>
31    </cfoutput>

Comments Comments (3) | Print Print | Send Send | 3649 Views

Fridays Joke: Bottle of scotch

The first post of 2008 is here and its a joke, of course. Hope everyone had a good christmas/holiday. Enjoy the first of many Fridays of the year!

A fellow decides to take off early from work and go drinking. He stays until the bar closes at three in the morning, at which time he is extremely pissed. After leaving the bar, he walks home. When he enters his house, he doesn't want to wake his wife, so he takes off his shoes and starts tip-toeing up the stairs. Half-way up the stairs though, he falls over backwards and lands flat on his back. That wouldn't have been so bad, except that he had a half bottle of scotch in his back pocket, and it broke; the broken glass carved up his ass terribly. Yet, he was so drunk that he didn't know he was hurt.

A few minutes later, as he was undressing, he noticed blood, so he checked himself out in the mirror, and, sure enough, his ass was cut up terribly. He then repaired the damage as best he could under the circumstances, and went to bed.

The next morning, his head was hurting, his back was hurting, and he was hunkering under the covers trying to think up some good story, when his wife came into the bedroom.

"Well, you really tied one on last night," she said. "Where'd you go?"

"I worked late," he said, "and I stopped off for a couple of beers."

"A couple of beers? That's a laugh," she replied. "You got pissed last night. Where did you go?"

"What makes you so sure I got drunk last night, anyway?"

"Well," she replied, "my first big clue was when I got up this morning and found a bunch of plasters stuck on the mirror."

Comments Comments (4) | Print Print | Send Send | 3288 Views

Populating related cfselects via Flash Remoting

First of let me say that as much as I would love this to be my code it mainly comes out of two posts [1,2] on ASFusion.com.

To sidetrack for a moment, I must point out now is that even if you don't find answers in the Asfusion posts always check the comments out! They get up to 50+ comments on some posts with hints and tips there as well.

Back to the form. I had a project which started life as a 5 page HTML form with the need to make it a little user friendly to the eyes and more organised. Any form over 2 pages I hate in general and I seem to be the only person in the world who thinks one long page is better than X amount of multiple pages this is whether i'm filling them in or creating them.

In moving my HTML form over to <cfform format="flash"> I ran into the problem of having to duplicate some Ajax where one select is populated from a DB then another select is populated from there. It didn't take too much digging around and I thought i'd share in case it helps anyone else out. My Flash/As knowledge isn't 100% so if you see an easier way drop me a line in the comments.

First of the CFC

flashRemotingResponder.cfc

view plain print about
1<cfcomponent name="flashRemotingResponder" access="public" description="Responds to Flash remoting requests">
2
3<cffunction name="getBrands" output="false" access="remote" returntype="query">
4                    
5    <cfset var qry = ""/>
6    <cfset var brandQry = queryNew("brand_code,brand_name") />
7
8    <cfscript>
9        queryAddRow(brandQry);
10            querySetCell(brandQry,'brand_code','dell');
11            querySetCell(brandQry,'brand_name','Dell');
12        queryAddRow(brandQry);
13            querySetCell(brandQry,'brand_code','apple');
14            querySetCell(brandQry,'brand_name','Apple Inc.');
15        queryAddRow(brandQry);
16            querySetCell(brandQry,'brand_code','microsoft');
17            querySetCell(brandQry,'brand_name','Microsoft Corp.');                        
18    
</cfscript>
19                    
20    <cfquery dbtype="query" name="qry">
21        SELECT
22         brand_code, brand_name
23        FROM brandQry
24    </cfquery>
25
26    <cfreturn qry />
27</cffunction>
28
29
30<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --->
31<cffunction name="getModels" access="remote" output="false" returntype="query">
32    <cfargument name="brand" type="string" />
33    
34    <cfset var qry = ""/>
35    <cfset var modelQry = queryNew("model_number,model_description,brand_code") />
36    <cfset var brand_code = arguments.brand />
37
38    <cfscript>
39        queryAddRow(modelQry);
40            querySetCell(modelQry,'model_number','123-qwe');
41            querySetCell(modelQry,'model_description','Apple Mac Book Pro 15.4"');
42            querySetCell(modelQry,'
brand_code','apple');
43        queryAddRow(modelQry);
44            querySetCell(modelQry,'
model_number','987123-123');
45            querySetCell(modelQry,'
model_description','Apple Mac Book Pro 17"');
46            querySetCell(modelQry,'brand_code','apple');
47        queryAddRow(modelQry);
48            querySetCell(modelQry,'model_number','asdpo-1232');
49            querySetCell(modelQry,'model_description','Apple 72" Monitor');
50            querySetCell(modelQry,'
brand_code','apple');
51        queryAddRow(modelQry);
52            querySetCell(modelQry,'
model_number','d123');
53            querySetCell(modelQry,'
model_description','XPS Mobile Gaming Laptop');
54            querySetCell(modelQry,'
brand_code','dell');
55        queryAddRow(modelQry);
56            querySetCell(modelQry,'
model_number','d6534');
57            querySetCell(modelQry,'
model_description','64" Monitor');
58            querySetCell(modelQry,'brand_code','dell');
59        queryAddRow(modelQry);
60            querySetCell(modelQry,'model_number','123-mqwe');
61            querySetCell(modelQry,'model_description','DRM removal tool');
62            querySetCell(modelQry,'brand_code','microsoft');
63        queryAddRow(modelQry);
64            querySetCell(modelQry,'model_number','123-serr');
65            querySetCell(modelQry,'model_description','Windows Vista inc. SP4');
66            querySetCell(modelQry,'brand_code','microsoft');                
67
</cfscript>
68
69
70    <cfquery dbtype="query" name="qry">
71        SELECT
72            model_number,
73            model_description
74        FROM
75            modelQry
76        WHERE
77            brand_code = <cfqueryparam cfsqltype="cf_sql_varchar" value="#brand_code#" />
78    </cfquery>
79    
80    <cfreturn qry/>
81</cffunction>
82
83</cfcomponent>

Second the action <cfform>

flashRemoting.cfm

view plain print about
1<!--- These queries are copied from you flashRemotingResponder.cfc --->
2<cfset brandQry = queryNew("brand_code,brand_name") />
3<cfset modelQry = queryNew("model_number,model_description,brand_code") />
4
5
6
7
8<cfsavecontent variable="getBrands">
9    <cfoutput>
10        //create connection
11        var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/");
12        //declare service
13        var myService:mx.remoting.NetServiceProxy;
14    </cfoutput>
15
16    var responseHandler = {};
17
18    //put the controls in scope to avoid calling _root
19    var brand = brand;
20    
21    responseHandler.onResult = function( results: Object ):Void {
22        //when results are back, populate the cfselect
23        brand.labelField = "brand_name";
24        brand.dataProvider = results;
25    }
26
27    responseHandler.onStatus = function( stat: Object ):Void {
28        //if there is any error, show an alert
29        alert("Error while calling cfc:" + stat.description);
30    }
31    
32    //get service
33    myService = connection.getService("flashRemotingResponder", responseHandler );
34    //make call
35    myService.getBrands();
36</cfsavecontent>
37
38<cfsavecontent variable="getModel">
39    <cfoutput>
40        //create connection
41        var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/");
42        //declare service
43        var myService:mx.remoting.NetServiceProxy;
44    </cfoutput>
45
46    var responseHandler = {};
47
48    //put the controls in scope to avoid calling _root
49    var model = model;
50    
51    responseHandler.onResult = function( results: Object ):Void {
52        //when results are back, populate the cfselect
53        model.labelField = "model_description";
54        model.dataProvider = results;
55    }
56
57    responseHandler.onStatus = function( stat: Object ):Void {
58        //if there is any error, show an alert
59        alert(stat.description);
60    }
61    
62    //get service
63    myService = connection.getService("flashRemotingResponder", responseHandler );
64    //make call
65    myService.getModels(brand.selectedItem.brand_code);
66</cfsavecontent>
67
68<cfform format="flash" name="myform" onload="#getBrands#" width="500" height="400">
69
70    <cfformgroup type="panel" label="Example of flash remoting and dynamically populating cfselect">
71        <cfselect name="brand" id="brand" query="brandQry" display="brand_name"
72            value="brand_code" onchange="#getModel#" label="What is the brand name">
</cfselect>
73    
74        <cfselect name="model" id="model" query="modelQry" display="model_description"
75            value="model_number" label="What Model Number">
</cfselect>
76    </cfformgroup>
77</cfform>

You can download the source at: http://www.andyjarrett.co.uk/flash_remoting_populate_select.zip

Comments Comments (3) | Print Print | Send Send | 3767 Views

Visible attribute and the gap left in Flash forms

The visible attribute and the gap left in Flash forms

First of thanks to Kelly Keith to actually putting me onto this solution after my post to CF-Talk about removing the gap left in when you set an item like visibilites to hidden. To quote Kelly direct the short answer is "When visible is set to false set the height to a negative number."

Below I've got three examples of problem, the solution and an event driven solution.

1. This first exaple is a example of the visible gap left by setting visible to false

view plain print about
1<cfform format="flash" action="#cgi.script_name#" name="form1">
2    <cfformitem type="text">Form 1</cfformitem>
3    <cfformgroup type="panel" label="top panel" visible="false">
4        <cfformitem type="html">Panel 1</cfformitem>
5    </cfformgroup>
6    <cfformgroup type="panel" label="bottom panel">
7        <cfformitem type="html">
8            You'll notice the gap above this "panel" left by the first hidden panel
9        </cfformitem>
10    </cfformgroup>
11
12</cfform>

2. Below I have put in place Kelly's suggestion which resolves the whitespace

view plain print about
1<cfform format="flash" action="#cgi.script_name#" name="form2">
2    <cfformitem type="text">Form 2</cfformitem>
3    <cfformgroup type="panel" label="top panel" visible="false" height="-1">
4        <cfformitem type="html">Panel 1</cfformitem>
5    </cfformgroup>
6    <cfformgroup type="panel" label="bottom panel">
7        <cfformitem type="html">
8            You'll notice the gap is now removed. This is done by setting a negative height e.g.
9            <br><br>
10            <cfformgroup type="panel" label="top panel" visible="false" height="-1">
11        </cfformitem>
12    </cfformgroup>
13</cfform>

3. The final bit of code uses some basic Actionscipt to remove on a onClick event to hide/show the panel along with setting the height

view plain print about
1<cfform format="flash" action="#cgi.script_name#" name="form3">
2
3    <cfformitem type="script">
4        function hidePanel(){
5            _root.pan1.visible = false;
6            _root.pan1.height = -1;
7        }
8        function showPanel(){
9            _root.pan1.visible = true;
10            _root.pan1.height = 100;
11        }
12
13    </cfformitem>
14
15    <cfformitem type="text">Form 3</cfformitem>
16    <cfformgroup type="panel" label="top panel" id="pan1">
17        <cfformitem type="html">Panel 1</cfformitem>
18    </cfformgroup>
19    <cfformgroup type="panel" label="bottom panel">
20        <cfformitem type="html">
21            Bottom Panel
22        </cfformitem>
23    </cfformgroup>
24
25    <cfformgroup type="horizontal">
26        <cfinput type="button" name="hideBtn" id="hideBtn" value="Hide Top Panel" onclick="hidePanel()" />
27        <cfinput type="button" name="showBtn" id="showBtn" value="Show Top Panel" onclick="showPanel()" />
28    </cfformgroup>
29</cfform>

If you are working with Flash Forms I gotta say check out AsFusion.com. I've been working on a few rather complex forms which has meant even replicating some Ajax functionality via Flash Remoting all of which I've got from there. I'll try and blog about that soon.

Comments Comments (6) | Print Print | Send Send | 4478 Views

Flex 2 for CF developers by Ben Forta

I finally managed to get myself to London again for the Ben Forta presents on Flex 2 for ColdFusion Developers presentation, and as usual it answered lots of questions and I think amazed quite a few people. The PowerPoint slides should be available soon on the UKCFUG site, and the code demo'd is available at http://labs.macromedia.com/. So what came out of it:

  1. Beta 2 is coming any day - it was actually out on the day of the presentation!
  2. The pricing has been a major factor in this release, after all the posts and messages last time Adobe have focused on price. To prove this you can actually develop Flex apps for Free by creating the MXML in an editor of you choice and compile it using the freely available Flex Framework and SDK
  3. Support for Mac is coming, though there is no official news on Mac-Intel
  4. Flex apps 2 are 100's of time faster on the initial load then Flex 1. If anyone who saw the Pre Flex 1 presentations, or experimented with it will remember how slow a simple hello world app would take to start.
  5. Flash 8.5 was actually rewritten to improve speed and is not compatiable with previous version, but to ensure backward compatibility has the pre 8.5 engine available within it
  6. There will be a new Flash Lite to use with Flex 2, so you will be able to push these apps to Mobile devices

That was just the general spill, below is whats new in Flex 2 and/or beta 2

  1. CFC CRUD, Bean wizards. Seeing this in action was pretty amazing. - This actually is available as a seperate download so you can use it in conjunction with CFeclipse. Look for the ColdFusion Extensions to Flex Builder 2.0
  2. RDS - Shown last night it was a nice feature to have available agin. This is also available to use when you download the ColdFusion Extensions
  3. ActionScript to CFC and CFC to ActionScript wizards availabe by right-clicking on the appropiate file. Again available via the CF extention
  4. Charting Components are now included in the beta 2 of Flex, which might mean that selling it as a seperate package might be out of the window.
  5. Live Charting - Charts feeding directly from data

There was some more covered but my notes at that point get scarce. Needless to say I think there will be a few downloading Flex 2 today after the meeting, but even if you don't want to go near Flex make sure you download the ColdFusion Extensions for RDS support and CFC wizards.

The one point Ben made a few times was that if you want it in the application/server let Adobe know. Without letting them know there is a demand they won't include it.

By the way the sample app used was Phone Selector.

Comments Comments (2) | Print Print | Send Send | 2516 Views

why you need to read threads everyday

a.k.a Another Adobe and Macromdia post

So its coming to the end of the day in the UK soon (6:15pmish here now) and i realised that for the first time in ages i hadnt fired up FeedDemon all day WOW - last time that happens. So incase you havent heard there's gonna be a huge merger between Macromedia and Adobe - for more info check out the mini site at www.adobe.com/aboutadobe/invrelations/adobeandmacromedia.html. If you are looking for a more personal touch in finding out what this means you NEED to check out Mike Chamber recent blog entry.

Well i could go on about relative links out there but MXNA and Goog have done that well with all the post stating their concerns.

One big concern i have that doesnt seem to of been addressed that well anywere is the community focus. With the likes of of all the MM staff blogs which are an invaluable resource, there participation on mailing lists right down to MXNA? What will come of this?

Comments Comments (0) | Print Print | Send Send | 2477 Views

Fridge Magnet Message

Send message to your friends like this or maybe something more creative via Fridge Magents.

Another cool use for flash

Comments Comments (1) | Print Print | Send Send | 2531 Views

Flash Reservoir

OMG, i know its not friday but i've just came across what can only be descibed as one of the largest collections of links to flash games...ever. When i say large i mean nearly 1400 listed and categorised, and all at games.briankass.com/. All I know now is that i gotta keep away from site while working :o)

Updated: Brian, who runs the site has left me a messages - there are now over 1400 (1401 to be precise) Flash Games available.

Comments Comments (2) | Print Print | Send Send | 2413 Views

More Entries

BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .