This content has been marked as final. Show 12 replies
When you do this:
<custom:Button_Component id="comp" height="87" initialCount="true,false,true" />
The Flex Framework will set the properties of the component before it will create its children (technically, the setting of properties and the creation of children can be somewhat mixed, but the point is you cannot rely on the children being created before any properties are set).
The initialCount property function is being called which then tries to change visible properties of the children; the children are not created yet and are thus null.
Property setter and getter functions should not change the properties of UI children. Instead, have those functions call invalidateProperties() and override the commitProperties() function. Inside of commitProperties() you can then set those childrens' properties. This is a standard technique used throughtout the Flex source code.
Could please explain how i need to add the code in my mxml . it'll be helpfull for me ...
There are 10 mxml file are there . each file contain three button , so user need to call the component file when he need the three button are two button by setting the property initialCount="true,false,true" .
In the component, you can add a Event Listener and Handler for the creationComplete Event (which is triggered after all children have been created), and then in the Handler Function, set the visible property of each button to the value in the initialCount Array (see attached code). This is how I usually handle cases like this.
Thanks for ur reply
but i am facing some problem initialCount="false,true,true"
var _mySubArray:Array = _initialCount.split(",");
vans_but.visible = Boolean(_mySubArray);
try_but.visible = Boolean(_mySubArray);
sol_but.visible = Boolean(_mySubArray);
it is not working.if i pass the value like this means initialCount="0,1,1" it's working fine.
where i did the mistake
This does NOT convert a string to a boolean:
It tests for non-null.
Instead do this:
vans_but.visible = (_mySubArray == "true");
Thanks it's working fine..
but after if i pressed any three button i need make visible for clickable one
hw i need to pass the array comp.initialCount="true,false,true"; is it the correct way
Do you have to use a String or can you use an Array of 3 Boolean: initialCount="[true,false,true]" ? This would eliminate the need to turn the Strings into Booleans. Then you would have something like vans_but.visible=initialCount; making your code a lot simpler.
thanks for ur answer it's working fine.but if i need to pass the value like this
when i pressed any button comp.initialCount="false,true,true"; it's not working fine. can you help me hw to solve this issue
Why would you want to pass a string when an Array of Boolean would be so much easier:
Actually i have used this ="[true,false,true]" in anchor tag
<custom:Button_Component id="comp" height="87" visibility="[true,false,true]" x="304" y="514" />.
it's working fine .
But if i pressed the answer button remaining two button are become invisible i.e( try_but ans sol_but). so hw should i call the function
i got the error like this
1067: Implicit coercion of a value of type String to an unrelated type Array.
i do't know where i did the mistake . if you could help me then it'll be very much need full for me
without the quotes.
hi Peter Ent,
i did't get any success, i have used this line comp._initialCount=[true,true,false]; . but it's not working