You can only do simple initialization of vars outside of a function.  If
you try, you can get a null object reference.  (please give the text of
the error, I do not have the numbers memorized)

 

Put that variable assignment into a function, like init() and call it in
a creationComplete handler.

 

Tracy

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of ashlytu
Sent: Tuesday, November 04, 2008 10:16 PM
To: [email protected]
Subject: [flexcoders] hi! this examples didn't work out,please help

 

when I read "the Essential guide to flex 3"
from page 87 to 95, there is a example , in the application MXML ,the
code is

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
layout="absolute" xmlns:local="*">
<mx:Script>
<![CDATA[

public var myProperty:String = myComponent.myFirstProperty;

]]>
</mx:Script>
<local:MyFirstComponent id="myComponent" myFirstProperty="Welcome to
Flex" />
<mx:Label text="{myComponent.myFirstProperty}" id="myLabel"/>

</mx:Application>

and in the component file :MyFirstComponent ,is just these code below:

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " width="400"
height="300">
<mx:Script>
<![CDATA[
[Bindable]
public var myFirstProperty:String;
]]>
</mx:Script>
</mx:Canvas>

I followed all the steps, and would like to view the value of
"myProperty" in the script section of the Application MXML file, in
the Expressionis frame, but the error was "TypeError: Error #1009:",
It's seems like "myProperty" cannot get the value from a object
attribute.

what is wrong with it?
Thanks a lot!

Ashly

 

Reply via email to