Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to layer movie clips on top of eachother

Participant ,
Jun 06, 2018 Jun 06, 2018

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*/

  1. Green.stop();

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*/

  1. Blue.stop();

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*/

  1. Purple.stop();

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();

680
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 06, 2018 Jun 06, 2018

assuming the movieclips with the gotoAndPlay() should be moved to the top:

SheaB

var playing:Boolean = false;

function stopAllCounts():void {

     Green.gotoAndStop(1);

     Blue.gotoAndStop(1);

     Purple.gotoAndStop(1);

}

/*1st movieclip*/

  1. 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

...
Translate
Community Expert ,
Jun 06, 2018 Jun 06, 2018

assuming the movieclips with the gotoAndPlay() should be moved to the top:

SheaB

var playing:Boolean = false;

function stopAllCounts():void {

     Green.gotoAndStop(1);

     Blue.gotoAndStop(1);

     Purple.gotoAndStop(1);

}

/*1st movieclip*/

  1. 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*/

  1. 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*/

  1. 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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 06, 2018 Jun 06, 2018

Thanks so much kglad! That worked perfectly. Much appreciated!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2018 Jun 06, 2018
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 06, 2018 Jun 06, 2018

Google is your friend:

Movie clip stacking - always on top?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines