THis is the best way you can easily handle boolean type conversion between FileMaker and ActionScript, specially when using AMF services.
As you know, FileMaker doesn't have Boolean field type, but can use, evaluate and return boolean values as a result of the evaluation of Text or Number fields. In addition, FileMaker versions before 6.x, version pre-7.0, and versions 7.0, 8.x, 9, 10 to 11, have significant differences in boolean evaluation:
You can use any of these values to be evaluated as TRUE: [non blank field], 1 or "1"
You can use any of these values to be evaluated as FALSE: [blank field], 0 or "0"
In FM v 6.0 and earlier, you can use these strings as well:
Evaluates to TRUE: "True", "Yes", "Y", "y", "T" or "t"
Evaluates to FALSE: "False", "No", "N", "n", "F" or "f"
Obviously my recommendation is to use a Number Field, set to 1 or 0 (and forget FM version 6 and earlier).
In the remote service, define the corresponding class (for to your Value Object) to threat it as int...
(in php will look like this...)
| filemaker | | copy code | | ? |
| 01 | <?php |
| 02 | class LabelVO { |
| 03 | |
| 04 | public function __construct() { } |
| 05 | |
| 06 | var $recid; |
| 07 | public $isValid; |
| 08 | public $sku; |
| 09 | public $txt; |
| 10 | public $_explicitType = "com.myPackage.LabelVO"; |
| 11 | |
| 12 | public function __set_state ( $assoc ) { |
| 13 | $this->recid = (int) $assoc->recid; |
| 14 | $this->isValid = (int) $assoc->isValid; |
| 15 | $this->sku = (string) $assoc->sku; |
| 16 | $this->txt = (string) $assoc->txt; |
| 17 | } |
| 18 | } |
| 19 | ?> |
Then in the AS3 side, build your value object in this simple way...
| ActionScript | | copy code | | ? |
| 01 | package com.myPackage |
| 02 | { |
| 03 | |
| 04 | [RemoteClass(alias="com.myPackage.LabelVO")] |
| 05 | public class LabelVO |
| 06 | { |
| 07 | public var note : String; |
| 08 | public var txt : String; |
| 09 | public var sku : String; |
| 10 | |
| 11 | [Transient] |
| 12 | public var valid : Boolean; |
| 13 | |
| 14 | public function set isValid (value : int) : void |
| 15 | { |
| 16 | valid = value > 0; |
| 17 | } |
| 18 | |
| 19 | public function get isValid () : int |
| 20 | { |
| 21 | return valid ? 1 : 0; |
| 22 | } |
| 23 | |
| 24 | public function LabelVO () |
| 25 | { |
| 26 | } |
| 27 | } |
| 28 | } |
One Trackback/Pingback
[...] This post was mentioned on Twitter by FileMaker Newswire, FMClub and FlexClub, Francesc Sans. Francesc Sans said: New blog posting @theflexclub Handle boolean type conversion between #FileMaker and #ActionScript http://bit.ly/cNdUhD [...]