This content has been marked as final. Show 17 replies
you must wait until your movieclip exists before trying to reference it with actionscript.
so, you can put that swapDepths() statement in frame 2 of the timeline where the target movieclip exists or you can use a time delay to encode the swapDepths() just after your gotoAndPlay(3) statement.
no, i did apply the script example to the second frame. well, i actually applied it to the invisible button in the second frame.
how would I script a time delay? or do you just mean placing swapDepths() after the gotoAndPlay command?
what movieclip are you trying to target (with your swapDepths()?
does it exist when you execute your swapDepths() statement?
I am targetting casen1, and the button this script is attached to is in the second frame of casen1, so yes it must exist. and as i am using this script on a button, i thought targetting it was the right syntax, as I cannot use 'this.'
P.S As there are 6 clips i need to do this to, I am using a value for swapDepths rather than targetting ANOTHER clip for me to swap with
why can't you use "this"?
if that's a true button, you can't use "this" to reference the button, but then you can't use swapDepths() on a button anyway, so that makes no sense. or maybe it does make sense and explain your problem.
if that's a movieclip button you can use "this" and you can use swapDepths().
well, i tried converting the image in the second frame of the movieclip into ANOTHER clip and applying an on(release) script to that, but it didn't work, and it complicates it more.
is there a way to attach script to the moviclip so that when the invisible button is clicked, swapDepths is applied.
I know about OnClipEvent, is there an equivelant for buttons?
you can use swapDepths() on your movieclip, but not on your button.
and you can't use onClipEvent() for a button and there is no equivalent.
can it (swapDepths) be applied to a frame of a movieclip?
no, but you can accomplish the same thing by using this.swapDepths() on the appropriate frames of your movieclip.
this may sound convoluted but variables have worked for me before.
the button on frame 2, say i declare a variable on its release, then in frame 3 of my MOVIECLIP script:
do you think that sounds workable?
yes, that would work.
thankyou, but as there are six different clips, all in close proximity, i think i need to use the value of depth rather than a specified clip
you can use a variable for the swapDepths() parameter.
the variable worked! great :D
thanks for all your help!
You CAN use swapDepths() on buttons.
But WHY anyone would use buttons is beyond me. :)