Saturday, March 30, 2013

AMFPHP with the Flash Vector class

The 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.

There is a new version of AMFPHP from Silex Labs. 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.

I have created a google code 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.

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"). 

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.

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.


Thursday, April 12, 2012

Borders around Graphics and Frames in LibreOffice

Its 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.

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->Appearance

Thursday, February 9, 2012

New Logo For Apache Flex

After what seemed like endless deliberations on the Flex Dev Mailing list, the team from Fuse Collective 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.

Check it out on Facebook or Google+.

While I'm on this subject, I would like to use the opportunity to urge other Flex developers to get involved with the Apache Flex and Spoon 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.

Friday, May 20, 2011

Apache/PHP Crash 3221225477

A 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.

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.

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 windows.php.net:

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.

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.

We installed the 2.2.18 build from Apache Lounge, we installed the 5.3.6 build from windows.php.net - and the crashing has now stopped. Lovely Jubbly.

Friday, May 6, 2011

Flash Debugger Crash

UPDATE 20th May 2011.
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.
---------
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.

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.

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.

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 adobe article). 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).

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!

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.

Saturday, November 6, 2010

DropDownList Memory Leak - Flex 4.1

There'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).

Adding the functions below provided us with a workaround (in MXML set "preinitialize" to the onPreInit function):

import flash.events.Event;

private function onPreInit():void
{
      addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
}

protected function onRemovedFromStage(event:Event):void
{
      removeEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
      this.dataProvider = null;
}

Saturday, September 25, 2010

MXDataGridItemRenderer Focus

Author's note - since writing this post I subsequently discovered the "editor" 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...

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.

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.

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.

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.



<s:MXDataGridItemRenderer
fx="http://ns.adobe.com/mxml/2009"
mx="library://ns.adobe.com/flex/mx"
s="library://ns.adobe.com/flex/spark"
focusin="gotFocus(event)"
focusenabled="true"
implements="mx.managers.IFocusManagerComponent">
<fx:script>
<!--[CDATA[

import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.listClasses.BaseListData;
import flash.events.Event;
import mx.managers.IFocusManagerComponent;

protected var _listData:DataGridListData;
protected var focusChild:IFocusManagerComponent;

private function gotFocus(event:Event):void
{
if (focusChild)
{
focusChild.setFocus();
}
}
override public function set data(value:Object):void
{
super.data = value;
}
public override function get data():Object
{
return super.data;
}
override public function get listData():BaseListData
{
return _listData;
}
override public function set listData(value:BaseListData):void
{
_listData = DataGridListData(value);
}
]]-->

</fx:script>
</s:MXDataGridItemRenderer>