Hello,

Can any body guide me what is the right syntax of removeChild
function. Please see my below code, the initApp  will draw a map on
the screen, and redrawXmlDataMap map is suppose to erase the current
map and create a new one. My problem is i was mot able to remove the
current map and two mpas are showing in the screen.

Thanks in advance

--
Mithun


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
    layout="vertical" backgroundColor="0xffffff"
    creationComplete="initApp()">
    <mx:Script>
        <![CDATA[
                        import mx.controls.Alert;
                        import flash.display.Sprite;
                        import flash.external.*;

                        // Need to keep the object state as we need to modify 
the same
object
                        // via different interface interaction calls
                        private var bpMap: BrandPreferenceMapComponent;
                        public function showXmlDataMap():void {
                                // External JavaScript calls will be mapped to 
this function
                            bpMap.showMap();
                        }
                        public function redrawXmlDataMap():void {
                                // External JavaScript calls will be mapped to 
this function
                                this.removeChild(bpMap);  // HERE IS MY 
PROBLEM,  THIS CALL DOES
NOT REMOVE THE CHILD
                                var xml: String = 
ExternalInterface.call("BPM.Flex.getXmlData");
                                bpMap.setXmlData(xml);
                                bpMap.initUI();
                                bpMap.showMap();
                                this.addChild(bpMap);
                        }

            public function initApp():void {
                //ExternalInterface.call("BPM.debug('Flex: init App
called')");
                // Add the Javascript call back
                ExternalInterface.addCallback("showXmlMap",
showXmlDataMap);
                ExternalInterface.addCallback("redrawXmlMap",
redrawXmlDataMap);
                // Get the avialble screen width from Javascript
                var w: int = ExternalInterface.call
("BPM.Flex.getScreenWidth");
                // The below function will get XML date for Flex
application form HTML DOM
                    var xml: String = ExternalInterface.call
("BPM.Flex.getXmlData");
                    // Instantiate the new Map Component
                bpMap = new BrandPreferenceMapComponent();
                // Set the positions and diamenstions
                    bpMap.x = 0;
                    bpMap.y = 0;
                    bpMap.height = 400;
                    bpMap.width = w;
                    // Save the external xml data to componets own internal
memory
                    bpMap.setXmlData(xml);
                    // Start creating button, fileds only after object gets
the xml data
                    bpMap.initUI();
                    // Only Now try to draw the canvas, double check the
existance of object in JS code too
                    ExternalInterface.call("BPM.Flex.showMap");
                    // Direcly show the map without any user interaction
                    // bpMap.showMap();
                    // Add the componet to application
                    this.addChild(bpMap);
            }
        ]]>
    </mx:Script>
</mx:Application>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to