PDA

View Full Version : Help with "on release" code


pashonit
10-14-2005, 03:37 PM
I have a website that has a biography page. There are 5 buttons to view biographies of different people. On each button, there is the code below (with the exception of "jenbio.swf" being a different name for each biography button of course):

on (release) {
_root.contents2.loadMovie("jenbio.swf");
}
on (release) {
if (_global.biographymc == 0) {
_parent.biographymc.gotoAndPlay(2);
_global.biographymc = 1;
}
}

The 2nd "on release" code is a title that fades in. The code tells it to load if the movie hasn't been played yet (because no button had been pressed yet) but if it has already played, to leave it and not play it over again.

My problem is this. When I test it on my computer, it all works fine. Both codes work as they should. The title movie (biographymc) plays and the biography comes up or the title movie has already been played, so it leaves it and just brings up the biography. When it is up online, if you press a button the title movie plays but no biography comes up. You have to press the button again in order for the biography to come up. If the title movie has already played, it leaves it, but you still have to press the button again to get the biography to come up. These should be happening at the same time.

Does anyone know why this is happening and is there a fix? Is it because I have two "on release" codes on the button and it is reading the one first? It should be happening together.

My thanks to anyone who can help.

pashonit
10-16-2005, 03:39 PM
Just an extra note to say that I did try placing all the code into one "on release" handler and it is still doing the same thing. When tested on my computer, it works fine but online it still has the same problem. So, it wasn't because it had 2 of the same handler for one button. I also tried doing 2 different handlers, like the bio being "onrelease" and the title movieclip as "on press" or "on rollOut" and each time the mc script worked but you still had to press the button again to get the biography to come up.

I tried it with just this script alone:

on (release) {
_root.contents2.loadMovie("jenbio.swf");
}

and took out the rest and it worked. I only had to press the button once. But of course, now I don't have my title fade in because the script wasn't there. So obviously those 2 scripts don't like being together for some reason! I am trying to figure out why I have to press the button twice, when online, in order for the swf to load. Why does it only read the mc script first?

If anyone has a suggestion, or answer, please let me know.

I am trying to see if there is another way to get the title mc to play at the appropriate time. When you press the button, the biography that is supposed to load up replaces a picture that is already in the movie loader. How do I say, if this picture unloads (which is "biography.swf), play this movieclip (which would be "biographymc")? Something like,

_root.contents2.loadMovie("biography.swf");
if (_root.contents2.unloadMovie("biography.swf")) {
biosmc.biographymc.gotoAndPlay(2);
}

Although this code doesn't work properly, that is what I am looking for. So, the first part is the movie loading. Then the second part, I am trying to say, if the movie goes away, then launch this.

pashonit
10-18-2005, 10:02 PM
OKAY...HAHAHAHA

Guess what! I got fed up with it, trying different things to make this work. I gave in and completely changed it so that the fading in title thing is gone and I just let the title be without any effect (so it just always shows now). So now the code for all the buttons is this only:

on (release) {
_root.contents2.loadMovie("jenbio.swf");
}

-with the exception of "jenbio.swf" being a different swf name for each button. So I figure that should cure my problem! Well I put it up online and it is still taking 2 clicks to show up! I give up!

helenb29
10-19-2005, 06:09 PM
I am a total newbie aswell but I have had this problem many times.
I don't know if anything I say will help but here goes.
let's back up to where you were.

on (release) {
_root.contents2.loadMovie("jenbio.swf");
}
on (release) {
if (_global.biographymc == 0) {
_parent.biographymc.gotoAndPlay(2);
_global.biographymc = 1;
}
}
You probably should not do 2 on (releases).
And I am assuming that you want the same button to do 2 different things
depending on whether "jenbio.swf" has been loaded into your main movie yet?
Again, no guarantees here but you could try this.
First put a stop frame on the movie jenbio.fla so that it won't start playing
right away and it will wait for our button to play it.
Save and export and all that jazz.
Then go to the main timeline (of your main movie)and make a keyframe on a new layer.
On that keyframe, make an actionscript that declares a varialbe.
We will call it hasJenbioMovieLoadedYet for this example.
so it should like like this.
hasJenbioMovieLoadedYet=no

(You can make a whole bunch of these for other buttons too.
Name them whatever you like.)
Ok, then on your button with the onRelease stuff.

on (release) {
//check to see if "jenbio.swf" has been loaded,
//if not then load it.
if (_root.hasJenbioMovieLoadedYet != yes) {
_root.contents2.loadMovie("jenbio.swf");
//this will set that variable we made earlier to say yes.
_root.hasJenbioMovieLoadedYet = yes;
} else {
//otherwise if it is all ready been loaded, play it.
_root.contents2.gotoAndplay(2);
}
}

Maybe this could help but if not, at least you will know a little about checking for the state of loaded moives.

good luck

pashonit
10-20-2005, 04:02 PM
Not quite what I am looking for I don't think. But, thank you for trying to help! I appreciate it.