First error is in the BtnRmc 1061: call to a possibly undefined method gotoAndPlay througt a reference with static tipe… …:Stage
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Main extends MovieClip {
private var BtnL:BtnLmc;
private var BtnR:BtnRmc;
public function Main() {
stop();
//adding the Btns class
var btns:Btns = new Btns();
addChild(btns);
this.addEventListener(Event.ADDED_TO_STAGE, toStage, false, 0, true);
}
private function toStage(event:Event):void {
this.removeEventListener(Event.ADDED_TO_STAGE, toStage);
stage.addEventListener(Event.ENTER_FRAME, onEnter, false, 0, true);
}
//add actions at specific frame
private function onEnter(event:Event):void {
var frame:Number;
frame = currentFrame;
switch (frame) {
case 1 :
stop();
BtnR.visible = true;
BtnL.visible = true;
break;
case 10 :
gotoAndStop(11);
BtnR.visible = true;
BtnL.visible = true;
break;
case 20 :
gotoAndStop(21);
BtnR.visible = true;
BtnL.visible = true;
break;
case 30 :
gotoAndStop(31);
BtnR.visible = true;
BtnL.visible = true;
break;
case 40 :
gotoAndStop(41);
BtnR.visible = true;
BtnL.visible = true;
break;
case 50 :
gotoAndStop(51);
BtnR.visible = true;
BtnL.visible = true;
break;
case 60 :
gotoAndStop(61);
BtnR.visible = true;
BtnL.visible = true;
break;
case 70 :
gotoAndStop(71);
BtnR.visible = true;
BtnL.visible = true;
break;
case 80 :
gotoAndStop(1);
BtnR.visible = true;
BtnL.visible = true;
break;
case 90 :
gotoAndStop(71);
BtnR.visible = true;
BtnL.visible = true;
break;
case 100 :
gotoAndStop(61);
BtnR.visible = true;
BtnL.visible = true;
break;
case 110 :
gotoAndStop(51);
BtnR.visible = true;
BtnL.visible = true;
break;
case 120 :
gotoAndStop(41);
BtnR.visible = true;
BtnL.visible = true;
break;
case 130 :
gotoAndStop(31);
BtnR.visible = true;
BtnL.visible = true;
break;
case 140 :
gotoAndStop(21);
BtnR.visible = true;
BtnL.visible = true;
break;
case 150 :
gotoAndStop(11);
BtnR.visible = true;
BtnL.visible = true;
break;
case 160 :
gotoAndStop(1);
BtnR.visible = true;
BtnL.visible = true;
break;
}
}
}
}
package {
import flash.display.MovieClip;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.events.Event;
public class Btns extends MovieClip {
//add instance to the display list
public var BtnL:BtnLmc = new BtnLmc();
public var BtnR:BtnRmc = new BtnRmc();
//array of buttons example: parrent(BtnL).child(BtnL1)
public var buttonsAr:Array = [BtnR.BtnR1, BtnR.BtnR2, BtnR.BtnR3, BtnR.BtnR4, BtnL.BtnL1, BtnL.BtnL2, BtnL.BtnL3, BtnL.BtnL4];
public function Btns() {
//add childs to the stage
BtnL.x = 143,3;
BtnL.y = 111,3;
addChild(BtnL);
BtnR.x = 641,2;
BtnR.y = 111,3;
addChild(BtnR);
//BtnL and R name
BtnL.name = "BtnL";
BtnR.name = "BtnR";
//call setButtons function
setButtons();
}
public function setButtons():void {
for (var i:int = 0; i < buttonsAr.length; i++) {
buttonsAr*.buttonMode = true;
buttonsAr*.mouseChildren = true;
buttonsAr*.mouseEnabled = true;
//listeners to array of buttons
buttonsAr*.addEventListener(MouseEvent.ROLL_OVER, playOver, false, 0, true);
buttonsAr*.addEventListener(MouseEvent.ROLL_OUT, playOut, false, 0, true);
buttonsAr*.addEventListener(MouseEvent.CLICK, doClick, false, 0, true);
}
}
public function playOver(event:MouseEvent):void {
//button state "over"
event.currentTarget.gotoAndStop("over");
}
public function playOut(event:MouseEvent):void {
//button state "out"
event.currentTarget.gotoAndPlay("out");
}
public function doClick(event:MouseEvent):void {
//release(to "up" state), if any button is selected(in down state)
function setSelectedBtn():void {
for (var i:int=0; i< buttonsAr.length; i++) {
if (buttonsAr*.currentLabel == "down"){
buttonsAr*.gotoAndStop("up");
buttonsAr*.buttonMode = true;
buttonsAr*.mouseEnabled = true;
buttonsAr*.mouseChildren = true;
}
}
}
switch (event.target.parent.name) {
//parent container is BtnL, means any of nested MCs.
case "BtnL" :
//each button cause his neigbour button selected("down state"), and block his functionality.
if (event.target.name == "BtnL2") {
BtnL.BtnL1.gotoAndStop("down");
BtnL.BtnL1.buttonMode = false;
BtnL.BtnL1.mouseEnabled = false;
BtnL.BtnL1.mouseChildren = false;
}
else if (event.target.name == "BtnL3") {
BtnL.BtnL2.gotoAndStop("down");
BtnL.BtnL2.buttonMode = false;
BtnL.BtnL2.mouseEnabled = false;
BtnL.BtnL2.mouseChildren = false;
}
else if (event.target.name == "BtnL4") {
BtnL.BtnL3.gotoAndStop("down");
BtnL.BtnL3.buttonMode = false;
BtnL.BtnL3.mouseEnabled = false;
BtnL.BtnL3.mouseChildren = false;
}
else {
BtnR.BtnR1.gotoAndStop("down");
BtnR.BtnR1.buttonMode = false;
BtnR.BtnR1.mouseEnabled = false;
BtnR.BtnR1.mouseChildren = false;
}
//making buttons unvisible to show the animation layer (buttons tween made at stage)
BtnR.visible = false;
BtnL.visible = false;
break;
//same like first case, but for right buttons
case "BtnR" :
if (event.target.name == "BtnR2") {
BtnR.BtnR1.gotoAndStop("down");
BtnR.BtnR1.buttonMode = false;
BtnR.BtnR1.mouseEnabled = false;
BtnR.BtnR1.mouseChildren = false;
}
else if (event.target.name == "BtnR3") {
BtnR.BtnR2.gotoAndStop("down");
BtnR.BtnR2.buttonMode = false;
BtnR.BtnR2.mouseEnabled = false;
BtnR.BtnR2.mouseChildren = false;
}
else if (event.target.name == "BtnR4") {
BtnR.BtnR3.gotoAndStop("down");
BtnR.BtnR3.buttonMode = false;
BtnR.BtnR3.mouseEnabled = false;
BtnR.BtnR3.mouseChildren = false;
}
else {
BtnL.BtnL1.gotoAndStop("down");
BtnL.BtnL1.buttonMode = false;
BtnL.BtnL1.mouseEnabled = false;
BtnL.BtnL1.mouseChildren = false;
}
BtnR.visible = false;
BtnL.visible = false;
break;
}
}
}
}
package {
import flash.display.MovieClip;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.Stage;
public class BtnRmc extends Btns {
public function BtnRmc() {
// constructor code
}
override public function doClick(event:MouseEvent):void {
//when we do the click at the currentlabel, gotoAndPlay animation which is than stopet bi Main function onEnter
switch (currentLabel) {
case "first" :
stage.gotoAndPlay(83);
break;
case "second" :
stage.gotoAndPlay(153);
break;
case "third" :
stage.gotoAndPlay(143);
break;
case "fourth" :
stage.gotoAndPlay(133);
break;
case "fiveth" :
stage.gotoAndPlay(123);
break;
case "sixth" :
stage.gotoAndPlay(113);
break;
case "seventh" :
stage.gotoAndPlay(103);
break;
case "eight" :
stage.gotoAndPlay(93);
break;
}
}
}
}
package {
import flash.display.MovieClip;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.Stage;
public class BtnLmc extends Btns {
public function BtnLmc() {
// constructor code
}
override public function doClick(event:MouseEvent):void {
//similar to the BtnRmc, but the animation from left to right is betwen the keyframes, so it is enough jst to play().
stage.play();
switch (currentLabel) {
case "first" :
break;
case "second" :
break;
case "third" :
break;
case "fourth" :
break;
case "fiveth" :
break;
case "sixth" :
break;
case "seventh" :
break;
case "eight" :
break;
}
}
}
}