Results 1 to 3 of 3
-
April 7th, 2012, 12:18 AM #12Registered User
postsTrouble with gotoAndPlay and movieclips
hello,
I have been working on a product design portfolio in flash CS5.5, and have run into some trouble with my AS. I managed to eventually fix the problem, but was hoping to get some feedback as to why it wasn't working in the first place.
I have a movieclip
I have a button(btn_01)and a movieclip(P_01) on the main timeline. The P_01 movieclip contains an empty stop frame on frame 1. From frame 2 to 20 an image fades in and stops at 20, then 20 to 40 the image fades out:
Daniel
This works:
this.btn_01.onRelease = function (){
if(this.P_01._currentFrame <= 20){P_01.gotoAndPlay(21)}else{P_01.gotoAndStop(20) }
This Doesn't:
this.btn_01.onRelease = function (){
if(this.P_01._currentFrame <= 20){this.P_01.gotoAndPlay(21)}else{this.P_01.gotoAndStop(20)}
I would prefer to keep the scripting relative to its location with the "this." function, as I want to keep all the scripting contained within the movieclip.
thanks in advance,
-
April 7th, 2012, 01:46 AM #2
this contextually refers to different things. Outside the function, this refers to the MovieClip on who's timeline the code was written. Here, I think it would be the main timeline, _root, but your description was confusing to me. Inside the function, this refers to the object in which the function is defined. So in this case, inside the function, this refers to _root.btn_01. In essence, you're writing _root.btn_01.P_01.
Proud Montanadian
We tolerate living and breathing. And niches.
Name Brand Watches
Maybe getTimer() or TweenMax is the answer to your problem . . .
-
April 7th, 2012, 03:32 AM #32Registered User
postsThanks for the reply 'The Canadian'. I originally posted it as I was running out the door, and now reading it I can see the confusion. Your reply made sense and is very helpfull.
Thanks again,
Daniel

Reply With Quote

Bookmarks