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 [...]

Quick update

Fighting my way through this blog’s cobwebs I have finally managed to post!! I have been meaning to post quite a few things recently but keep running out of time, and then moving onto something else… So I thought I would write a quick update as to what’s been keeping me busy! I am currently re-writing [...]

PolarClock

I came across PolarClock today, a great flash clock that kind of rotates depending on the time. What was really interesting is that the developer has turned it into a screen saver using ScreenTime. When you change the settings on OS X you can see the flex app loading. Will have to try it out, but first [...]
Meta tags: ActionScript, Flex

Caculating Dates in AS3

Meta tags: AIR, ActionScript, Flex

Next Page »