kingyiren / flex-object-handles

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

Flex4ChildManager can't work with NavigatorContent class from Flex 4 SDK #41

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. try to use NavigatorContent instance as target for object handles
2.
3.

What is the expected output? What do you see instead?
Expected working application, but i have an error,because NavigatorContent 
implements IVisualElementContainer, but not extends Group container.

What version of the product are you using? On what operating system?
Latest version from SVN

Please provide any additional information below.

In Flex4ChildManager.addChild method i have changed FROM

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

TO:

public function addChild(container:Object, child:Object):void{
if(child is IVisualElement && container is IVisualElementContainer){
    (container as IVisualElementContainer).addElement(child as 
IVisualElement);
}else if(!(child is IVisualElement) && container is IRawChildrenContainer){
    (container as IRawChildrenContainer).rawChildren.addChild(child as 
DisplayObject);
}else{
    container.addChild( child as DisplayObject);
}
}

And looks like all is working now. Added same changes to removeChild 
method:
public function removeChild(container:Object, child:Object):void{
if(child is IVisualElement && container is IVisualElementContainer){
    (container as IVisualElementContainer).removeElement(child as 
IVisualElement);
}else if(!(child is IVisualElement) && container is IRawChildrenContainer){
    (container as IRawChildrenContainer).rawChildren.removeChild(child 
as DisplayObject);
}else{
    container.removeChild( child as DisplayObject);
}
}

Original issue reported on code.google.com by burd...@gmail.com on 26 Apr 2010 at 12:25

GoogleCodeExporter commented 8 years ago
I had the same issue with spark BorderContainer

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

            if( container is Group )
            {
                (container as Group).addElement( child as IVisualElement );
            }
            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 );
            }
            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);
            }
        }

Original comment by moya.t...@gmail.com on 25 Jul 2011 at 6:39