1
votes

In my timeline, I have a 'background' layer, an 'actions' layer and a 'play' layer (all have just 1 frame). The background layer has a MovieClip called backgroundMC and when you double click the MovieClip, there is a MovieClip called analysisScreenMC. In the timeline for analysisScreenMC, there is a folder called 'Title Bar' and inside 'Title Bar' there is a layer called 'answers' which has a motion tween which makes analysisScreenMC fade out to 50% in a span on 15 frames.

The 'play' layer just has a MovieClip called playButton.

Now, when playButton is clicked, I want to play analysisScreenMC so that it fades out. Here is what I tried.

import flash.events.MouseEvent;
import flashx.textLayout.formats.Float;

function playButtonClicked(evt:MouseEvent):void {
    analysisScreenMC.play();
}

playButton.addEventListener(MouseEvent.CLICK, playButtonClicked);

when I run this, it gives me an error saying 'Access of undefined property analysisScreenMC.'

Any idea on how to fix this?

Note: I am using Adobe Flash CS 5 and Actionscript 3.

Edit: When I put

trace("backgroundMC="+ backgroundMC+", backgroundMC.analysisScreenMC="+ backgroundMC.analysisScreenMC);

inside the

function playButtonClicked

this is what it traces

backgroundMC=[object analysisScreenInside_1], backgroundMC.analysisScreenMC=[object MovieClip] 

analysisScreenMC is the instance name of analysisScreenInside

1
Is the code you shared located on the actions layer? - Anil Natha
@SlyRaskal yes the code is in the actions layer in the main timeline. How do I tell it that analysisScreenMC is inside the background layer / inside backgroundMC? - user2817200
Please verify that you have accurately described the hierarchy of your MovieClips. The example I created on my machine for the answer I posted based on your description worked fine on my computer, which leads me to believe that there may be something that needs more clarification. - Anil Natha
@SlyRaskal main timeline there is 'actions' layer, 'playButton' layer and 'background' layer, in that order (from top to bottom). All three only have one frame. Actions layer has what I posted above in the question. playButton layer has playButtonMC. Background layer has backgroundMC. Inside backgroundMC, there is analysisScreenMC, which is has actions layer consisting of 1 frame and an 'answers' layer. Actions layer just has 'stop();'. 'answers' layer is a motion tween which makes analysisScreenMC fade out. You can also click inside analysisScreenMC to view a bitmap image. Does that matter? - user2817200
@SlyRaskal can you post the example you created on your machine? Or would it be possible for you to upload it so I can download it? - user2817200

1 Answers

2
votes

Try the following code. I dupcliated your file on my system and this code appears to work just fine.

import flash.events.MouseEvent;
import flashx.textLayout.formats.Float;

function playButtonClicked(evt:MouseEvent):void {
    backgroundMC.play();
}

playButton.addEventListener(MouseEvent.CLICK, playButtonClicked);

The key here is that your reference to the location of where analysisScreenMC is located was incorrect.