|
Instance variable assignment in the declaration
is always dangerous because dependencies are generally not tracked for
initialization purposes. Assigning the variable in a function that’s
called later (like creationComplete or even initialize) is considered the
best-practice. Matt From: OK, help me out here, 'cause I've been scratchin' my head a little
too hard on this one... What I'm trying to do is setup a simple static class to use as a
pointer to my main, global model, from within my MXML components. I've
been running into some "interesting" behavior that I can't explain,
and I'm wondering if anyone can help shed some light. (Couldn't
find much help in the docs or forums) I'm seeing that when I'm at the <mx:Application> level and I try
to bind to a "global" variable that is initialized from the static
class I mentioned above, no binding takes place unless I initialize the var
after creationComplete(). This is NOT required however, when I'm trying
to use the same type of binding in a component. (The var seems to
initialize fine) I should mention that I've also tested this using a "normal"
class ( var resource:String = new com.StaticResource().test;), and also a
singleton class ( var resource =
com.StaticResource.getInstance().test;). No difference. Any thoughts? <<<< Sample Code >>>> <!-------------------- StaticResource.as ----------------------->
<!------------------------------------------------------------------------> <!-------------------- testStaticBinding.mxml
---------------> <?xml version="1.0" encoding="utf-8"?>
<!------------------------------------------------------------------------> <!------ testStaticBindingComponent.mxml---------------> <?xml version="1.0" encoding="utf-8"?> <!------------------------------------------------------------------------> Also, how are ModelLocators typically implemented using the Cairngorm
framework?
|
- RE: [flexcoders] Variable Initialization Bug? Data Binding... Matt Chotin

