• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 870
  • Last Modified:

Setting depths in Flex 4

Flash Builder 4 is telling me I should use setElementIndex instead of the usual setChildIndex, but that doesn't seem to be working. Any advice would be welcome.

Her is the format I would be using, when a button is pressed:

                  protected function setDepths(event:Event):void{
                        var clip = event.target;
                        this.setElementIndex(clip, this.numChildren-1);
                  }

Devin
0
devinvail
Asked:
devinvail
2 Solutions
 
cconstable_workCommented:
I believe it is numElements:
this.setElementIndex(clip, this.numElements-1);
0
 
tomaugerdotcomCommented:
I'm not exactly sure what your code is trying to accomplish, but I'm guessing you want to bring whatever element has been clicked on to the FRONT of the collection within its parent visualElementContainer.

If that's the case, I'm guessing there's a slight error in your logic.

Assuming that the event listener is on one of the child IVisualElement objects within an IVisualElementContainer...

protected function bringToFront(event:MouseEvent) {
  var visElement:IVisualElement = event.target;

 // visElement.parent returns type DisplayObject, so let's cast it as an IVisualElementContainer
 // (I have not tested this)
  var parentContainer:IVisualElementContainer = IVisualElementContainer(visElement.parent);

  parentContainer.setElementIndex(visElement, parentContainer.numElements - 1);
}

So the salient difference in my code is that I'm calling setElementIndex on the parent container, not on the element that was clicked. Not sure if this aligns with the way you intended to use the event handler.

T
Hope this puts you on the right track...
 
0
 
CyanBlueCommented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now