Hey folks,
This is my first time posting So basically I have a small Flash presentation I’m putting together and I’ve written out the code that I’ll need or how it will function at least.
My question is… is there an easy way to condense the script so every single button doesn’t have like 20 if/elseif statements?
This is the code on my main frame:
import mx.transitions.Tween; //import tweening class
import mx.transitions.easing.*;
container01.attachMovie("picstatic07_mov","loadedIn",10); //load movie into container
var xPosT:Tween = new Tween(container01, "_x", Regular.easeOut, 900, 0, 25, false); //slide container in
var loadedMovie:String; //declare variable
loadedMovie = "picstatic07_mov";
trace(loadedMovie);
stop();
Now this is what it on my buttons:
on (release) {
import mx.transitions.Tween;
import mx.transitions.easing.*;
if (loadedMovie == "picstatic07_mov") {
trace("it checked loadedMovie correctly and stopped") //checking if this movie is already loaded
stop();
} else if (loadedMovie == "picstatic06_mov") {
container02.attachMovie("picstatic06_mov", "loadOut", 10); //loading current movie to another container
var xPosT:Tween = new Tween(container02, "_x", Regular.easeOut, 0, -900, 25, false); //sliding the same movie offscreen
container01.attachMovie("picstatic07_mov", "picstatic07_mov", 10); //loading new movie in container
var xPosT:Tween = new Tween(container01, "_x", Regular.easeOut, 900, 0, 25, false); //sliding THAT movie onscreen
var loadedMovie = "picstatic07_mov"
trace("it checked loadedMovie correctly and changed hopefully")
} else if (loadedMovie == "picstatic05_mov") {
container02.attachMovie("picstatic05_mov", "loadOut", 10); //more of the same
var xPosT:Tween = new Tween(container02, "_x", Regular.easeOut, 0, -900, 25, false);
container01.attachMovie("picstatic07_mov", "picstatic07_mov", 10);
var xPosT:Tween = new Tween(container01, "_x", Regular.easeOut, 900, 0, 25, false);
var loadedMovie = "picstatic07_mov"
trace("it checked loadedMovie correctly and changed hopefully")
} else if (loadedMovie == "picstatic04_mov") {
container02.attachMovie("picstatic04_mov", "loadOut", 10); //more of the same
var xPosT:Tween = new Tween(container02, "_x", Regular.easeOut, 0, -900, 25, false);
container01.attachMovie("picstatic07_mov", "picstatic07_mov", 10);
var xPosT:Tween = new Tween(container01, "_x", Regular.easeOut, 900, 0, 25, false);
var loadedMovie = "picstatic07_mov"
trace("it checked loadedMovie correctly and changed hopefully")
} else {
trace("something didn't work or loadedMovie is not set");
trace(loadedMovie);
}
}
Now I have to apply this idea to like 50 buttons in different sections. Is there a way that I can just check whats in that container already and then just load that movie out without all the code? I’m going to have to rewrite this thing like 50 times for it to work otherwise!
Thanks!