Skip to main content
Known Participant
October 31, 2009
Answered

Accessing a Movie Clip in a parent Scene.

  • October 31, 2009
  • 1 reply
  • 1395 views

Setup:

*Scene 1:

  - MovieClip1

  *Inside MovieClip1:

   - Actions:

     stop();

     next_btn.addEventListener(MouseEvent.CLICK, onNextButtonClicked);

     previous_btn.addEventListener(MouseEvent.CLICK, onPreviousButtonClicked);

     function onNextButtonClicked(e:MouseEvent):void {

     if (currentFrame == totalFrames) {

     gotoAndStop(1);

     } else {

     nextFrame();

     }

     }

     function onPreviousButtonClicked(e:MouseEvent):void {

     if (currentFrame == 1) {

     gotoAndStop(totalFrames);

     } else {

     prevFrame();

     }

     }

    (THIS CODE IS FOR MY NEXT AND PREV BUTTON TO CYCLE THROUGH MY PIECES OF WORK)

   Then I have...

  - Pieces of work Layer:

    This includes each piece on a single frame, with a label name. (5 total frames on this layer)

    Then I have....

    - Next and Prev buttons on a layer

    And Finally....

   - The last layer in this scene has a background frame.

***** Now inside each frame containing each piece of work there is:

       1st Layer = Actions

       Containing this code: stop();

       2nd Layer = This is the movie Clip that Fades my pieces of work in.

   ****** Inside this movie Clip of the piece of work fading in will contain:

           1st Layer = Actions

           Containing this code:

stop();

function openLabel(event:MouseEvent):void {

switch (event.currentTarget) {

case identity_cplogo_btn :

gotoAndPlay("cplogo_lv");

break;

}

}

identity_cplogo_btn.addEventListener(MouseEvent.CLICK, openLabel);

2nd Layer = 1st frame blank, then frame 2-10 contains a movieclip with a label of cplogo_lv. This movie clip is the clip that has a large view of the image popup and darken the background. (Like a lightbox effect)

3rd layer = the logo which is a BUTTON. THis is located on the first frame and is called "identity_cplogo_btn." So when this is clicked it opens the large view.

*****Now....

When I click inside the movieclip that is the lightbox effect and go inside of it there is.....

1st Layer = Actions with the code of:

stop();

function openLabel(event:MouseEvent):void {

switch (event.currentTarget) {

case lv_close_btn :

gotoAndPlay("return");

      

}

}

lv_close_btn.addEventListener(MouseEvent.CLICK, openLabel);

****After the actions keyframe, which is locate on frame 10, there is a label called "return" from frame 11-24. It is a blank label meaning there is nothing on it but the label name.

2nd Layer = the "Close" button which appears when the large view is opened and is located on frame 10 right underneath the action code.

3rd Layer = This contains the Large view of the logo, which I have made a movie clip for making it fade in then I paste reverse frames after right underneath the "return" label making it fade out.

4th Layer = Contains the Dark background that pops up which also fades in then underneath the "return" label it has its' reverse frames which are making it fade out.

SO... I have the code making it so that when the "Close" button is clicked it is going to the "return" label which is making everything fade out.

***************************** NOW WHAT I NEED TO FIGURE OUT *************************************

I need to know the code to be in the last movie clip I just explained and when I click the close button and it plays everything underneath the "return" label, THEN i need it to access the movie clip with the logo fading in so that it appears to go back to BEFORE clicking on the logo and expanding the view.

I understand that this code will be places right after the "return" label so that when the return phase plays it will then play the code making it go to this movie clip then it will stop.

I have tried

MovieClip(parent.parent).gotoAndPlay("return_2");

stop();

And giving the movieclip that has the logo fading in the "return_2" label name. THis allows it to go to that movie clip, however, it doesnt play it is just blank on the screen.
I also have tried accessing the movie clip after giving it an instance name, but it was doing the same thing.
Help PLEASE!

This topic has been closed for replies.
Correct answer Ned Murphy

Actually, from what you say, you have only one scene (which is good practice).  If I am interpreting it correctly, in that scene you have movieclip1 containing movieclip2, movieclip2 containing movieclip3, and movieclip3 containing movieclip4.  As long as that's correct, and that you are certain that you have assigned the instance name "Logo_1" to a movieclip in movieclip2 (assigned via the properties panel, not its library name), then to command Logo_1 from movieclip4's timeline, the following should work...

MovieClip(this.parent.parent).Logo_1.play();

But Logo_1 must be in the current frame of movieclip2 for that to work.

1 reply

Ned Murphy
Legend
October 31, 2009

It may be just me, but it seems like information overload trying to determine what is important with all that you describe in your posting.  Could you possibly simplify it by explaining.... " I have a movieclip that is within a movieclip on the main timeineline and want to tell this other movieclip that lives....etc...."  just an example... but a short one... easier to get the picture.

Known Participant
October 31, 2009

I actually tried a post earlier that was simplified, but I think the setup of scenes might be important....anyways, here it is.

Setup:

Scene 1 > MovieClip1 > MovieClip2 > MovieClip3 > MovieClip4

Explanation:

I am in MovieClip4, in which I have a "Close_btn" that when clicked, it takes you to label "return" (still inside MovieClip4), which then plays the movie clips in the layers below label "return." What I want it to do is....Once label "return" plays, I need the code to make it go into "MovieClip2" and play a movie clip with the "Instance" Name of "Logo_1."

I have tried this by setting a label name above the movie clip and referencing the label, however, it does access that movie clip, but it doesnt play it...It is just blank.

Hope this is understandable.

Ned Murphy
Ned MurphyCorrect answer
Legend
October 31, 2009

Actually, from what you say, you have only one scene (which is good practice).  If I am interpreting it correctly, in that scene you have movieclip1 containing movieclip2, movieclip2 containing movieclip3, and movieclip3 containing movieclip4.  As long as that's correct, and that you are certain that you have assigned the instance name "Logo_1" to a movieclip in movieclip2 (assigned via the properties panel, not its library name), then to command Logo_1 from movieclip4's timeline, the following should work...

MovieClip(this.parent.parent).Logo_1.play();

But Logo_1 must be in the current frame of movieclip2 for that to work.