If's and but's

If's and but's

Post by stein olse » Tue, 29 Jan 2008 19:12:28


I'm new to action script and was hoping for a wee bit of help with some coding
from anyone with an ear to listen. I'm working on a levels system for a website
idea which I'm practicing on.

I want to use a lot of levels, loading swf's into those levels when you click
on the navigation. What I don't want though is once the swf is loaded into a
level, and you click on the same button again, then it doesn't load that movie
again and can just access the already loaded movie. I also want to be able to
unload a big chunk of movies in many levels if need be.

So what I was thinking was (taking a movie in level 10 as an example):

on (release) {
if (_root.level10=explosion.swf,true) {
_root.level10.explosion.swf.gotoAndPlay(3) }
else {
loadMovie ("explosion.swf",10);

Then to unload a lot of movies (say in levels 1-50) without having to put in
loads of code can you use this?

on(release) {

I'm not sure if any of this will work?

Any help?



If's and but's

Post by lilalfyali » Tue, 29 Jan 2008 21:09:59

Have you considered using a loop?


If's and but's

Post by rlc561 » Tue, 29 Jan 2008 21:47:10

if(_level10 <> undefined) {
} else {

Of course if level10 is not loaded and someone repeatedly clicks the button
with no delay, the movie would try to load and load. If the _level10, for
example, was not yet loaded and you decide to load it, you should disable the
button until it is loaded and then reenable the button.

As far as unloading a bunch of levels, using unloadMovieNum in a loop would do
just fine. On example:

for(var i = 1; i <= 50; i++) {
if(_root["_level" + i] <> undefined) {

If's and but's

Post by stein olse » Tue, 29 Jan 2008 23:46:57

You lot are genius!

Thank you very much. I must say it can be very daunting learning all this code but it's pretty cool stuff.