Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
There seems to be no logic
Old 10-01-2004, 12:57 PM There seems to be no logic
lajkonik86's Avatar
Ultra Talker

Posts: 389
Trades: 0
this is really the most strange problem i ever had.
I've created my own flash game and it creates a checksum which it send along with the score to a php script. Which creates a highscore list.
The checksum is proving to be a problem. The php script is taking the score and creating a checksum.
The flash is taking the score and creating the checksum and is then supposed to send it.
There's just one problem..

When i take a look at my flash in swishmax and use the trace function to see if the checksum is calculated correctly everything seems fine.
But when export it to a html or flashplayer the variable gets send out wrong.

Flash code:
Code:
_root.scoreprecheck = _root.score*63478256;
    _root.scorecheck = 0;
    for (c=0; c<length(_root.scoreprecheck); c++) {
        _root.scorecheck+=_root.scoreprecheck.substr(c,1)*(c+1);
        _root.scorecheck-= "1";
    }
       trace(_root.scorecheck);
With a score of 200 this would result in 170. The trace does tell me it's 170 but when i play the game in flashplayer or in the web it doens't submit 170. It submits -11.
I don't get this at all. Maybe there's a different engine running swishmax or something?
Dont know hope somebody can help me with this.. I'm getting nowere

Don't know what good it would do but this is the code i'm using to submit to the php.

Code:
scorecheck = _root.scorecheck;
    getURL("http://localhost/test.php","_blank","POST");

Need help


Greetz
Thierry
__________________
Know what to Download

Please login or register to view this content. Registration is FREE
lajkonik86 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-01-2004, 01:59 PM
david's Avatar
King Spam Talker

Posts: 1,314
Location: Glasgow, UK
Trades: 0
All I can think of is that maybe your numbers are getting truncated or overflowing. Check the way they are being represented (is it integer or floating point?)
__________________

Please login or register to view this content. Registration is FREE
- Everything a webmaster needs - for free

Please login or register to view this content. Registration is FREE
- Free web hosts reviewed and rated

Please login or register to view this content. Registration is FREE
- Impartial hosting directory - Add your host today for FREE
david is offline
Reply With Quote
View Public Profile
 
Old 10-02-2004, 01:57 PM
lajkonik86's Avatar
Ultra Talker

Posts: 389
Trades: 0
dont really understand what you are saing
__________________
Know what to Download

Please login or register to view this content. Registration is FREE
lajkonik86 is offline
Reply With Quote
View Public Profile
 
Old 10-02-2004, 09:03 PM
Rufo's Avatar
Extreme Talker

Posts: 173
Trades: 0
I'd say that the line
_root.scoreprecheck = _root.score*63478256;
is causing the checksum numbers to be too big for Flash to cope with. Try a smaller number.

I think the line
_root.scorecheck-= "1";
shouldn't have the "s, either.

Rufo.
__________________

Please login or register to view this content. Registration is FREE
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Old 10-02-2004, 10:52 PM
kisk's Avatar
Extreme Talker

Posts: 161
Location: skynet
Trades: 0
not sure how flash handles type casting, but you're initially using scoreprecheck as a number

later you say "for (c=0; c<length(_root.scoreprecheck); c++) {" ... are you sure length() is not a string function and type casting your number to a string and taking the # of characters instead of the literal value?

I'm pretty sure the substr() function is a string function as well -- once again I don't know how flash handles this. If its anything like c++ then you're in trouble because automatic type casting is very dangerous.

... and as rufo said, _root.scorecheck-= "1"; ... you're trying to subtract a string from a number -- you won't get a favorable result doing that either.

just curious, how long have you been coding with flash? Flash's language is "actionscript" right?
kisk is offline
Reply With Quote
View Public Profile Visit kisk's homepage!
 
Old 10-03-2004, 04:42 AM
lajkonik86's Avatar
Ultra Talker

Posts: 389
Trades: 0
well when i check in my editor using trace everything seems to work just fine.
But when i try it in my flashplayer it doesn't calcullate well. This makes it very hard to debug and i don't know why flasheditor and flashplayer are doing stuff different.

Been doing actionscript for about a month

P.S. how do i go about converting a number to a string and vice versa
__________________
Know what to Download

Please login or register to view this content. Registration is FREE

Last edited by lajkonik86; 10-03-2004 at 04:45 AM..
lajkonik86 is offline
Reply With Quote
View Public Profile
 
Old 10-09-2004, 08:00 PM
Rufo's Avatar
Extreme Talker

Posts: 173
Trades: 0
Quote:
Originally Posted by kisk
are you sure length() is not a string function and type casting your number to a string and taking the # of characters instead of the literal value?
As far as I know, the argument to length() can be either a string or a number. To be sure, you could put
length(_root.scoreprecheck+'')
to force it to be cast into a string.

Quote:
Originally Posted by kisk
I'm pretty sure the substr() function is a string function as well
Yes, though I am fairly sure this works OK on numbers (integers at least).


Rufo
__________________

Please login or register to view this content. Registration is FREE
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Old 10-10-2004, 04:00 AM
lajkonik86's Avatar
Ultra Talker

Posts: 389
Trades: 0
At the moment i'm using this code
in flash.
PHP Code:
_root.scoreprecheck _root.score*63478256;
    
_root.scorecheck 0;
    for (
c=0c<length(_root.scoreprecheck); c++) {
        
_root.scorecheck+= _root.scoreprecheck.substr(c,1)*(c+1);
        
_root.scorecheck-= 1;
    }
    
trace(_root.scorecheck);

When running in swismax it outputs for a score of 200 177
when running in browser it outputs for a score of 200 -11

That leads me to conclude that the c<length(_root.scoreprecheck) part is working well.
Because the -1 part is being done.
So this bit of code
_root.scorecheck+= _root.scoreprecheck.substr(c,1)*(c+1);
Doesnt work in the browser... But does work in the editor.


Hope anybody knows how to fix this
__________________
Know what to Download

Please login or register to view this content. Registration is FREE
lajkonik86 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to There seems to be no logic
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.41305 seconds with 12 queries