A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: finding a instance in a movieclip with a class

  1. #1
    Junior Member
    Join Date
    Nov 2000
    Posts
    17

    finding a instance in a movieclip with a class

    hi,

    In the document Class I've put several buttons in a container, it all works well. These buttons are movieclips in de .fla (linkage). Inside this movieclip there's this accent_mc which is just another movieclip with the instance name: accent_mc. This upAction for all the buttons works also fine, so line 5 and line 8 are doing "the job" (one button jumps to the right).

    In line 6 I'm trying to reach the accent to be visible... how come it's not working? ( Error #1123: Filter operator not supported on type Knop1. at Main/upAction()

    1. private function upAction (evt:MouseEvent)
    2. {
    3. for ( var i:int= 0; i < numberButtons ; i++)
    4. {
    5. container.getChildAt(i).x = 0;
    6. container.getChildAt(i).(getChildByName("accent_mc ") as MovieClip).visible = false;
    7. }
    8. evt.target.x += 10;
    9. }

    Could anyone help me a bit? Do I have to send more script first?

    Thanks a lot!!
    Jean-Francois
    jean-francois

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    What happens when you try this:
    PHP Code:
    container.getChildAt(i).accent_mc.visible false

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    It has to be

    MovieClip(container.getChildAt(i).getChildByName(" accent_mc ")).visible = false;
    You need to cast the whole expression.
    - The right of the People to create Flash movies shall not be infringed. -

  4. #4
    Junior Member
    Join Date
    Nov 2000
    Posts
    17
    Thanks a lot for the suggestions.

    I did try before:
    container.getChildAt(i).accent_mc.visible = false;

    but this gives the error: 1119: Access of possibly undefined property accent_mc through a reference with static type flash.displayisplayObject.

    And:
    MovieClip(container.getChildAt(i).getChildByName(" accent_mc")).visible = false;

    gives error: 1061: Call to a possibly undefined method getChildByName through a reference with static type flash.displayisplayObject.

    I've now put a relative path:
    evt.target.parent.getChildByName("k" + (i+1) + "_mc").accent_mc.visible = false;

    This works fine!

    Still I don't know what's wrong with the other scripts. Is it enough if you manually put an instance inside a MovieClip (in the fla)? Or do I need to add "that" also in the class?
    jean-francois

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    The error 1061 is thrown, because container.getChildAt(i) does not have such a method. You can try once this
    MovieClip(container.getChildAt(i)).getChildByName( " accent_mc").visible = false;
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Junior Member
    Join Date
    Nov 2000
    Posts
    17
    that works fine, thanks a lot!
    jean-francois

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