The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 2 of 2

Thread: getChildAt (strict/normal) problem

  1. #1

    getChildAt (strict/normal) problem

    for example i have a public class Title with publicfunction destroy(); in it
    than in my main class i create 1 sprite and some Titles than i sprite.addChild(title) for every title i have created which works ok.
    i have tried invoking destroy method manually and it also works fine but when i try the following code flash builder reports error
                while(sprite.numChildren > 0){
    error: 1061: Call to a possibly undefined method destroy through a reference with static type flash.displayisplayObject.

    I think the problem might be builder mybe can't know that every child of sprite will be able to provide destroy(); method ( or in other words it shall be instance of class Title) ... but how to tell him that it's ok without exiting strict mode?

  2. #2
    If you're sure that that child is going to be a Title, use something like this:

    (sprite.getChildAt(0) as Title).destroy()

    …but be careful of the order in which you remove things and reference them later. In your code, you're removing one child and then trying to call destroy on subsequent child of sprite… which won't exist during the last iteration of that loop.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012