|
-
Juvenile Delinquent
php & this.onEnterFrame causing pain
I am at a loss for this one really. It works on 1 part of the swf but not the other. The following is on a keyframe.
Code:
stop();
loadVariablesNum("dig.php", 0, "POST");
//this constantly checks to see if the PHP script has sent
//the variable 'checklog' back to the movie and directs accordingly
this.onEnterFrame = function() {
if (checklog == 5) {
gotoAndPlay(58);
delete this.onEnterFrame;
}
if (checklog == 6) {
gotoAndPlay(59);
delete this.onEnterFrame;
}
};
Here's an example of the dig.php output: "status=Sorry, You are not a winner this time&checklog=6" (status is a dynamic text box in the movie).
Now I've checked and checklog is being received into flash but it won't execute the commands in the onEnterFrame. The weird thing is I have the exact same script at the start of my movie except it's for users logging in:
Code:
this.onEnterFrame = function() {
if (_root.checklog == 1) {
gotoAndPlay("sectorselection", 1);
_root.checklog = 0;
delete this.onEnterFrame;
}
if (_root.checklog == 2) {
gotoAndStop(3);
_root.checklog = 0;
delete this.onEnterFrame;
}
};
It's identical and works fine. The only difference is loadVariablesNum is on a button movie clip (On release). I've tried putting the loadVariablesNum on a button for the script that isn't working but, just as I thought, it doesn't make a difference.
You can see the swf here. Log in with user "cvotest" and pass "cvotest" so you have credits. Once you pick your sector you will be taken to a screen which I have cluttered with dynamic textboxes showing all the vars including checklog. You will see checklog=0. Select your square and then press "Dig". The code above then executes. It will then update checklog to 5 or 6 from the php file but the movie won't gotoAndPlay.
I've asked for a lot of help on here recently and have learned a lot from it. I wanted to figure this one out myself but I've searched all day and tried many different things but I'm now starting to give up hope. Can anyone bail me out one more time?
-
Hi,
why wouldn't you use a loadvars object and the onLoad handler instead of loadvariablesnum and the enterframe
Also it might help to put in an explicit _root.gotoAndPlay ... and the ,1 in one gotoandplay looks dangerous, too
Musicman
-
Juvenile Delinquent
Hi MM, thanks for the reply. I've only ever used loadvariablesnum. I've put _root before gotoandplay but still no dice. I've had a few stabs at what you've said but I think I'm doing it the wrong way as I've never really coded anything like this before:
Code:
this.onLoad = function() {
if (checklog == 5) {
_root.gotoAndPlay(58);
delete this.onLoad;
}
if (checklog == 6) {
_root.gotoAndPlay(59);
delete this.onLoad;
}
};
loadVariables("dig.php", this, "POST");
It's picking up the vars but still won't play (that's if I've done the above right). The php file will output 1 of 2 things:
Either: status=You Lost.checklog=6
or: prize=$prizecode=$codestatus=You Won.checklog=5
Using loadVariablesNum brings all the vars in but it just won't play. Going to look at examples of the loadVars to see how it's put together but I just can't get my head round why the loadVarNum worked earlier in the swf but not here.
Last edited by CVO Chris; 02-04-2008 at 09:34 AM.
-
Flashmatics
-
Juvenile Delinquent
Edit: spotted an error...
Last edited by CVO Chris; 02-04-2008 at 12:12 PM.
-
Juvenile Delinquent
Okay the original script works fine and so does the LoadVars object but it still didn't gotoandplay.
The reason was because there was a space after the checklog value. It didn't appear on the php output because I checked. It seems flash put that space in there. The solution: have the last character of the php file as an "&".
They should tell you things like this in tutorials. It would save hours and hours of head bashing agony
Thanks for your help MM and silentweed. I'm going to use the LoadVar object anyway even though the other script worked
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|