The problem is that we don’t know
the type of nestedObject. So you need to either use a class, re-declare the
Model, or use casting.
Since this is all based on a Model in the
parent it might be easiest to do something like this instead of the var
declaration:
<mx:Model id=”myModel”
/>
Now binding will know it’s working with
a model and can adjust accordingly. If you type a property as object we only
assume we know about a property one level down. So you’d need to cast to
keep going.
Attr=”{Object(myModel.nestedObject).fName}”
As for instantiating the var next the
variable declaration you can’t do it in AS. I just posted an example
with Dates that shows what you need to do.
And remember that the compiler knows about
types based on the declaration (var foo : Object), not how you instantiate it.
Matt
From: Scott Barnes
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 23, 2005
3:29 AM
To: [email protected]
Subject: Re: [flexcoders] Passing
Models into MXML components...
> What's the error?
"Changes to unknown property, firstName will
not be detected."
> Are you working with strongly typed
objects? If so, does
> the object have the properties you're trying
to access declared?
No, as at the present inside mx:Script you can
only initialize top
level variables (probably not correctly worded).
ie:
public var myModel:Object = new Object();
myModel.nestedObject = new Object(); // This line
causes an error to occur.
So down in the code if make reference to a binding
like
attr="{myModel.nestedObject.fName}" it
throws an error like:
"Changes to unknown property, firstName will
not be detected."
but if i can initialize at the very least
myModel.nestedObject (even
though no reference to fName occurs other then the
intended binding)
it should work - but - i cannot figure out a way
to initialize a
variable in the construct space (ie i can't
over-ride a MXML
components construct function and putting that
into an initialize()
method still won't fix its binding
exceptions....*pant*...
> The key to binding is to use strong types (as
Tracy pointed
out). There are
> other binding debugging tips listed on my
blog and in the docs (which for
> 1.5 is actually an updated version of my old
blog post).
>
You have a blog? ;) hehe i'll hunt around now but
i'm telling ya, i
think its not gonna work out as planned. I've
adopted a different
approach now, in that i have a "helper"
if you will that will
initialize my intended controls instead of a lazy
bind solution i was
originally shooting for....
--
Regards,
Scott Barnes
http://www.mossyblog.com
http://www.flexcoder.com
(Coming Soon)
| Yahoo! Groups Sponsor |
ADVERTISEMENT
![click here]() | |
![]() |
Yahoo! Groups Links