A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: for each (child:someClass) in MovieClip? doesn't work!

Threaded View

  1. #1
    Member
    Join Date
    Jul 2009
    Location
    Florianópolis
    Posts
    81

    for each (child:someClass) in MovieClip? doesn't work!

    hello,

    In short:
    How can I remove all children that are instances of a given class?

    I've tried the following:

    Code:
    for each (var obj:InfoBox in infoPanel)
    {
         infoPanel.removeChild(obj);
    }
    if i do that i get this error:

    Code:
    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@4304f821 to InfoBox
    however, if i use MovieClip instead of InfoBox (for each (var obj:MovieClip in infoPanel), it works well and it removes all movieclips.

    and if i trace infoPanel.getChildAt(i) (in a loop), i get all the objects [object InfoBox] as well as the objects MovieClips.

    Why?

    thanks in advance!
    Last edited by ziriguidum; 04-08-2010 at 01:45 AM. Reason: clarify

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center