In Addition of Rich Tretola solution

here's anothe one.


<yours:Component creationComplete="setLabel" id="labelfill"/>

<script>
public function setLabel():void
{
         labelfill.label = "my Label";
}
</script>


Best

On 2/8/07, Rich Tretola <[EMAIL PROTECTED]> wrote:

  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



--
----------------------------
Igor Costa
www.igorcosta.org
www.igorcosta.com
skype: igorpcosta

Reply via email to