Hi Rich,

This is just a test case of mine. I want to set the label of the button using 
script, inside the component. Forget trying to set it in the main application.
There are no compile errors in the component code (make the id of the button 
whatever you wish), until  the component is included in the main application. 
At that time any reference to the button is not recognised as a valid property 
by the compiler, though the code hinting obliges nicely!

Paul
  ----- Original Message ----- 
  From: Rich Tretola 
  To: flexcoders@yahoogroups.com 
  Sent: Thursday, February 08, 2007 9:53 AM
  Subject: Re: [flexcoders] properties in components..


  The 1st problem is that you can not name your button id x as it is a reserved 
word.


  Not sure what you are trying to accomplish. If your goal is to be able to set 
the label from the main application, you should do something like this: 


  <?xml version="1.0" encoding="utf-8"?>
  <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"; width="400"
  height="300"> 
  <mx:Script>
  <![CDATA[
      [Bindable]
      public var myLabel:String="jim";
  ]]>
  </mx:Script>
  <mx:Button id="x1" label="{myLabel}"/>
  </mx:Canvas> 



  <?xml version="1.0" encoding="utf-8"?>
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" 
xmlns:local="*"> 
      <local:Test myLabel="Rich"/>
  </mx:Application>

  Rich




  On 2/8/07, Paul Andrews < [EMAIL PROTECTED]> wrote:
    OK, this is driving me nuts. I'm using Flex Builder 2.01 on a PC.

    I have a very simple component (say test.mxml), code below, where I set a 
    label value on a button using actionscript.

    I can get this to compile very simply and we're all happy.

    As soon as I edit the main application(main.mxml) to include this component:

    <comp:test>
    </comp:test>

    main.mxml is happy but now I get a compile error (access of undefined 
    property) in test.mxml saying that the button id is an undefined property.
    When I edit the test.mxml code, flexbuilder will happily give me code hints 
    about the properties after I've put in the button id.

    What's going on? Maybe I just need more coffee?

    Paul

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"; width="400" 
    height="300">
    <mx:Script>
    <![CDATA[
    x.label="jim";
    ]]>
    </mx:Script>
    <mx:Button id="x" label="fred"/>
    </mx:Canvas>






  -- 
  Rich Tretola
  <mx:EverythingFlex/>
  http://www.EverythingFlex.com  

Reply via email to