Hi Tracy, 

I don't think I'm successfully storing the reference of the children 
into the array. 

This is what I had tried:

        private var moduleloader:ModuleLoader;
        private var button:Button;
        private var _aChildren:Array;

        private function click(evt:MouseEvent):void {
        tiletest.removeChild(_aChildren["one"]);
        tiletest.removeChild(button);
        }       
        
        public function AddModule():void {
        moduleloader = new ModuleLoader();
        moduleloader.url = "test.swf";
        button = new Button();
        button.label = "unload";
        button.addEventListener(MouseEvent.CLICK, click);
        tiletest.addChild(button);
        _aChildren = new Array();
        _aChildren["one"] = tiletest.addChild(moduleloader);
        }       

But I keep getting the "ArgumentError: Error #2025: The supplied 
DisplayObject must be a child of the caller." error.

Thanks again.

-David

--- In flexcoders@yahoogroups.com, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Well, you did not do what I suggested.
> 
>  
> 
> What do you think is in "moduleloader" when you click the remove 
button?
> The last thing you put in it.
> 
>  
> 
> Re-read my response.
> 
>  
> 
> Tracy
> 
>  
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
> Behalf Of sailorsea21
> Sent: Thursday, October 16, 2008 4:38 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: sailorsea21 - RemoveChild question.
> 
>  
> 
> Hi Tracy, thank you for your quick response.
> I'm a little stuck on this one... I can't get it to work...
> 
> I'm now able to load a module and unload it. But if I load several 
> modules, I'm only able to unload the latest one. 
> 
> When I try unloading the other loaded modules I receive the follow 
> error:
> 
> ArgumentError: Error #2025: The supplied DisplayObject must be a 
> child of the caller.
> at flash.display::DisplayObjectContainer/removeChild()
> at 
> 
mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::$remo
> <http://www.adobe.com/2006/flex/mx/internal::$remo> 
> veChild()[E:\dev\3.1.0
> \frameworks\projects\framework\src\mx\core\UIComponent.as:5074]
> at mx.core::Container/removeChild()[E:\dev\3.1.0
> \frameworks\projects\framework\src\mx\core\Container.as:2267]
> at content_module_template_blank/click()
> [C:\Inetpub\wwwroot\LWY\UI\UI Score\UI Score 004
> \src\content_module_template_blank.mxml:29]
> 
> This is my code: 
> 
> import mx.states.RemoveChild;
> import mx.modules.ModuleLoader;
> import mx.controls.Button; 
> 
> private var moduleloader:ModuleLoader;
> private var button:Button;
> 
> public function loadmodule():void {
> moduleloader = new ModuleLoader();
> tiletest.addChild(moduleloader);
> moduleloader.url = "test.swf";
> button = new Button();
> button.label = "unload";
> button.addEventListener(MouseEvent.CLICK, click);
> tiletest.addChild(button);
> } 
> 
> private function click(evt:MouseEvent):void {
> tiletest.removeChild(moduleloader);
> tiletest.removeChild(button);
> } 
> 
> <mx:Tile width="100%" height="100%" id="tiletest"/> 
> <mx:LinkButton label="Load" click="loadmodule()" buttonMode="true"/>
> 
> Thank you very much.
> 
> -David.
>


Reply via email to