;

PDA

Click to See Complete Forum and Search --> : variable problems...novice.


mindtea
12-05-2003, 04:39 PM
Alright. Hopefully I can explain this well.
I am trying to reference variables from an external .swf file, which is loaded into a container. The purpose is to use six buttons to load external.swf files into the same container on the stage, at different times. The initial movie loading into the container is a preloader, which should read which button is pressed(by the variables), and then preload the appropriate movie. Long story short the external turns up undefined variables everytime. Here is the preloaders code.



trace(_global.profile);
trace(_global.work);
trace(_global.modules);
trace(_global.reusme);
trace(_global.contact);
trace(_global.signIn);
percent_display = "";

this.createEmptyMovieClip("main_hold", 50);

function movieCheck() {
if (_parent._global.profile == true) {
main_hold.loadMovie("profile_main.swf");
} else if (_global.work == true) {
main.hold.loadMovie("work_main.swf");
} else if (_global.modules == true) {
main.hold.loadMovie("modules_main.swf");
} else if (_global.resume == true) {
main.hold.loadMovie("resume.swf");
} else if (_global.contact == true) {
main_hold.loadMovie("contact_main.swf");
} else if (_global.signIn == true) {
main_hold.loadMovie("signIn_main.swf");
}
};
movieCheck();

this.onEnterFrame = function() {
percent = (this.main_hold.getBytesLoaded()/this.main_hold.getBytesTotal())*100;
if (!isNan(percent)) {
if (percent == 0) {
percent_display = "";
} else {
percent_display = Math.ceil(percent)+"% loaded";
}
container.stop();
} else if (percent == 100 && _global.profile == true) {
delete this.onEnterFrame;
percent_display = "";
loadMovieNum("profile_main.swf", 94);
} else if (percent == 100 && _global.work == true) {
delete this.onEnterFrame;
percent_display = "";
loadMovieNum("work_main.swf", 95);
} else if (percent == 100 && _global.modules == true) {
delete this.onEnterFrame;
percent_display = "";
loadMovieNum("modules_main.swf", 96);
} else if (percent == 100 && _global.resume == true) {
delete this.onEnterFrame;
percent_display = "";
loadMovieNum("resume_main.swf", 97);
} else if (percent == 100 && _global.contact == true) {
delete this.onEnterFrame;
percent_display = "";
loadMovieNum("contact_main.swf", 98);
} else if (percent == 100 && _global.signIn == true) {
delete this.onEnterFrame;
percent_display = "";
loadMovieNum("signIn_main.swf", 99);
}
};
stop();

DallasNYC
12-05-2003, 08:43 PM
Are you saying the initial traces at the very first of the script are tracing undefined? How are these variables defined in the main movie?


Also, some things you will want to fix in your script:

trace(_global.profile);
trace(_global.work);
trace(_global.modules);
trace(_global.reusme); // <-- resume is spelt wrong
trace(_global.contact);
trace(_global.signIn);
percent_display = "";
this.createEmptyMovieClip("main_hold", 50);
function movieCheck() {
if (_parent._global.profile == true) { //<-- should be _global.profile
main_hold.loadMovie("profile_main.swf");
} else if (_global.work == true) {
main.hold.loadMovie("work_main.swf"); //<<-- should be main_hold
} else if (_global.modules == true) {
main.hold.loadMovie("modules_main.swf");//<<-- should be main_hold
} else if (_global.resume == true) {
main.hold.loadMovie("resume.swf");//<<-- should be main_hold
} else if (_global.contact == true) {
main_hold.loadMovie("contact_main.swf");
} else if (_global.signIn == true) {
main_hold.loadMovie("signIn_main.swf");
}
}

FlashGoblin
12-06-2003, 05:37 AM
Hi mindTea,

Don't use _global to access the vars.....
If u've made a var a Global var....u can access it just by writing its name.

trace(work);
trace(modules);
trace(reusme);
trace(contact);
trace(signIn);
if (profile == true) {
main_hold.loadMovie("profile_main.swf");
}

Just remove global while accessing the global vars....
Otherwise it will again initialise the var.

Hope this'll help,
Sam

mindtea
12-07-2003, 12:55 PM
thanks for the responses. I will give them a try. If anyone know another, more effecient way of accompolishing this I would love to hear it. You can get an idea of what I am trying on my site. http://mindteadesign.com/mindteaMEDIA_root/pages/portal1.htm when the buttons are pressed, it loads the preloader, but the preloader doesn't know which external movie to load into itself.

thanks again.
clarence