Pixelbox

Welcome to Pixelbox. Thursday the 24 of July 2008

Skip to content >>

Binding to private vars in Flex

The Flex Logo

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.

Meta tags: AIR, Development, Flex

Changing the default loading screen in Flex

One of the first things you want to do when creating a Flex app is to remove all the default stuff, which makes your app look like everyone else’s. The most obvious default thing in Flex is that loading, progress initilisation bar you get before the application starts. Now before I start there is one thing [...]

Caculating Dates in AS3

Meta tags: AIR, ActionScript, Flex

Date conversions in AS3

I have been re factoring some stuff in action script 3 recently and the old date manipulation was a bit hacky. It included get time then adding multiples of milliseconds to epocs, which was a bit confusing. I though I would be a good idea to write a few methods in my personal utilities class, simple [...]

Apollo is dead, long live AIR!

In a rather large step backwards in marketing and buzz word… well, buzzing, Adobe have changed the name of Apollo (their code name) to Adobe Integrated Runtime or AIR. I guess you could have seen this coming as the .air extension has been used for the install files since day one, although I thought Apollo was [...]
Meta tags: AIR

Next Page »