View Full Version : goto (var)???
Cattie
09-22-2003, 12:54 PM
Hi everybody, I got a very simple question
I got a movie:taartje.swf and I view it with taartje.html, in in there is a movieclip called "taart"; I have a file test.php with the code
<?php
echo "&postest=25&";
?>
Now I want the the movie clip "taart" to go to frame 25 (to "postest")
In the first frame of the movie I got the actions:
loadVariablesNum ("test.php", 0, "POST");
postest = Number(postest);
tellTarget ("taart") {
gotoAndStop (postest);
}
but it doesn't work
what am I doing wrong???
Love Louise :p
your not giving flash enough time between the time you load the variable to the time you check to the variable.
if you are using flashmx, use the loadvars object.
if you are using flash5, then do a quick search of the forums for 'swonk', and you see another way to do this.
Cattie
09-22-2003, 01:14 PM
I'll search, thanx!!
Louise :p
Cattie
09-22-2003, 03:05 PM
It still doen't work!
I now got:
php file:
<?php
echo "&postest=25&EOF=true&";
?>
a movie with 2 scene's : loader and diagram
scene loader:first frame:
loadVariablesNum ("test.php", 0, "POST");
if (EOF == "true") {
gotoAndStop ("diagram", 1);
}
scene: diagram : first frame
postest = Number(postest);
tellTarget ("taart") {
gotoAndStop (postest);
}
What am I doing wrong???
Love Louise :p
cattie try one of these two methods:
//frame 1
loadVariablesNum ("test.php", 0, "POST");
//frame 2
//frame 3
if (EOF != "true") {
//check if the file is done loading... if this is true (not done loading) then loop back to frame 2 and check again.
gotoAndPlay(2);
}
// if EOF is true, then it will go on to frame 4.
//frame 4
gotoAndStop ("diagram", 1);
or you could do it this way:
put a blank movie clip onto your main timeline
give it an instance name of 'loader'
//this code goes 'on' the movieclip 'loader'
onClipEvent(load){
this.loadMovie("test.php");
}
onClipEvent(data){
//this runs when the data is finished loading (so you can get rid of the EOF if you use this method).
_parent.gotoAndPlay(the frame to play);
}
//on your main timeline:
//scene: diagram : first frame
postest = Number(loader.postest);
tellTarget ("taart") {
gotoAndStop (postest);
}
Cattie
09-23-2003, 12:28 PM
well it almost works,
but the var postest returns as 0, when it should be 25??? I dont understand why??
Love Louise:p
which method did you use cattie?
use the trace() action fairly librally in your code when in test mode, to help track down errors and anomalies.
Cattie
09-23-2003, 12:48 PM
Another problem... i'm very new to this and .. eehh...
I don't know what you mean my method?? And I don't know how to use the trace function...
So will you be so kind just to expain it one more time???:confused:
Love Louise:p
up above i gave you two possible solutions to loading your file... which did you do?
trace():
put this on the first line of your code:
trace("hey cattie");
in test mode, you should get the output window popup with the message 'hey cattie' in it.
so put trace(and any message you want here); anywhere you want in your code to see what an actual variable value is.
here is an example using the same code above:
//frame 1
loadVariablesNum ("test.php", 0, "POST");
//see what eof is:
trace(EOF);//should output 'undefined'
//frame 2
//frame 3
//see what eof is again:
trace("you are in frame 3 eof=" +EOF);//output is: your are in frame 3 eof=" will probably be undifined 1 or 2 times then come back true
if (EOF != "true") {
//check if the file is done loading... if this is true (not done loading) then loop back to frame 2 and check again.
gotoAndPlay(2);
}
// if EOF is true, then it will go on to frame 4.
//frame 4
trace("you are in frame 4 postest should be 25: postest="+postest);//output: you are in frame 4 postest should be 25: postest=25 ... hopefully it will be 25.
gotoAndStop ("diagram", 1);
Cattie
09-23-2003, 01:09 PM
OOo i get it, and I used your second solution..
Louise :p
good... so try:
//this code goes 'on' the movieclip 'loader'
onClipEvent(load){
this.loadMovie("test.php");
}
onClipEvent(data){
//this runs when the data is finished loading (so you can get rid of the EOF if you use this method).
trace(this.postest);
_parent.gotoAndPlay(the frame to play);
}
//on your main timeline:
//scene: diagram : first frame
trace(loader.postest);
postest = Number(loader.postest);
trace(postest);//do it again here to make sure the Number() function didn't return NaN.
tellTarget ("taart") {
gotoAndStop (postest);
}
Cattie
09-23-2003, 01:16 PM
Okay, I lost it????
I did that and I get no output at all??
Lo:p
carrie, look how i did it here:
i'm not using a real php file, you can use your original if you want.
Cattie
09-24-2003, 06:49 AM
Thanx tg,
But the problems won't stop comming...I forgot to tell you wicb version of flash I got... And when I try to open it, I get the message ....Unexpected file format....I got flash 5.
Which version are you using, I will install that, my brother has got all. (My brother is a real Software freak, comes in handy from time to time!)
Love Louise ^_^ :p
i use mx... i would have done it in 5 for you, but i no longer have that version on my box. if i remember to, i will rewrite the example for you on 5 tonight at home.
Cattie
09-24-2003, 02:27 PM
thanx tg,
your the best :p
Love Louise
see if this is better.
i havn't tested it, cause i'm kinda in a rush, but it should give you the idea of what i was talkin about above.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.