Nice one :)
What you do with removeChildAt is that you remove a child at a specific index (number), you get this index by using the getChildIndex ( stringname of displayobject)

Cheers,

Sid

On Apr 24, 2008, at 4:26 PM, ACE Flash wrote:

buddy,
It works. :) removeChildAt(getChildIndex( targetToRemove )); should be
removeChild @v@

I appreciate that all of your posts in the topic .

Thanks ALL! :))



On Thu, Apr 24, 2008 at 10:00 AM, Sidney de Koning <[EMAIL PROTECTED] >
wrote:

try doing this, it should work:

import flash.text.TextField;
var _pValue:TextField;

function createNavigatorButton( txt:String ) {
      _pValue = new TextField();
      _pValue.text = txt;
      _pValue.backgroundColor = 0x000000;
      _pValue.x = 60;
      _pValue.y = 400;
      addChild( _pValue );
}

function removeNavigatorButton( txt:String ) {
      //_pValue = "_"+pValue;
      _pValue.name = txt;
      var targetToRemove:DisplayObject =
this.getChildByName(_pValue.name);

      trace(getChildIndex( targetToRemove ) )
      removeChildAt(getChildIndex( targetToRemove ));

}

createNavigatorButton( "Flash" );
removeNavigatorButton( "Flash" );



On Apr 24, 2008, at 3:48 PM, Andres Garcia wrote:

this line:

_pValue = DisplayObject("_"+pValue);

has the problem.... you are casting from string to displayObject...

you can try something like:

createnavigatorButton(pValue:String){
      ...
      _pValue.name = pValue;
      ...

}

function removeNavigatorButton( pValue:String ) {
...
      _pValue = DisplayObject(this.getChildByName("_" + pValue));
      this.removeChild(_pValue);
...
}
On Apr 24, 2008, at 8:30 AM, ACE Flash wrote:

Hi there,

I would like to define a variable, so I could pass any name to
createNavigatorButton and using removeNavigatorButton to remove it.

I wrote a simple code here  http://www.privatepaste.com/e8tI4OgtHg,
but I
got an error msg => TypeError: Error #1034: Type Coercion failed:
cannot
convert "_Flash" to flash.display.DisplayObject.


Any suggestion?

Thanks you
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to