Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top