I’ve been trouble shooting an issue that I was experiencing in Flex for close to 20 hours now. Yup I know, what could possibly take 20 hours to work out!!?
What I’ve been trying to do is set up binding between a textfield in a state of my view, and a private variable set in that same view. I’ll post some code to better illustrate in a minute. The reason I was trying to setup this binding is because of the runtime errors I was receiving when trying to change the textfields text property from within a function of the same component. I was getting plenty of TypeError: Error #1009’s and was aware that trying to set the textfield’s text propery before the state was initialised and the textfield was actually created was what was causing the issues. I just didn’t know how to get around them.
I just now had a look at the properties you can set on a
Here’s the example showing how I fixed my problem. Right click for view source
Now I’ve still got a bone to pick with states and bindings. It seems like binding variables within a components script tags to components (ie. textfields) within state tags is nigh on impossible. That or I don’t understand how to do it.
Here’s a few links that touch on what I’m trying to do:
It seems like the bindings fire once, but then go dead and nothing entered into the textfields ends up in the getter/setter variables that I’m binding them to. I’ve tried using custome events (ie [Bindable(event=”myEventChanged”)]) with no luck, the mx:Bindings tag, change events in the textfields themselves (but then that defeates the purpose of using bindings right?). You name it I think I’ve used it, so I guess I just don’t understand how to bind to things properly in state based components.
Does anyone have any good information and or an example of how to get this working?
(I think I may have just stumbled across the reason why my initial efforts weren’t working. Pretty sure it’s to do with the Mate framework and the way it’s scoping method calls in my view. Will post some more info when I have it)
UPDATE: Ok I’ve looked at the Mate stuff and I ended up doing things in a slightly different way. Not sure if it was user error or I’ve got a legitimate qualm, no doubt the boffins at mate.asfusion.com will put me on the straight and narrow.