Copy link to clipboard
Copied
Hi - I'm looking for a way to layer several movie clips on top of each other so that when the corresponding button is clicked a specific movie clip is called forward and plays. If the 3rd button (startButton3) is clicked, you see the purple movie clip play on top of the other two movie clips. I've seen some forum Q&A about parent/child code but I can't quite understand how or where to add it, I'm definitely an AS3 novice, any guidance is much appreciated!
Here's the current code I'm using, everything needs to be able to operate as it does now, just with the additional functionality that although "Green" movie clip is layered on top when startButton2 or startButton3 is selected that the appropriate movie clip (Blue or Purple) would then move to the top and play. I've attached the files if it helps.
TESTINGlayeredClips_2.swf - Google Drive
TESTINGlayeredClips_2.fla - Google Drive https://drive.google.com/open?id=11z5c9032a8ktXji8q25HUdcmWqy0aPrD
var playing:Boolean = false;
function stopAllCounts():void {
Green.gotoAndStop(1);
Blue.gotoAndStop(1);
Purple.gotoAndStop(1);
}
/*1st movieclip*/
function startGreen(event:MouseEvent):void {
var stopped:Boolean = Green.currentFrame == 1 || Green.currentFrame == Green.totalFrames;
stopAllCounts();
if (stopped) {
Green.gotoAndPlay(1);
}
}
startButton1.addEventListener(MouseEvent.CLICK, startGreen);
/*2nd movieclip*/
function startBlue(event:MouseEvent):void {
var stopped:Boolean = Blue.currentFrame == 1 || Blue.currentFrame == Blue.totalFrames;
stopAllCounts();
if (stopped) {
Blue.gotoAndPlay(1);
}
}
startButton2.addEventListener(MouseEvent.CLICK, startBlue);
stop();
/*3nd movieclip*/
function startPurple(event:MouseEvent):void {
var stopped:Boolean = Purple.currentFrame == 1 || Purple.currentFrame == Purple.totalFrames;
stopAllCounts();
if (stopped) {
Purple.gotoAndPlay(1);
}
}
startButton3.addEventListener(MouseEvent.CLICK, startPurple);
stop();
assuming the movieclips with the gotoAndPlay() should be moved to the top:
...
var playing:Boolean = false;
function stopAllCounts():void {
Green.gotoAndStop(1);
Blue.gotoAndStop(1);
Purple.gotoAndStop(1);
}
/*1st movieclip*/
- Green.stop();
function startGreen(event:MouseEvent):void {
var stopped:Boolean = Green.currentFrame == 1 || Green.currentFrame == Green.totalFrames;
stopAllCounts();
if (stopped) {
addChild(Green);
Green.gotoAndPlay(1);
}
}
startButton1.addEvent
Copy link to clipboard
Copied
assuming the movieclips with the gotoAndPlay() should be moved to the top:
var playing:Boolean = false;
function stopAllCounts():void {
Green.gotoAndStop(1);
Blue.gotoAndStop(1);
Purple.gotoAndStop(1);
}
/*1st movieclip*/
- Green.stop();
function startGreen(event:MouseEvent):void {
var stopped:Boolean = Green.currentFrame == 1 || Green.currentFrame == Green.totalFrames;
stopAllCounts();
if (stopped) {
addChild(Green);
Green.gotoAndPlay(1);
}
}
startButton1.addEventListener(MouseEvent.CLICK, startGreen);
/*2nd movieclip*/
- Blue.stop();
function startBlue(event:MouseEvent):void {
var stopped:Boolean = Blue.currentFrame == 1 || Blue.currentFrame == Blue.totalFrames;
stopAllCounts();
if (stopped) {
addChild(Blue);
Blue.gotoAndPlay(1);
}
}
startButton2.addEventListener(MouseEvent.CLICK, startBlue);
stop();
/*3nd movieclip*/
- Purple.stop();
function startPurple(event:MouseEvent):void {
var stopped:Boolean = Purple.currentFrame == 1 || Purple.currentFrame == Purple.totalFrames;
stopAllCounts();
if (stopped) {
addChild(Purple);
Purple.gotoAndPlay(1);
}
}
startButton3.addEventListener(MouseEvent.CLICK, startPurple);
stop();
Copy link to clipboard
Copied
Thanks so much kglad! That worked perfectly. Much appreciated!!
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
Google is your friend:
Find more inspiration, events, and resources on the new Adobe Community
Explore Now