I'm just starting to play with XML objects in
Actionscript/Flex. I have a VERY simple test that I cannot get
working. Code and errors follow...any help is much appreciated.
[EDIT] Ignore the mismatched case on the myXml variable, it's
correct in my code [/EDIT]
The last line of the script generates "1120: Access of
undefined property alsoWorks".
It seems that if I create a new variable as I try to call the
"appendChild" function, everything is fine. But if I try to call
the function without creating a new variable, I get the 1120 error.
I've tried public and private variables, as well as unscoped.
Nothing seems to resolve this.
Not sure if this is just a snippet of code from a much larger
body, but at present you are not inside a function of any kind so
the compiler will be basically expecting declarations rather than
statements. Your line
public var alsoWorks:XML
is essentially a declaration albeit with initialisation as
Have you tried putting the alsoWorks = ... line into an
actual function (maybe called on creationComplete or some such) and
seen whether it works under these conditions?