PDA

View Full Version : Flash to Javascript


Ema
05-27-2002, 07:53 PM
Hello,

I have a little problem. I have a button in Flash called "Save Scores" that will do two things when it is clicked: save a score into a cookie and get the updated number of scores from the cookie.

Here's the problem. If I have only the line "getURL("javascript:SaveScore( '" .....);" this works fine.

If I have only the line "getURL("javascript:GetRecordNum()");" this works fine.

But if I have both of them together in the button, like below, then it doesn't work. It doesn't save the score, and it doesn't get the number of scores.

Does anyone know what the problem is?

Thank you very much in advance.


on(release)
{

getURL("javascript:SaveScore( '" + _root.name.name + "','" + scoreCount + "', '" + timeSpent + "') ");

getURL("javascript:GetRecordNum()");

gotoAndPlay(81);

}

Jesse
05-28-2002, 01:04 PM
Simplest solutions often being the ones that work I'm inclined to think that since you haven't terminated your JS calls with a semi-colon, that could be stuffing you up. Try:
getURL("javascript:SaveScore( '" + _root.name.name + "','" + scoreCount + "', '" + timeSpent + "');");
getURL("javascript:GetRecordNum();");

Ema
05-28-2002, 03:00 PM
Hmmm, I tried that and it didn't work. I fooled around for a bit and found a run-about way that did make it work. I made another movie clip and called it functions. On frame one, I put the actionscript
getURL("javascript:SaveScore('" + _root.name.name + "','" + scoreCount + "', '" + timeSpent + "');");

and on frame 20, I put the actionscript

getURL("javascript:GetRecordNum();"); .

So I just call the movie clip and make it run from frame 1 to 20. And that worked! Really odd.

Jesse
05-28-2002, 03:18 PM
Sure you're variables are all setup properly? Maybe you're passing a dummy value and causing one script to hang or something...

Ema
05-28-2002, 03:21 PM
I was playing around with the code some more and discovered something interesting. If I do only one getURL statement that calls both functions inside it, then it works! Like the following:

getURL("javascript: function1('my variables'); function2('my other variables');");

So I guess Flash doesn't like it if you call more than one getURL statements? Anyway, I really appreciate your help :-)

Abelius
05-28-2002, 06:23 PM
This was a real nice thread to read...
Informative.

Jesse
05-28-2002, 11:21 PM
Hrmm I should have thought to suggest just one line. Getting slow in my old age :)