tag:blogger.com,1999:blog-56624213195748801472024-03-19T14:50:37.323-07:00Mick Powell's TipsMick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-5662421319574880147.post-20020110321149965192022-04-11T17:00:00.005-07:002022-04-12T15:26:17.729-07:00Curry Day at the Exit!<p>We're doing a Curry Day at the Exit Inn, 2a Avenida Sur #22, Antigua Guatemala on Wednesday the 20th of April. A complete curry meal made up of chicken madras, rice, saag aloo, raita and naan bread. We'll also do a vegetarian option with chickpea madras in place of the chicken, or fully vegan which as well has kachumba and a chapati in place of the raita and naan. The whole meal for Q100. Here's a video of the team in action! <br /></p><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dwjgmJJJxSRB8q27njDxoQUpmxsHCtCqXZf5b_SCVAzIVTMGAVc0WJgoCREZwlx5uVUj9Bs_PEdUzOiX2yoFw' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br />Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0Antigua Guatemala, Guatemala14.5572969 -90.733223299999992-13.752936936178845 -125.88947329999999 42.86753073617885 -55.576973299999992tag:blogger.com,1999:blog-5662421319574880147.post-21317061878050085352018-08-21T11:32:00.000-07:002018-08-21T11:32:59.200-07:00More on tsconfig paths with JestIn my <a href="https://mickpowellstips.blogspot.com/2018/08/configuring-unit-testing-path-aliases.html" target="_blank">last post</a> I explain how you can manually update your jest configuration to reflect paths that you may have setup in tsconfig.json.<br />
<br />
I found this utility called <a href="https://www.npmjs.com/package/tsconfig-paths-jest" target="_blank">tsconfig-paths-jest</a>, that will do that automatically for you. To use this, you will need to set up a jest.config.js file so that you can assign values dynamically at test runtime, and if you have jest configuration info in package.json you should remove that when you set up your jest.config.js file. Please see the <a href="https://www.npmjs.com/package/tsconfig-paths-jest" target="_blank">tsconfig-paths-jest</a> project for full instructions.<br />
<br />
One other pointer there - be careful if like me you have copied the tsconfig.json file from somewhere on the internet. The utility uses JSON.parse, and the implementation is strict and doesn't like trailing commas at the end of arrays and objects.<br />
<br />
So something like this:<br />
<br />
<div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Menlo, Monaco, "Courier New", monospace; line-height: 18px;">
<div>
<span style="color: #9cdcfe;">"paths"</span>: {</div>
<div>
<span style="color: #9cdcfe;">"@assets/*"</span>: [ <span style="color: #ce9178;">"src/assets/*"</span> ],</div>
<div>
<span style="color: #9cdcfe;">"@source/*"</span>: [ <span style="color: #ce9178;">"src/*"</span> ],</div>
<div>
}</div>
</div>
<br />
Should be changed to:<br />
<br />
<div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Menlo, Monaco, "Courier New", monospace; line-height: 18px;">
<div>
<span style="color: #9cdcfe;">"paths"</span>: {</div>
<div>
<span style="color: #9cdcfe;">"@assets/*"</span>: [ <span style="color: #ce9178;">"src/assets/*"</span> ],</div>
<div>
<span style="color: #9cdcfe;">"@source/*"</span>: [ <span style="color: #ce9178;">"src/*"</span> ]</div>
<div>
}</div>
</div>
<br />Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-75350911966086522772018-08-01T07:08:00.002-07:002018-08-21T11:32:45.435-07:00Configuring unit testing path aliases with Jest, Typescript and React-native<style type="text/css">
@page { margin: 2cm }
p { margin-bottom: 0.25cm; line-height: 120% }
a:link { so-language: zxx }
</style>
<br />
<div style="line-height: 100%; margin-bottom: 0cm;">
<i>Update: 21/8/2018: This post describes how to set up tsconfig.json paths manually for jest. In the <a href="https://mickpowellstips.blogspot.com/2018/08/more-on-tsconfig-paths-with-jest.html" target="_blank">next post</a> I describe how to do that automatically.</i><br />
<br />
I ran into some
nasty problems recently (well the latest set of them anyway) trying
to run tests with the Jest setup in a react-native project. A while
ago I had seen a nice Typescript feature where you can set up an
alias for a path in your source code (details of that in <a href="https://medium.com/@caludio/how-to-use-module-path-aliases-in-visual-studio-typescript-and-javascript-e7851df8eeaa">this
post</a> and others). Having been round the block a few times over
the years with "../../../../" relative paths, these path aliases felt
like something of a solution.</div>
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0cm;">
A while after that,
I started setting up some Jest unit tests, and while some worked just
fine, others would fail on imports. The reason is that Jest has no
clue about these path aliases that Typescript is using (although
there might be an argument that something like ts-jest should relay
that information). I'm not a fan of having these nice features, and
then finding that you need to set them up in more than one place, but
the only way I have found to fix the issue so far is using the
<span style="background-color: white;"><span style="color: purple;">moduleNameMapper</span></span> configuration for Jest.<br />
<br /></div>
<style type="text/css">
@page { margin: 2cm }
p { margin-bottom: 0.25cm; line-height: 120% }
a:link { so-language: zxx }
</style>
<br />
<div style="line-height: 100%; margin-bottom: 0cm;">
As an example, let's
say we have an assets directory path set up in tsconfig.json as per
the following snippet:</div>
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0cm;">
</div>
<pre style="background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: "arial"; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">"paths":
{
"@assets/*": [ "src/assets/*" ],
},
</code></pre>
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0cm;">
And remembering that
we need an extra package.json file in the assets directory with the
following configuration:</div>
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<pre style="background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: "arial"; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">{ "name": "@assets" }</code></pre>
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0cm;">
Then we can tell
Jest about that in the jest config in our main package.json (or in
jest.config.js if you went that way):<br />
<br /></div>
<div style="line-height: 100%; margin-bottom: 0cm;">
</div>
<div style="line-height: 100%; margin-bottom: 0cm;">
<pre style="background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: "arial"; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">"moduleNameMapper":
{
"@assets/(.*)$": "<rootDir>/src/assets/$1"
},
</code></pre>
</div>
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0cm;">
Which essentially
says "for anything that begins with @assets/ substitute with the
root directory of the project then src/assets and then whatever comes
after" so:
</div>
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<pre style="background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: "arial"; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">@assets/images/icons/icon1.png</code></pre>
<br />
<div style="line-height: 100%; margin-bottom: 0cm;">
becomes something like<br />
<br /></div>
<div style="line-height: 100%; margin-bottom: 0cm;">
</div>
<pre style="background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: "arial"; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">/users/example/react-native-projects/my-app/src/assets/images/icons/icon1.png</code></pre>
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0cm;">
This is documented on the <a href="https://github.com/kulshekhar/ts-jest" target="_blank">ts-jest github docs</a>. You will save a lot of time and potentially major frustration by carefully reading the information there that pertains to your project before you start using ts-jest.</div>
<br />Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-52645664880814167792018-06-26T15:26:00.000-07:002018-06-26T15:33:04.031-07:00Fuego Volcano Disaster in GuatemalaGolf players here in Guatemala have been raising money for some caddies who lost family, homes and livelihoods during the recent volcano disaster. The golf course where they were working near the villages that were hit was essentially destroyed as well during the event, and so they're out of work now on top of everything else… (Good thing was none of the ones working that day died, as the golf course had good emergency procedures in place.) The golf course had a policy of employing local people, so most of the caddies were kids from very poor local families, the same families whose villages drew the brunt of the pyroclastic flow that came down the volcano.<br />
<br />
<iframe allow="autoplay; encrypted-media" allowfullscreen="" frameborder="0" height="225" src="https://www.youtube.com/embed/aqsRBTU2NI4" width="400"></iframe><br />
<br />
A funding page to raise money for the effort has been set up, specifically aimed at (but not exclusive to) people in the UK. I know the people involved and every penny raised will go directly to affected families. If you know of someone who plays golf and would be up for helping, please pass on the link below: <a href="https://www.gofundme.com/jn4cwz-houses-for-caddies?sharetype=teams&member=321576&rcid=r01-152995344496-d3860daf68a1407b&pc=ot_co_campmgmt_m">https://www.gofundme.com/jn4cwz-houses-for-caddies?sharetype=teams&member=321576&rcid=r01-152995344496-d3860daf68a1407b&pc=ot_co_campmgmt_m</a>. Of course... you don't have to be a golfer to help out!<br />
<div>
<div>
<br /></div>
<div>
<br /></div>
</div>
Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-64973999896262032922014-11-19T09:35:00.003-08:002014-11-19T09:35:58.284-08:00Las Manos Festival 2014If you are in or near Antigua Guatemala on the 6th of December 2014, you won't want to miss this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9Px4Mrti2P9OpVnAAULMeSLj0lDWmluspJXDuK4jBCMvK5csRI7IYlKJ_MCwloZ_4YSfZgj81k134KAEY5o7-j_-1_BcrhPE0enTpGxtT2twOuRslifZB6x3EMwOb610Shz4yY2tuD52d/s1600/LMIII-WEB-SKULL.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9Px4Mrti2P9OpVnAAULMeSLj0lDWmluspJXDuK4jBCMvK5csRI7IYlKJ_MCwloZ_4YSfZgj81k134KAEY5o7-j_-1_BcrhPE0enTpGxtT2twOuRslifZB6x3EMwOb610Shz4yY2tuD52d/s1600/LMIII-WEB-SKULL.jpg" height="320" width="186" /></a></div>
<br />Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com2tag:blogger.com,1999:blog-5662421319574880147.post-2892931997626094052013-03-30T15:50:00.002-07:002013-03-30T15:58:02.610-07:00AMFPHP with the Flash Vector classThe AMFPHP (1.9 beta) did not support vectors (vector arrays) either inbound or outbound from Flash. My colleagues and I have made this work for our team, but with PHP 5.4 and a rather modified version of AMFPHP for our sole purposes.<br />
<div>
<br /></div>
<div>
There is a new version of AMFPHP from <a href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&sqi=2&ved=0CC8QFjAA&url=http%3A%2F%2Fwww.silexlabs.org%2Famfphp%2F&ei=G2ZXUdTCLo7M9gSj64DYAg&usg=AFQjCNFXs21JgOSAaqhPWmVltoFqSu7KWQ&sig2=3gUWtqCxSoZ1hx76Mwz2rQ&bvm=bv.44442042,d.eWU" target="_blank">Silex Labs</a>. I cannot say how much better it is than the 1.9 version, but I would advise that you check that first. I'm not sure though that it includes code for serializing and deserializing vectors, and for that reason, I have posted the code from our adaptation of the 1.9 version so that its potentially available to anybody, new version or old.<br />
<br />
I have created a <a href="http://code.google.com/p/amfphp-vectors/" target="_blank">google code</a> project and included the updates to AMFSerializer and AMFDeserializer there. These are the the .php files, not patches, so you will need to know what you're doing to update your code. If there really is enough interest, I will create patches and tidy this up a bit. There is also a class for AMFVector, this is so that the serializer knows that we want to send a vector back (and not an array). It also defines constants for the serializer and deserializer.<br />
<br />
Vectors are cast to arrays for incoming vectors to PHP. Arrays wrapped in the AMFVector class will be vectors when they get back to flash. All the vectors in the spec cast back correctly, but please note the Vector.<Boolean> and Vector.<String> get cast to Vector.<Object> by Flash on the swing-back for some reason. I found that casting them using the static Vector.<String> or Vector.<Boolean> function call addressed the issue (ie: without the "new").
<br /><br />
Please be warned, this was made for PHP 5.4 - it is not backwards compatible with other versions of PHP, and there is no intention on my part to make it so. Also, there are no guarantees, you use this at your own risk.<br />
<br />
At the same time, as far as I can see this conforms the AMF spec for vectors, and works for vector-int, vector-uint (with the PHP caveats), vector-float and vector-object.<br />
<br />
<br /></div>Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-51090245311471715032012-04-12T09:17:00.000-07:002012-04-12T09:19:14.395-07:00Borders around Graphics and Frames in LibreOfficeIts has been a bit of struggle trying to work this out. I was trying to stop LibreOffice (version 3.4.3) showing borders around graphics. At first I thought these were real borders (either around the graphic or the frame), but then realised that they are just "view" borders and do not print. Even so, I wanted to get rid of them, but there is not option in the "view" menu. <br />
<br />
On the Mac I discovered that in Preferences->LibreOffice->Appearance there is a check on "Object Boundaries", un-checking this does the trick. In Windows this is in Tools->Options->LibreOffice->AppearanceMick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-59941280950885289812012-02-09T09:27:00.000-08:002012-02-09T10:08:42.842-08:00New Logo For Apache FlexAfter what seemed like endless deliberations on the Flex Dev Mailing list, the team from <a href="http://www.fusecollective.com/" target="_blank">Fuse Collective</a> have published the new Apache Flex logo. I think they did a great job personally and many thanks to them for donating their time and efforts.<br />
<br />
Check it out on <a href="http://www.facebook.com/photo.php?fbid=323407114369911&set=a.164354343608523.27750.115504021826889&type=1" target="_blank">Facebook</a> or <a href="https://plus.google.com/u/0/110106254054698446288/posts/iZTyGd1LZwr" target="_blank">Google+</a>. <br />
<br />
While I'm on this subject, I would like to use the opportunity to urge other Flex developers to get involved with the <a href="http://blogs.apache.org/flex/" target="_blank">Apache Flex</a> and <a href="http://www.spoon.as/" target="_blank">Spoon</a> projects. To be honest, I'm just as upset as many of you are with the way that Adobe has handled anything Flash or Flex recently, but even if you have decided to move to another technology like HTML5, Java etc., things are being discussed and worked on that will interest you too (in terms of migration). We're all in the same boat, and there's no better time to pull together and pool our collective resources and ideas.Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-17682612225005101782011-05-20T07:42:00.000-07:002011-05-20T07:42:06.167-07:00Apache/PHP Crash 3221225477A friend of mine had problems recently running Apache, PHP and MYSQL on Windows Server 2003. The problems occurred using the community version of eGroupWare (a web based project manager), although we suspected that the issues weren't just limited to that product.<br />
<br />
The problem was the now seemingly famous (if you Google it) Apache crash: Parent: child process exited with status 3221225477 -- Restarting. This problem is apparently an access violation.<br />
<br />
If you have been unfortunate enough to experience this, and you have read the things about copying DLLs to the windows system32 folder (and maybe checked your PATH environmental variable before you did that!), you might want to read the following snippet from <a href="http://windows.php.net/">windows.php.net</a>:<br />
<br />
<blockquote>Windows users: please mind that we do no longer provide builds created with Visual Studio C++ 6. It is impossible to maintain a high quality and safe build of PHP for Windows using this unmaintained compiler.<br />
<br />
For Apache SAPIs (php5_apache2_2.dll), be sure that you use a Visual Studio C++ 9 version of Apache. We recommend the Apache builds as provided by ApacheLounge.</blockquote><br />
We installed the 2.2.18 build from <a href="http://www.apachelounge.com/download/">Apache Lounge</a>, we installed the 5.3.6 build from <a href="http://windows.php.net/download/">windows.php.net</a> - and the crashing has now stopped. Lovely Jubbly.Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-47312598905469387572011-05-06T12:00:00.000-07:002011-05-20T08:44:26.168-07:00Flash Debugger Crash<b>UPDATE 20th May 2011.</b><br />
I'm very happy to announce that this problem seems to have been fixed in the 10.3 version of the Flash Debug Player in Windows. I'm also happy to say that Adobe did indeed contact my colleague Alejandro today to ask us to check again or provide more details. Nice.<br />
---------<br />
Since Flex 4 and Flash Player 10 were published, we have been getting crashes when running the external debug Flash Player from FlashDevelop, somewhere after release 10.0.32. As workaround we just reverted back to the Flash Standalone Debug player that we knew worked, and carried on. Recently we wanted to move to Flex 4.5, and this became more of an issue as we need to now use the 10.2 player.<br />
<br />
Originally we were pointing the finger at FlashDevelop (because of past posts etc. on this issue), but we have established that this is in fact a Flash Debugger Player bug and we know pretty much exactly how it happens. The fact that is has nothing to do with FlashDevelop.<br />
<br />
If you are using resource bundles in Flex, and you have a file with keys and values that exceeds a point just over 12k, and you compile these files into the SWF using the locale=en_US (or = whatever) compiler option, this crash will start happening.<br />
<br />
The workaround is to create a resource module swf of your resource files and load that at runtime, and then the crash stops (see this <a href="http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f3c.html">adobe article</a>). Alternatively, you can break your resource bundle files up into less that 12k each. Please remember that this only seems to apply to the external debug player (projector).<br />
<br />
We have registered this bug with Adobe - FP-6790 at https://bugs.adobe.com/flashplayer/, but because it relates to "a potential security issue", we couldn't see it or review it afterward!<br />
<br />
Really hope this helps somebody with the same problem. This was true for Flex SDK 4.5 first release build and Flash Player Debugger (projector, sa_debug) 10.2 r159.Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-63613814243858235632010-11-06T08:45:00.000-07:002010-11-06T09:08:04.611-07:00DropDownList Memory Leak - Flex 4.1There's a memory leak in the DropDownList in Flex 4.1 (build 4.1.0.16076). If you set the dataProvider you'll find you can't subsequently clear it from memory and it won't get garbage collected (and nor will the container etc. that houses it).<br /><br />Adding the functions below provided us with a workaround (in MXML set "preinitialize" to the onPreInit function):<br /><br />import flash.events.Event;<br /> <br />private function onPreInit():void<br />{<br /> addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);<br />} <br /> <br />protected function onRemovedFromStage(event:Event):void<br />{<br /> removeEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);<br /> this.dataProvider = null;<br />}Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-48384139185711470962010-09-25T11:34:00.000-07:002010-11-06T08:45:14.768-07:00MXDataGridItemRenderer Focus<span style="font-style: italic;">Author's note - since writing this post I subsequently discovered the "<a href="http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/mx/controls/listClasses/MXItemRenderer.html#editor">editor</a>" property which does exactly what my "focusChild" property does below. I've left the post intact anyway to help highlight the point and maybe also in the faint hope that somebody from the documentation team at Adobe sees this and does something wild like mentioning this property in their examples...</span><br /><br />Once you have switched your existing Flex 3 projects over to trying to use the spark components in Flex 4 you will come across a problem with the new setup for DataGrid ItemRenderers. You will realise that things are now structured differently and you will need to use the MXDataGridItemRenderer class to get your item renderers working again.<br /><br />You smile a wry smile and bite the bullet, but then something else happens. You realise that things have got all “out of focus”... And by that I mean that tab and mouse focusing doesn't work like they did in Flex 3, and the behaviour is not what you (or your users) would be expecting.<br /><br />The good thing is the solution is ultimately pretty simple. The code below shows a sub-class of MXDataGridItenRenderer which you can use to get the old focus behaviour back to the way it was. What happens is MXDataGridItemRenderer itself receives the focus, but can't really do anything with it, so you yourself get the job of passing it on to your TexInput, DropDownList, whatever. The way we did it was to add a property called focusChild to our sub-class, as the itemRenderer could conceivably contain any number of custom controls, and this helps to stipulate which one gets the focus when the user mouse-clicks or tabs into the renderer for the given column on the DataGrid.<br /><br />Our team on the job generally subclass this class, and use the creationComplete event to set the focusChild property to the custom control. The accessors on Data and ListData are there for convenience so that these can be accessed by a subclass (in Flex 3 this complied with the interfaces for IDataRenderer and IListItemRenderer). We also generally override the set data method for setting custom properties on a custom control.<br /><br /><div class="preWrapper"><pre><br /><code><br /><s:MXDataGridItemRenderer<br />fx="http://ns.adobe.com/mxml/2009"<br />mx="library://ns.adobe.com/flex/mx"<br />s="library://ns.adobe.com/flex/spark"<br />focusin="gotFocus(event)"<br />focusenabled="true"<br />implements="mx.managers.IFocusManagerComponent"><br /><fx:script><br /><!--[CDATA[<br /> <br />import mx.controls.dataGridClasses.DataGridListData;<br />import mx.controls.listClasses.BaseListData;<br />import flash.events.Event; <br />import mx.managers.IFocusManagerComponent;<br /><br />protected var _listData:DataGridListData; <br />protected var focusChild:IFocusManagerComponent;<br /><br />private function gotFocus(event:Event):void <br />{ <br /> if (focusChild) <br /> { <br /> focusChild.setFocus();<br /> }<br />} <br />override public function set data(value:Object):void<br />{ <br /> super.data = value; <br />}<br />public override function get data():Object<br />{<br /> return super.data;<br />}<br />override public function get listData():BaseListData<br />{<br /> return _listData;<br />}<br />override public function set listData(value:BaseListData):void<br />{<br /> _listData = DataGridListData(value);<br />} <br />]]--><br /><br /></fx:script><br /></s:MXDataGridItemRenderer><br /><br /></code><br /></pre></div>Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com1tag:blogger.com,1999:blog-5662421319574880147.post-32498884921472744632010-03-09T16:14:00.000-08:002010-03-09T16:50:25.289-08:00Air 2 Native Process Command Window Pop-upFurther to an earlier post, I just wanted to note that Adobe have now said they will stop the command window appearing by default on native processes run on Windows when they do the full release of Air 2 (see my post from January 2010 on <a href="http://mickpowellstips.blogspot.com/2010/01/air-2-beta-native-process-and-php-cli.html" target="_blank">Air 2 Beta Native Process</a>).<br /><br />Chris Thilgen from Adobe apparently pushed for this (see his comments on the <a href="http://forums.adobe.com/message/2647435#2647435" target="_blank">adobe forum</a>), so if you ever read this Chris, thanks for that.Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-23137541272570886192010-03-06T14:14:00.000-08:002010-03-06T14:31:13.789-08:00Don't try this at homeAll people in this video will remain anonymous - its not me by the way - its the future president of FIFA.<br /><br /><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dxOPMsfH9rSvUBfwtJNLX43yRCoRqCu0nrxeipAbUM2Lg9_cmteeIGvHg1vLfI5Yk3_7sbmKTPLJT_3k-XRVg' class='b-hbp-video b-uploaded' frameborder='0'></iframe>Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-25271030640415768162010-01-28T11:14:00.000-08:002010-01-28T11:29:12.939-08:00Subversion subfolder access funAfter such a fantastic morning trying to set up subfolder access on various subversion repositories - its nice to share this little gem with anybody that might be interested.<br /><br />I wanted a user to have read access to a whole project folder, but to restrict write access to just one folder inside the project. According to the docs I read this should work:<br /><br />[Project1:/]<br />newuser = r<br /><br />[Project1:/trunk/graphics]<br />newuser = rw<br /><br />But it didn't. After a whole wasted morning, I found - much to my chagrin - that I had to grant rw rights at the root to the new user, and then deny rights where they weren't applicable, to be able to grant write rights (apache with subversion 1.6.6) to a subfolder (read rights worked ok funnily enough).<br /><br />[/]<br />newuser = rw<br /><br />[Project1:/]<br />newuser = r<br /><br />[Project1:/trunk/graphics]<br />newuser = rw<br /><br />[Project2:/]<br />newuser =<br /><br />I suppose there is some kind of logic there, somewhere...<br /><br />If you're reading this because you're having the same problem -I really do hope I've helped you.Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-11804624653352276382010-01-25T15:25:00.001-08:002010-01-26T14:04:59.041-08:00AIR 2 Beta native process and the PHP CLIWith the release of the Adobe Air 2 beta comes a rake of cool new features. The most promising amongst them for future development is the ability to call and communicate with native processes on the machine on which Air is running. This obviously opens up all sorts of possibilities for extending the capacity of AIR without the need for the required API to be a part of AIR itself.<br /><br />The application I'm building has so far has been slowly growing as a bunch of Flex applications, working with MYSQL via AMFPHP. But as more things are moved into AIR I wanted to get rid of the need for the webserver, in the case of the application working standalone on a local machine with a local installation of a MYSQL database.<br /><br />Using the new native process API in AIR, and the CLI version of PHP, I've managed to come up with a way of communicating with AMFPHP directly through STDIN and STDOUT without the need for a webserver. The code is in its infancy, but I thought this would be a good time to share the idea and get some comments and input from those of you out there who are working in the same environment.<br /><br />Rather than trying to post the code here on the blog - I've opened a Google Code project so that anybody who's interested can download the code and develop the idea if they want to. The project is at <a href="http://code.google.com/p/aircmdamfphp">http://code.google.com/p/aircmdamfphp/</a> - you can download from subversion or there's a zip that you can download for convenience.<br /><br />My main concern so far is security. For this to work on in a live application scenario on a user's machine the first consideration would be to have the PHP code compiled and have some way of securing the PHP installation against possible attacks. Any comments and/or suggestions on this or any other areas of concern regarding security on this particular idea would be appreciated. I suppose the other concern might be somebody hooking something in between the parent and child process...<br /><br />There is a truly annoying caveat with AIR on Windows at the moment. If you install and run an AIR application using the 2 beta you get a command line pop-up window appearing each time you run php.exe (or it seems any other command line executable). I was hoping Adobe would come up with a fix for this before a production version is released, but looking at the Adobe Forums, Chris Thilgen is telling us that it won't be... (apparently its a "feature request" to not show the command window!) <a href="http://forums.adobe.com/thread/558533?tstart=0">http://forums.adobe.com/thread/558533?tstart=0</a>.<br /><br />Maybe next time eh?<br /><p style="margin-bottom: 0cm;"></p>Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-1867608615233096272009-02-19T18:43:00.000-08:002010-01-28T11:30:02.218-08:00The Base Index ThingHaving already converted to MYSQL as a backend database while still using VFP – I have come up against an old xbase peculiarity with the base number for array indexing. In most other languages that I’ve come across (including Actionscript) – array indexing starts at zero – in xbase it starts at 1. Kind of cool for “FOR loops” in xbase, and has workable logic to it, but that’s about it!<br /><br />A common practice for a finite number of options for a given field value is to tie an integer field to a combobox. Let me give an example: in an application that I’ve been working on there is a pricing option that is stored in a rate table. This defines how a price is calculated – “per person”, “group” or “group + additional”. The application only works with those price calculations, the list is not something that’s customizable by the user, so we don’t need a related table for that list – we just need a 1, 2 or 3 (or in Actionscript 0, 1 or 2) to tell us which pricing option has been assigned.<br /><br />NB: You could argue that the best practice would be a related table with formulaic data that the application uses to calculate and the user could customise – that’s on the to-do list!<br /><br />So to return to the problem – values in the database were stored originally in Foxpro but now need to be integrated into Flex. This means we now have an issue with just tying the value to the selectedIndex for a combobox – 1 now = 0, 2 now = 1 etc. The straightforward answer is to “just convert the data for Flex”. I actually adopted that policy previously on a different project and for reasons I won’t bother to explain right now it slowed down development and kept biting me in the nether region. Additionally – I want to use Flex and Foxpro concurrently - replacing sections of the front end in stages - and eventually ending up with an AIR application. In some areas of the application the user is working in Flex, in others it is still the Foxpro GUI.<br /><br />The answer I came up with was relatively simple – override the getter and setter for selectedIndex, and use a separate private variable for binding the value from the data field. A little bit of plus and minus 1 and it all works. The code is below in the subclass of the combobox.<br /><br />But then a second issue arose making things just a little more complicated. As soon as I put this extension of the Combobox on a canvas in a TabNavigator that wasn’t the first to be displayed (ie: the second or subsequent tab) strange things happened. Whatever I had the data field set to, I ended up with a blank comboBox when I clicked the tab the very first time. Move to another record and everything starts working and the values start displaying…<br /><br />I am guessing this is related to some code inside Flex that is doing some delayed jiggery-pokery to enhance performance. Without delving into the code though – that will have to remain just a guess. In the meantime – I tweaked a way round it. The test in the override for selectedIndex checks to see if the combobox is on a tabNavigator – and make sure that if it is - when Flex sets the selectedIndex it doesn’t set it to minus one after it has already been set via the cbSelected variable.<br /><br />Admittedly this is obscure stuff – but if I’ve helped out just one other person – I’ll be a happier individual for it!<br /><br />Here’s the extension of the combobox.<br /><br /><div class="preWrapper"><pre><br />package <br />{<br /> import mx.containers.TabNavigator;<br /> import mx.controls.ComboBox;<br /> import mx.containers.Canvas;<br /> <br /> <br /> /**<br /> * ...<br /> * @author ...<br /> */<br /> public class ComboBoxSelectedIndex extends ComboBox<br /> {<br /> private var _cbSelected:int;<br /> private var _selectedIndex:int;<br /> <br /> public function ComboBoxSelectedIndex() <br /> {<br /> super();<br /> <br /> }<br /> public function get cbSelected():int<br /> {<br /> return _cbSelected;<br /> }<br /> public function set cbSelected(value:int):void<br /> {<br /> _cbSelected = value;<br /> <br /> if (value > 0)<br /> {<br /> super.selectedIndex = value -1;<br /> }<br /> }<br /> public override function get selectedIndex():int<br /> {<br /> return _selectedIndex;<br /> }<br /> public override function set selectedIndex(value:int):void<br /> {<br /> var setSelected:Boolean = true;<br /> if (owner is Canvas)<br /> {<br /> if ((owner as Canvas).parent is TabNavigator)<br /> {<br /> if (cbSelected is int)<br /> {<br /> if (selectedIndex < 0 && cbSelected >= 0)<br /> {<br /> setSelected = false;<br /> }<br /> }<br /> }<br /> }<br /> if (setSelected)<br /> {<br /> _cbSelected = value + 1;<br /> super.selectedIndex = value;<br /> _selectedIndex = value;<br /> }<br /> }<br /> }<br />}<br /></pre></div><br /><p></p>Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-82421307022104070222009-02-18T10:24:00.000-08:002010-01-28T11:29:43.467-08:00Checkbox Renderer Ignores Editable Property in a Grid Column<p>I've been having problems getting a Flex 3 checkbox to pay attention to a datagrid columns editable status. I finally found a solution using a component I had previously lifted from <a href="http://blogs.adobe.com/aharui/">Alex's Flex Closet</a>. The solution was in the code for the clickHandler - an override with a test of the parent columns editable status seems to have done the trick for me. This took me a while to work out - and even then there may be some issues with it. If anybody has a more efficient working method please let me know. I will come back soon and update this post with a full working example - but for now the code for extending the checkbox class is below.</p><br /><div class="preWrapper"><pre><br />package <br />{<br /> <br /> import flash.display.DisplayObject;<br /> import flash.events.KeyboardEvent;<br /> import flash.events.MouseEvent;<br /> import flash.text.TextField;<br /> import mx.controls.CheckBox;<br /> import mx.controls.dataGridClasses.DataGridListData;<br /> import mx.controls.listClasses.BaseListData;<br /> import mx.controls.DataGrid;<br /><br /> /** <br /> * The Renderer.<br /> */<br /> public class CentredCheckBox extends CheckBox<br /> {<br /><br /> private var _listData:DataGridListData;<br /><br /> public function CentredCheckBox()<br /> {<br /> focusEnabled = false;<br /> }<br /> <br /> override public function set data(value:Object):void <br /> {<br /> super.data = value;<br /> if (listData is DataGridListData)<br /> {<br /> selected = Boolean(data[DataGridListData(listData).dataField]);<br /> }<br /> }<br /> override public function get listData():BaseListData<br /> {<br /> return _listData;<br /> }<br /> override public function set listData(value:BaseListData):void<br /> {<br /> _listData = DataGridListData(value);<br /> } <br /> <br /> /* eat keyboard events, the underlying list will handle them */<br /> override protected function keyDownHandler(event:KeyboardEvent):void<br /> {<br /> }<br /><br /> /* eat keyboard events, the underlying list will handle them */<br /> override protected function keyUpHandler(event:KeyboardEvent):void<br /> {<br /> }<br /> <br /> /* eat mouse events, the underlying list will handle them */<br /> /* unless we are in edit mode - in which case process them */<br /> override protected function clickHandler(event:MouseEvent):void<br /> {<br /> var allowEdit:Boolean;<br /> if (listData is DataGridListData)<br /> {<br /> allowEdit = DataGrid(DataGridListData(listData).owner).columns[DataGridListData(listData).columnIndex].editable;<br /> }<br /> if (allowEdit)<br /> {<br /> super.clickHandler(event);<br /> }<br /> }<br /><br /> /* center the checkbox if we're in a datagrid */<br /> override protected function updateDisplayList(w:Number, h:Number):void<br /> {<br /> super.updateDisplayList(w, h);<br /><br /> if (listData is DataGridListData)<br /> {<br /> var n:int = numChildren;<br /> for (var i:int = 0; i < n; i++)<br /> {<br /> var c:DisplayObject = getChildAt(i);<br /> if (!(c is TextField))<br /> {<br /> c.x = (w - c.width) / 2;<br /> c.y = 0;<br /> }<br /> }<br /> }<br /> }<br /> }<br />}<br /></pre></div>Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-25397754125791898412008-10-10T09:20:00.000-07:002008-10-10T11:22:46.923-07:00CLEAR ALL - CANCEL - QUITI know some developers out there will be gutted by the demise of Visual Foxpro – I know I was. VFP was a great tool, and I doubt whether that kind of performance will be found again (and I was programming in Clipper before that!). But that said – the more important question for me was <span style="font-style: italic;">“what’s the next step then”</span>.<br /><br />I’ve settled on AIR and Flex. The possibility of a cross-platform solution that provides both Desktop and web access to an application and an application’s data from the same code base is basically irresistible. The fact that the SDK is open source as well – and that Microsoft are not involved – were also persuasive factors in the decision making process. I also had PHP and Flash experience, and my back-end database was already using MYSQL. But then the final clincher – <span style="font-style: italic;">“oh brilliant, they’ve got grids!”</span>.<br /><br />Given that, there is still a rather steep gradient going up the learning curve, so I’ll be sharing some of the experiences along the way, and aiming some of that specifically at ex-foxpro developers who might be following the same route. I’ve received a lot of help from fellow coders on blogs and wikis in the past, and I feel it really is about time I made an effort to give something back myself. I would also like to say a big thank you to all of you out there who that go that extra mile to share a few pearls of wisdom.<br /><br />And so to start in that vein – let me point out some very good general Flex and AS3 resources that are already in place:<br /><br /><a href="http://blogs.adobe.com/aharui/">Alex’s Flex Closet</a><br />Alex is apparently one of the engineers on the Flex project who makes time to share assorted gems from an insider perspective. If you wanted “authoritative” then you wouldn’t find much better.<br /><br /><a href="http://weblogs.macromedia.com/pent/">Peter Ent’s Blog</a>:<br />Lots of great information – particularly on renderers.<br /><br /><a href="http://blog.flexmonkeypatches.com/">Flex Monkey Patches</a><br />Again – a welter of useful information – and pretty much always with a working example.<br /><br /><a href="http://www.moock.org/">Colin Moock</a><br />Colin Moock is “the man” when it comes to Flash and Actionscript. He has been around pretty much from the beginning - and I’ve consulted his writing in the past while working on flash projects on literally hundreds of occasions. He has also written a very good book – <a href="http://www.moock.org/eas3/">Essental Actionscript 3 (O’Reilly)</a> – which you should make space on your bookshelf for. I even bought a copy myself (well my company paid for it).<br /><br />Good luck in your efforts anyway – and expect more from me soon.</p>Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0tag:blogger.com,1999:blog-5662421319574880147.post-547471386677782822008-09-16T16:43:00.000-07:002008-09-16T17:07:41.070-07:00Windows 2000 Server "Foreign" Disk?Had a lot of trouble this weekend simply changing a disk from one server to another. The first server had an <span class="blsp-spelling-error" id="SPELLING_ERROR_0">IDE</span> drive as the system disk, the second disk is a <span class="blsp-spelling-error" id="SPELLING_ERROR_1">sata</span> disk where <span class="blsp-spelling-error" id="SPELLING_ERROR_2">mysql</span> data was stored (there is a proven performance benefit with many programs to run the <span class="blsp-spelling-error" id="SPELLING_ERROR_3">executables</span> on one drive, and store the associated data on another).<br /><br />The <span class="blsp-spelling-error" id="SPELLING_ERROR_4">mysql</span> <span class="blsp-spelling-error" id="SPELLING_ERROR_5">sata</span> disk was to go to a new server - a server with the same name going into the same domain. Windows 2000 server recognised the disk once it had been swapped, but after loading drivers and asking for a reboot - still did not show the disk in windows explorer.<br /><br />I had noticed in the disk management snap-on in control panel-administrative tools-computer management - that the drive was actually being recognised - but was flagged as dynamic and "<span class="blsp-spelling-corrected" id="SPELLING_ERROR_6">foreign</span>"... I scratched my head and after some frustrated googling left for home in disgust. The next morning I arrived early, changed my search phrases - and found some answers straight away.<br /><br />If this ever happens to you - go to the disk management snap-on - right click the offending drive and click "Import Foreign Data" - and you should find your drive is now recognised and your data is still all there.<br /><br />What the dynamic and foreign nonsense is all about - god knows - I didn't even bother to find out as its ridiculous to me. But try the above which worked for me - and then contact Bill Gates for more information!Mick Powellhttp://www.blogger.com/profile/18148543185405970213noreply@blogger.com0