Hi there,
Does anyone have any idea how to link the following on release code used when clicking a menu item such that it will open the required mc?
stop();
// Include MC Tween
#include "mc_tween2.as"
// Global Variables
var whoIsOn:Number = 0 //Keeps track of what page we are currently on. Each page has a numerical variable corresponding to it.
var whatIsNext:Number = 0 //Keeps track of what page you are going to load after the current pages animates out
var blankScreen:Boolean = true; //Keeps track of if a page is even loaded. If none is loaded, you don't need an outro animation.
#include "lmc_tween.as"
//
Stage.align = "MC";
Stage.scaleMode = "NoScale";
Stage.showMenu = false;
this.m1.useHandCursor = false;
this.m2.useHandCursor = false;
this.m3.useHandCursor = false;
this.m4.useHandCursor = false;
this.m5.useHandCursor = false;
//
items = [m1, m2, m3, m4, m5];
titles = ["ONE", "TWO", "THREE", "FOUR", "FIVE"];
//
for (var i = 0; i<items.length; i++) {
items*.i = i;
items*._alpha = 0;
items*.alphaTo(100, 3, "", i/12);
items*.txt.title.text = titles*;
items*.onRollOver = function() {
this.txt.colorTo(0x993399, 0.1, "linear");
};
items*.onRollOut = function() {
this.txt.colorTo(0x000000, 0.3, "linear");
};
items*.onPress = items*.onRelease=function () {
this.txt.colorTo(0x993399, 0.1, "linear");
this.seta.frameTo(15, 0.5, "Linear");
this.enabled = false;
current.txt.colorTo(0x000000, 0.3, "linear");
current.seta.frameTo(0, 0.5, "Linear");
current.enabled = true;
_global.current = this;
};
}
m1.txt.colorTo(0x993399, 0.1, "linear");
m1.seta.frameTo(15, 0.5, "Linear");
m1.enabled = false;
_global.current = m1;
// onRelease functions
// Exit current page ("Outro")
function exitPage() {
trace("Leaving page " + whoIsOn + ".") // a trace to see if everything is working
trace("Entering page " + whatIsNext + ".")
if (blankScreen == false){ // checking to see if anything is on the screen
if (whoIsOn == 1) { // if the 1st page is loaded
Page_1_mc.blurTo(1,3,1.5, "easeOutQuad") // blur the first page to a x&y radius of 1, using high quality over 1.5 seconds
Page_1_mc.alphaTo(0, 1.5, "easeOutQuad") // decrease the alpha to 0 over 1.5 seconds using the easeOutQuad easing object.
Page_1_mc.onTweenComplete = enterPage; // when the tweeing in finished, the funciton enterPage(); is started.
}
if (whoIsOn == 2) {
Page_2_mc.blurTo(1,3,1.5, "easeOutQuad")
Page_2_mc.alphaTo(0, 1.5, "easeOutQuad")
Page_2_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 3) {
Page_3_mc.blurTo(1,3,1.5, "easeOutQuad")
Page_3_mc.alphaTo(0, 1.5, "easeOutQuad")
Page_3_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 4) {
Page_4_mc.blurTo(1,3,1.5, "easeOutQuad")
Page_4_mc.alphaTo(0, 1.5, "easeOutQuad")
Page_4_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 5) {
Page_5_mc.blurTo(1,3,1.5, "easeOutQuad")
Page_5_mc.alphaTo(0, 1.5, "easeOutQuad")
Page_5_mc.onTweenComplete = enterPage;
}
}
else { // if nothing is on the screen, no need to clear anything.
trace ("Blank screen? " + blankScreen)
enterPage();
}
}
// Bring in page
function enterPage() {
if (whatIsNext == 1) { // checks what page should load next
Page_1_mc.blurTo(0,3,1.5, "easeOutQuad") // the blur is at 1, so we want to take that away.
Page_1_mc.alphaTo(100, 1.5, "easeOutQuad") // the alpha is 0, so we want to bring it back to 100.
Page_1_mc._x = 0 // brings the page onto the stage
Page_1_mc._y = 0
whoIsOn = 1 // sets the variable whoIsOn to 1 because we are now on page 1
}
if (whatIsNext == 2) {
Page_2_mc._x = 0
Page_2_mc._y = 0
Page_2_mc.blurTo(0,3,1.5, "easeOutQuad")
Page_2_mc.alphaTo(100, 1.5, "easeOutQuad")
whoIsOn = 2
}
if (whatIsNext == 3) {
Page_3_mc._x = 0
Page_3_mc._y = 0
Page_3_mc.blurTo(0,3,1.5, "easeOutQuad")
Page_3_mc.alphaTo(100, 1.5, "easeOutQuad")
whoIsOn = 3
}
if (whatIsNext == 4) {
Page_4_mc._x = 0
Page_4_mc._y = 0
Page_4_mc.blurTo(0,3,1.5, "easeOutQuad")
Page_4_mc.alphaTo(100, 1.5, "easeOutQuad")
whoIsOn = 4
}
if (whatIsNext == 5) {
Page_5_mc._x = 0
Page_5_mc._y = 0
Page_5_mc.blurTo(0,3,1.5, "easeOutQuad")
Page_5_mc.alphaTo(100, 1.5, "easeOutQuad")
whoIsOn = 5
}
}
// Check is the page is already loaded
function loadPage() {
if (whoIsOn == whatIsNext) { // if the page is already loaded, no need to do anything
trace("This page is already loaded.")
}
else { // if the whoIsOn and whatIsNext are different, we want to clear the screen and then load the new page
exitPage();
}
}
// Assign onRelease functions
// Page_1
m1.onRelease = function() {
whatIsNext = 1; // this is saying to load page 1
loadPage();
Page_1_mc.gotoAndPlay(1);
blankScreen = false;
}
// Page_2
m2.onRelease = function() {
whatIsNext = 2;
loadPage();
Page_2_mc.gotoAndPlay(1);
blankScreen = false;
}
// Page_3
m3.onRelease = function() {
whatIsNext = 3;
loadPage();
Page_3_mc.gotoAndPlay(1);
blankScreen = false;
}
// Page_4
m4.onRelease = function() {
whatIsNext = 4;
loadPage();
Page_4_mc.gotoAndPlay(1);
blankScreen = false;
}
// Page_5
m5.onRelease = function() {
whatIsNext = 5;
loadPage();
Page_5_mc.gotoAndPlay(1);
blankScreen = false;
}
// Starting Blur & Visiblity
// Alpha
Page_1_mc._alpha = 0
Page_2_mc._alpha = 0
Page_3_mc._alpha = 0
Page_4_mc._alpha = 0
Page_5_mc._alpha = 0
// Blur
Page_1_mc.blurTo(1,3,.1)
Page_2_mc.blurTo(1,3,.1)
Page_3_mc.blurTo(1,3,.1)
Page_4_mc.blurTo(1,3,.1)
Page_5_mc.blurTo(1,3,.1)