Thanks , your method really helps, but I have another question, I was
using Expressions Window to watch the value of "myProperty" in the
Script, but it always show in this way "myProperty=...", I cannot see
the real value of the myProperty, Is there anything I can do with the
Expression window or there is something wrong with the value of
myProperty, Thanks.

can you be so nice to help me again?

Ashly

--- In [email protected], "valdhor" <[EMAIL PROTECTED]> wrote:
>
> There is a timing problem.
> 
> The script is running before myComponent is actually created so you
> get an error to the effect that you are trying to access a property of
> a null object.
> 
> The best way is to wait for the object you are trying to access to be
> created and then access it. One way is to use the creationComplete
event:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute" xmlns:local="*"
>       creationComplete="onCreationComplete()">
>       <mx:Script>
>               <![CDATA[
>                       public var myProperty:String;
>                       
>                       private function onCreationComplete():void
>                       {
>                               myProperty = myComponent.myFirstProperty;
>                       }
>               ]]>
>       </mx:Script>
>       <local:MyFirstComponent id="myComponent" myFirstProperty="Welcome to
> Flex" />
>       <mx:Label text="{myComponent.myFirstProperty}" id="myLabel"/>
> </mx:Application>
> 
> --- In [email protected], "ashlytu" <ayumimodest@> wrote:
> >
> > 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";
> > 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"; 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