i want to amend the below code so that when a button is pressed the current movie clip is UNLOADED, then when the next movie clip is loaded its RESTARTED. Currently the clips do not unload and when you go back to them they are in the current state left when the movieclips were switched.
code below:
stop();//stop buttons fading in, pages are controlled from this point here only
// 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.
// 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
aboutus_mc.blurTo(10,3,1, "easeOutQuad") // blur the first page to a x&y radius of 10, using high quality over 1 seconds
aboutus_mc.alphaTo(0, 1, "easeOutQuad") // decrease the alpha to 0 over 1 seconds using the easeOutQuad easing object.
aboutus_mc.onTweenComplete = enterPage; // when the tweeing in finished, the funciton enterPage(); is started.
}
if (whoIsOn == 2) {
findus_mc.blurTo(10,3,1, "easeOutQuad")
findus_mc.alphaTo(0, 1, "easeOutQuad")
findus_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 3) {
treatmentmenu_mc.blurTo(10,3,1, "easeOutQuad")
treatmentmenu_mc.alphaTo(0, 1, "easeOutQuad")
treatmentmenu_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 4) {
gallery_mc.blurTo(10,3,1, "easeOutQuad")
gallery_mc.alphaTo(0, 1, "easeOutQuad")
gallery_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 5) {
products_mc.blurTo(10,3,1, "easeOutQuad")
products_mc.alphaTo(0, 1, "easeOutQuad")
products_mc.onTweenComplete = enterPage;
}
if (whoIsOn ==6) {
giftvouchers_mc.blurTo(10,3,1, "easeOutQuad")
giftvouchers_mc.alphaTo(0, 1, "easeOutQuad")
giftvouchers_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 7) {
mailinglist_mc.blurTo(10,3,1, "easeOutQuad")
mailinglist_mc.alphaTo(0, 1, "easeOutQuad")
mailinglist_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 8) {
specialoffers_mc.blurTo(10,3,1, "easeOutQuad")
specialoffers_mc.alphaTo(0, 1, "easeOutQuad")
specialoffers_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 9) {
loyaltycards_mc.blurTo(10,3,1, "easeOutQuad")
loyaltycards_mc.alphaTo(0, 1, "easeOutQuad")
loyaltycards_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 10) {
contactus_mc.blurTo(10,3,1, "easeOutQuad")
contactus_mc.alphaTo(0, 1, "easeOutQuad")
contactus_mc.onTweenComplete = enterPage;
}
if (whoIsOn == 11) {
policies_mc.blurTo(10,3,1, "easeOutQuad")
policies_mc.alphaTo(0, 1, "easeOutQuad")
policies_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
aboutus_mc.blurTo(0,3,1, "easeOutQuad") // the blur is at 10, so we want to take that away.
aboutus_mc.alphaTo(100, 1, "easeOutQuad") // the alpha is 0, so we want to bring it back to 100.
aboutus_mc._x = 0 // brings the page onto the stage
aboutus_mc._y = 0
whoIsOn = 1 // sets the variable whoIsOn to 1 because we are no on page 1
}
if (whatIsNext == 2) {
findus_mc._x = 0
findus_mc._y = 0
findus_mc.blurTo(0,3,1, "easeOutQuad")
findus_mc.alphaTo(100, 1, "easeOutQuad")
whoIsOn = 2
}
if (whatIsNext == 3) {
treatmentmenu_mc._x = 0
treatmentmenu_mc._y = 0
treatmentmenu_mc.blurTo(0,3,1, "easeOutQuad")
treatmentmenu_mc.alphaTo(100, 1, "easeOutQuad")
whoIsOn = 3
}
if (whatIsNext == 4) {
gallery_mc._x = 0
gallery_mc._y = 0
gallery_mc.blurTo(0,3,1, "easeOutQuad")
gallery_mc.alphaTo(100, 1, "easeOutQuad")
whoIsOn = 4
}
if (whatIsNext == 5) {
products_mc._x = 0
products_mc._y = 0
products_mc.blurTo(0,3,1, "easeOutQuad")
products_mc.alphaTo(100, 1, "easeOutQuad")
whoIsOn = 5
}
if (whatIsNext ==6) {
giftvouchers_mc._x = 0
giftvouchers_mc._y = 0
giftvouchers_mc.blurTo(0,3,1, "easeOutQuad")
giftvouchers_mc.alphaTo(100, 1, "easeOutQuad")
whoIsOn = 6
}
if (whatIsNext == 7) {
mailinglist_mc._x = 0
mailinglist_mc._y = 0
mailinglist_mc.blurTo(0,3,1, "easeOutQuad")
mailinglist_mc.alphaTo(100, 1, "easeOutQuad")
whoIsOn = 7
}
if (whatIsNext == 8) {
specialoffers_mc._x = 0
specialoffers_mc._y = 0
specialoffers_mc.blurTo(0,3,1, "easeOutQuad")
specialoffers_mc.alphaTo(100, 1, "easeOutQuad")
whoIsOn = 8
}
if (whatIsNext == 9) {
loyaltycards_mc._x = 0
loyaltycards_mc._y = 0
loyaltycards_mc.blurTo(0,3,1, "easeOutQuad")
loyaltycards_mc.alphaTo(100, 1, "easeOutQuad")
whoIsOn = 9
}
if (whatIsNext == 10) {
contactus_mc._x = 0
contactus_mc._y = 0
contactus_mc.blurTo(0,3,1, "easeOutQuad")
contactus_mc.alphaTo(100, 1, "easeOutQuad")
whoIsOn = 10
}
if (whatIsNext == 11) {
policies_mc._x = 0
policies_mc._y = 0
policies_mc.blurTo(0,3,1, "easeOutQuad")
policies_mc.alphaTo(100, 1, "easeOutQuad")
whoIsOn = 11
}
}
// Check if 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
b00.onRelease = function () {
gotoAndPlay (90);
}
// About Us
b1.buttText.buttonText.text = "ABOUT US";
b1.onRelease = function() {
whatIsNext = 1; // this is saying to load page 1
loadPage();
blankScreen = false;
}
//Find Us
b2.buttText.buttonText.text = "FIND US";
b2.onRelease = function() {
whatIsNext = 2;
loadPage();
blankScreen = false;
}
// Treatment Menu
b3.buttText.buttonText.text = "TREATMENT MENU";
b3.onRelease = function() {
whatIsNext = 3;
loadPage();
blankScreen = false;
}
// Gallery
b4.buttText.buttonText.text = "GALLERY";
b4.onRelease = function() {
whatIsNext = 4;
loadPage();
blankScreen = false;
}
// Products
b5.buttText.buttonText.text = "PRODUCTS";
b5.onRelease = function() {
whatIsNext = 5;
loadPage();
blankScreen = false;
}
// Gift Vouchers
b6.buttText.buttonText.text = "GIFT VOUCHERS";
b6.onRelease = function() {
whatIsNext = 6;
loadPage();
blankScreen = false;
}
// Mailing List
b7.buttText.buttonText.text = "MAILING LIST";
b7.onRelease = function() {
whatIsNext = 7;
loadPage();
blankScreen = false;
}
// Special Offers
b8.buttText.buttonText.text = "SPECIAL OFFERS";
b8.onRelease = function() {
whatIsNext = 8;
loadPage();
blankScreen = false;
}
// Loyalty Cards
b9.buttText.buttonText.text = "LOYALTY CARDS";
b9.onRelease = function() {
whatIsNext = 9;
loadPage();
blankScreen = false;
}
// Contact Us
b10.buttText.buttonText.text = "CONTACT US";
b10.onRelease = function() {
whatIsNext = 10;
loadPage();
blankScreen = false;
}
// Special Offers
b11.buttText.buttonText.text = "POLICIES";
b11.onRelease = function() {
whatIsNext = 11;
loadPage();
blankScreen = false;
}
// Starting Blur & Visiblity
// Alpha
aboutus_mc._alpha = 0
findus_mc._alpha = 0
treatmentmenu_mc._alpha = 0
gallery_mc._alpha = 0
products_mc._alpha = 0
giftvouchers_mc._alpha = 0
mailinglist_mc._alpha = 0
specialoffers_mc._alpha = 0
lotaltycards_mc._alpha = 0
contactus_mc._alpha = 0
policies_mc._alpha = 0
// Blur
aboutus_mc.blurTo(10,3,.1)
findus_mc.blurTo(10,3,.1)
treatmentmenu_mc.blurTo(10,3,.1)
gallery_mc.blurTo(10,3,.1)
products_mc.blurTo(10,3,.1)
giftvouchers_mc.blurTo(10,3,.1)
mailinglist_mc.blurTo(10,3,.1)
specialoffers_mc.blurTo(10,3,.1)
lotaltycards_mc.blurTo(10,3,.1)
contactus_mc.blurTo(10,3,.1)
policies_mc.blurTo(10,3,.1)
any help would be appreciated