PDA

View Full Version : Jumping Scenes


bettheturn
01-25-2005, 04:51 AM
Hey all,

I've got a scene (first scene) called Loader that performs loading for data, then the idea is once it is loaded to jump to the Application scene.

Using gotoAndPlay("Application", 1) it will get to that scene. However, it continues playing the first scene (Loader) as well as the second scene. I assumed the playhead would MOVE from the first to the second scene doing that. If flash is built to play them concurrently, I assumed that calling gotoAndPlay("Application", 1) and then stop() from within the Loader scene, would start the Application scene and STOP the Loader scene. It seems to do this, but the Application scene executes the first frame and stops as well. If at the end of the Application scene I call play() or even gotoAndPlay("Application", 2) it again plays BOTH the Loader scene AND the Application scene. Tis is bizzare and makes no sense to me.

I just want to jump FROM one scene TO the next, having the first scene STOP and the second one START. These are the methods I tried:


// ======================
// Loader Scene (scene 1)
gotoAndPlay("Application", 1);
stop();

// ======================
// Application Scene (scene 2)
// execute whatever...
// frame 1 plays but never gets to frame 2



// ======================
// Loader Scene (scene 1)
gotoAndPlay("Application", 1);

// ======================
// Application Scene (scene 2)
// execute whatever...
// application scene plays both frames,
// but the Loader scene continues playing too



// ======================
// Loader Scene (scene 1)
gotoAndPlay("Application", 1);
stop();

// ======================
// Application Scene (scene 2)
gotAndPlay("Application", 2);
// application scene will now play scene 2,
// but the Loader scene ALSO starts playing!!


I know theres something I am missing here, but how is it that stop seems to stop ALL scenes and start starts ALL scenes? I need to be able to start just ONE scene and stop just ONE scene.

Thanks for any help.

sandesh
01-25-2005, 07:36 AM
can u post your FLA here so i can look into it directly ??

tGP
01-25-2005, 07:50 AM
also, i know you probably have alot of work into this so far, and dont want to change things... but for the future, try to refrain from using scenes... they are cumbersome to address with actionscript... it will save you work in the long run...

cheers.
j

Taff
01-25-2005, 09:08 AM
Also you need to give the frames you want to go to in different scenes have to have a frame label, numbers dont work,

SO:

gotoAndPlay("Application",1);

wouldnt work, where as

gotoAndPlay("Application","firstFrame");

would if you give it a framelabel firstFrame

A problem you wont have if you stick to putting everything into movieClips!

Taff

bettheturn
01-25-2005, 09:09 AM
Yeah, I hear people saying that about the scenes... Such a pitty, since they WOULD provide decent organization.

The fla and associated class are in a zip at:
http://www.thecorruptionreport.com/bettheturn/mazefailflash.zip

It simply doesnt work.

bettheturn
01-25-2005, 09:13 AM
Yeah, I tried frame names too, no difference, same result. I may have to rip out the scenes and do it all in one scene. I do wish someone could explain WHY it doesn't work, though.

Taff
01-25-2005, 09:41 AM
Tbh, I have absolutely no idea what those scenes actual do.

There are some strange things going on. For example you are saying

gotoAndPlay(2);
stop();

when you are on frame 2 already. For some reason frame 3 is still being called, although I cant see where

Your class has some a LoadVars which is where I fear the problem may lie.

public function didLoad():Boolean {
return mLoader._nodecount.valueOf()>0;
}


This lost me too, you dont seem to be calling this function, and what:

return mLoader._nodecount.valueOf()>0;

is, is also above me.

Maybe all these things are in the php file you are calling but I can't see how.

Sorry I couldnt help more.

Taff

bettheturn
01-25-2005, 09:48 AM
Sorry, some stuff I took out in an attempt to make the thing simpler and easier to see the issue. The issue is still there, and that is that it GETS to the second scene, frame 1... But it does NOT continue on to frame 2... Which is basically as simple as the problem is. Why does it NOT get to frame 2, there is no stop, nothing else going on? I just dont get it.

I just took out the scenes, put everything onto ONE scene, in different frames, same exact problem.

If this were working correctly, you should see the trace("") display from the second and 3rd frame of scene 2. Never gets there.

bettheturn
01-25-2005, 09:53 AM
Basically the flow should look like this:

Scene1, Frame 1:

LoadVars from the php file.
Loop the loading movieclip until onLoad shows up with the remote data
When onLoad gets called with failure or success, jump out of the loading mc loop and enter a new frame which either calls the failure scene (scene 2) or the success scene (3).

If success, (or failure, since I made it go there either way):
Scene 3, Frame 1:

Initiate some stuff, and expect that it will "flow through" to Scene 3, Frame 2. It never gets to frame 2, which is my problem.

The only reason for Scene 1 is to make sure that the LoadVars returns with the data. Once that is loaded, I just need to reposition for the normal application. I can't get it to reposition the playhead without either stopping or playing all scenes. Makes no sense.

Taff
01-25-2005, 10:29 AM
I see,
I am not into AS2.0 as of yet and am still learning but a couple of points could help here:

1) Maybe we should use a method to call our php script (just in case we move it someday).

2) while we are at it, lets make it target a preloading mC as well.

I was thinking along these lines (remember not much AS2.0 knowledge yet)

class Test {
private var myLoader:LoadVars;
//Load a file
public function loadData (URL:String,preloadMC:MovieClip ):Void {
//make sure our preloading MC is visble an make it play
preloadMC._visible=true;
preloadMC.gotoAndPlay(2);
//use our load Vars
myLoader = new LoadVars ();
myLoader.onLoad = function (success) {
if (success) {
//make preloader invisible again
preloadMC.gotoAndStop(1);
preloadMC._visible=false;
//and do the maze thing
_root.gotoAndPlay("AttachMazeScene","frame1");
} else {
trace ("Sorry, looks like I screwed up");
_root.gotoAndPlay("LoadingErrorScene","frame1");
}
};
myLoader.load (URL);
}

}

then we call call our class like this:

var test1:Test = new Test();
test1.loadData("data.txt",this.preloadingMC);


This isnt tested and I am not even sure if its the correct way to go about it. Ive been AS1 'ing for a while but this is still something Im trying to get into between bill paying work :-)

Feel free to ignore it! Maybe some expert will pop along soon and help us both!

Taff

bettheturn
01-25-2005, 07:13 PM
It appears that my mistake was in referencing a frame in the loading sequence to jump back and replay itself, as opposed to adding a new frame and having it jump to the one BEFORE itself.

WRONG:

// In Frame 1
gotoAndPlay(1);


RIGHT:

// In Frame 2
gotoAndPlay(1);
// Frame 1 is left empty


Now, I would think it should work anyway, just forever looping on the same frame, and adding the 1-frame delay each time. It seems to do just that, except when future jumps get called, then it acts bizzare. However, this appears to work as is.

Still wish I could get a detailed explanation of the design of the playhead, how it gets split (running multiple frames/scenes concurrently), and what effect stop() has on the one or many playheads.

Thanks guys.