View Full Version : static variables bindable?
Hi
I am just wondering if static vars inside classes can be bindable. Because I thought it's easier this way than passing parameters to every other components.
package {
[Bindable]
public class StaticClass{
static public var test:String ="test"
}}
<mx:Label text="{StaticClass.test}"/>
Above code only disptch event at startup. So maybe I need to add dispatcher manually? Or is there some method that makes things easier?
Thanks.
hangalot
06-04-2007, 11:31 AM
you should not be able to bind to a static member.
the reason fot that is that binding needs to dispatch events and static members well just think about it somemore :)
however binding to variables on a singleton works very nicely and i wopuld recomend looking down that route.
Thanks for your reply. I made a singleton and it works perfect.
I never had a chance to find any sense using singleton before, since using static variables is just far easier. :rolleyes:
hangalot
06-04-2007, 12:23 PM
if you look at the way binding works you will understand. its pretty interesting actually, and gets handy when you are developing a bigish flex app.
as a side note don't go and make singletons of everything now!! thats not the way to go, look at how architectures like ARP or Cairngorm solves this problem (and in truth i don't agree with eithers approach 100% but thats a loooong conversation)
I've heard of Cairngorm but I did't know that's for making binding easier.
I'll check those tutorials on adobe's web site. Thanks.
hangalot
06-07-2007, 10:07 AM
cairngorm does not specifically make binding easier, but it makes your app design consistant and in the long run easier to understand and maintain. added to that it has best practises which include binding well spelt out
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.