-
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
-
What happens when you try this:
PHP Code:
container.getChildAt(i).accent_mc.visible = false;
-
Senior Member
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. -
-
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?
-
Senior Member
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. -
-
that works fine, thanks a lot!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|