Is there an easy way to do two-way data binding to properties of inconsistent types? In the example below, I tried to associate two properties with each other: one of type String ( text property from s:TextInput ), and the other of type Number ( bar property from Foo )
package com.example { public class Foo { [Bindable] public var bar:Number; } } <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:ex="com.example.*" > <fx:Declarations> <ex:Foo id="foo" /> </fx:Declarations> <s:TextInput text="@{foo.bar}" /> </s:Application>
Attempting to compile this code results in the following error:
1067: Implicitly coercing a String value to an unrelated Number type.
I understand why the error occurred, but I was wondering if I did not know something (maybe some Flex 4 metadata) that would allow me to try to convert between the two types and throw an error at runtime if such a conversion fails ...
source share