slothg / flex-object-handles

Automatically exported from code.google.com/p/flex-object-handles
0 stars 0 forks source link

Using BorderContainer as a container object in Flex4 #53

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set BorderContainer as a container at the constructor of ObjectHandles
2. Call registerComponent() to add new item to container
3. Exception raised (with something like this info "use addElement() instead of 
addChild...")

What is the expected output? What do you see instead?
No exception raised.

What version of the product are you using? On what operating system?
ObjectHandles-2.0.0008_FLEX4.swc
Microsoft Windows XP professional sp3

Please provide any additional information below.
I changed the Flex4ChildManager.as like following and then it seems working 
fine , but I'm not sure...

--- start ---
package com.roguedevelopment.objecthandles
{
    import flash.display.DisplayObject;

    import mx.core.Container;
    import mx.core.IVisualElement;

    import spark.components.Group;
    import spark.components.SkinnableContainer;

    /**
     * A class that knows how to add and remove children from a Flex 3 based component using
     * either addElement, addChild or rawChildren.addChild
     * 
     * This class could always be used instead of Flex3ChildManager since it understand both,
     * but it won't compile under the Flex 3 SDK.
     **/
    public class Flex4ChildManager implements IChildManager
    {

        public function addChild(container:Object, child:Object):void
        {
            if (container is Group)
            {
                (container as Group).addElement(child as IVisualElement);
            }
            else if (container is SkinnableContainer)
            {
                (container as SkinnableContainer).addElement(child as IVisualElement);
            }
            else if (container is Container)
            {
                (container as Container).rawChildren.addChild(child as DisplayObject);
            }                      
            else
            {
                container.addChild(child as DisplayObject);
            }
        }

        public function removeChild(container:Object, child:Object):void
        {

            if( container is Group )
            {
                (container as Group).removeElement( child as IVisualElement );
            }
            else if (container is SkinnableContainer)
            {
                (container as SkinnableContainer).removeElement(child as IVisualElement);
            }
            else if( container is Container )
            {
                (container as Container).rawChildren.removeChild(child as DisplayObject);
            }
            else
            {
                container.removeChild( child as DisplayObject);
            }
        }
    }
}
--- end ---

Original issue reported on code.google.com by ittu...@gmail.com on 20 Sep 2012 at 3:21

GoogleCodeExporter commented 9 years ago
Sorry this issue was already added at #41...

Original comment by ittu...@gmail.com on 20 Sep 2012 at 3:26