The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 3 of 3

Thread: Trouble with gotoAndPlay and movieclips

  1. #1

    Trouble with gotoAndPlay and movieclips


    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(
    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:

    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,

  2. #2
    TheCanadian's Avatar
    Noo doot aboot it, eh?
    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 . . .

  3. #3
    Thanks 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,

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012