0

I'm trying to learn Flash builder 4.5, and now I'm stuck with this question.

I got this code:

<fx:Script>
    <![CDATA[
        public function showList():void
        {
            tier2.x=(this.x+this.width);
            tier2.y=(this.y+this.height);
            tier2.visible=true;
        }
    ]]>
</fx:Script>

// on mouseover I'm calling function showList()
<mx:LinkButton x="10" y="20" width="143"
               label="Class 1" id="t_id1"
               mouseOver="showList()"
               color="#FFFFFF" fontFamily="Arial" fontSize="16" fontWeight="bold"/>

<s:List id="tier2" visible="false" width="111" borderColor="#FEFEFE"
        borderVisible="true" color="#FAF3F3" contentBackgroundAlpha="0.5"
        contentBackgroundColor="#5D5E5E">
</s:List>

In function showList() I'm trying to move the list to the linkbutton on mouseover.

How can I get the linkbutton's x and y position?

ketan
  • 19,129
  • 42
  • 60
  • 98
Cyr
  • 77
  • 6
  • That's not the right approach in Flex. #1 Use a vertical layout to display it on the bottom of the component. #2. It is part/inside of the component so it can't put blow it on the screen. #3. If it's a SkinnableContainer (-sublcass), the list will be displayed in the component's skin. So it (the layout to be precise) will decide where the component is displayed. – Florian Salihovic Oct 22 '13 at 09:58
  • Thanks, I'm still learning so I did not quite understand most of that but I'll try to figure out. Anyway should I position the list in the bottom of linkbutton? If I have like 5 linkbuttons then I have to have 5 lists too? – Cyr Oct 22 '13 at 10:10
  • Well, you pointed out two problems: displaying the list below the link button and having as many lists as buttons with the same layout (1. button, then list). You should create a new component with s:Group as type. Add an s:layout of type s:VerticalLayout and then add the link button and the list. This way you'll have a generic component which fits your needs. Accessing the sub components is then a new task of its own, but simply adding properties to the Group and then bind the button and the list to them will do the task. – Florian Salihovic Oct 22 '13 at 10:22
  • Also, you don't need `this.x` - just use `x` – Alexander Farber Oct 23 '13 at 15:33

0 Answers0