Skip to main content

as3 quick q 77 Responses

Last post: 8 months, 3 weeks ago | Thread started: Mar 6, 08, 7:25 a.m.

RespondNew TopicDisable Images

Out of context: Response #5 [Mar 6, 08, 7:25 a.m.]

  • enjine

    there is a method to do this on every subclass of DisplayObjectContainer (i.e. Sprite, MovieClip, ...). From the language reference:

    Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. The search includes the entire display list including this DisplayObjectContainer instance. Grandchildren, great-grandchildren, and so on each return true.
    Parameters
    child:DisplayObject — The child object to test.

    Returns
    Boolean — true if the child object is a child of the DisplayObjectContainer or the container itself; otherwise false.

    Example
    The following example sets up a number of Sprite objects and adds some to the child list of others. (A Sprite object is a type of display object container.) The relationship between various objects is shown by calling the contains() method:

    import flash.display.Sprite;

    var sprite1:Sprite = new Sprite();
    var sprite2:Sprite = new Sprite();
    var sprite3:Sprite = new Sprite();
    var sprite4:Sprite = new Sprite();

    sprite1.addChild(sprite2);
    sprite2.addChild(sprite3);

    trace(sprite1.contains(sprite1… // true
    trace(sprite1.contains(sprite2… // true
    trace(sprite1.contains(sprite3… // true
    trace(sprite1.contains(sprite4… // false

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel

Skip to main content