Using Bindable variables and properties in Flex (Action Script 3) is great, it saves a huge amount of time adding events left right and center. However today I had a problem where I wanted to use a setter for a variable. In order to do this I made it private and used a getter and setter function, allowing me to add some logic when setting the variable.
The problem however is that private variables are unbindable. You will get a warning on anything bound to it, saying it will not see changes. There is a very simple way to get around this, but making the getters and setters bindable.
[Bindable]
public function set yourVar ( s : String ):void
{
//Some logic can go here
_yourVar = s;
}
public function get yourVar ( ):String
{
// Some logic perhaps
return _yourVar;
}
By putting the [Bindable] tag before the function (I assume you only need it above one), any variables bound to yourVar will work. You don't need a [Bindable] before your declaration of the private _yourVar and you should use yourClassInstance.yourVar when binding, rather than _yourVar.
Hope that helps someone.
There are often blog posts and message on mailing lists from people saying how much they hate page turning applications. The general vibe from digital natives is negative, however from the general population it’s the opposite. In a similar way you may have problems getting a huge coffee fan to drink instant coffee, or Jeremy [...]
This is a handy little function that returns the date suffix in AS3. By date suffix I mean those little letters at the end of the day of a date, such as st, rd, nd or th.
Typically languages don’t by have a function like this as the date suffixs are specific to language ( although [...]
Last Friday I got my hands on Mario Kart Wii, the latest incarnation of the Mario Kart series!
During my University days Mario Kart was a staple diet for gaming nights, especially with the more casual gamers. In a strange road map from Nintendo they only release the game once per console (rather than every 6 [...]
I often find files that are depreciated but never deleted, “just in case” something somewhere is still using them. This normally leads to files getting left for ages, and there is a risk that at some point someone will take over the project and have no idea they are depreciated.
In order to calm those fears [...]