Question

I want to create a list with flash cs3 using the accordion component (the user clicks on a row, and the row expands). The icon of the header is a movieclip "My_icon":

var oAccordion_1:Object = oAccordion.createChild("Datasheet", "Icon", {icon:"My_icon"});

Movieclip "My_icon" contains a dynamic textfield with the instance name "lblHead". No I want to change the text of the textfield like this:

oAccordion_1.icon.lblHead.text = "mytext";

But trace(oAccordion_1.icon.lblHead) gives undefined. However trace(oAccordion_1.icon) gives me "My_icon".

Any idea how I can access lblHead inside the header mc?

Thanks.

Btw. I know the accordion has a label itself, but I want to have more than just a label inside my header.

Was it helpful?

Solution

Unfortunately, there's not a clean and easy way to dynamically tweak the icon innards. An accordion header is just a Button instance, and the Button icon logic is complex and intertwined with the skinning support. Specifically, the Button creates many copies of the icon for the different button states.

But here's a trick: Have the icon change itself. On frame 1 of the My_icon MC, put this code:

lblHead.text = _parent.content_mc.lblHeadText;

Then add that parameter to your createChild call:

var oAccordion_1:Object = oAccordion.createChild("Datasheet", "Icon", {icon:"My_icon", lblHeadText:"Blah blah"});

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top