Be a Supporter!

Random Number Generator

  • 452 Views
  • 8 Replies
New Topic Respond to this Topic
Argentin
Argentin
  • Member since: Aug. 1, 2007
  • Offline.
Forum Stats
Member
Level 15
Game Developer
Random Number Generator 2009-02-12 08:25:05 Reply

Can somebody help me make one?
I'm not a coder, I'm an artist so....I can't code
But I need o make a random number generator

I need a code that picks a random number between 1 and 50
The thing is that it can't have button
It must pick a new number automaticly every week
So let's say that every sunday at 12 PM a new number is repicked
Can somebody make it?
It doesn't have to be fancy
Just a number that randomly changes every week

mimikun
mimikun
  • Member since: Feb. 11, 2009
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Random Number Generator 2009-02-12 09:40:18 Reply

try to put this script on new fla

var myrandom:Number = 0;
myrandom = 1 + Math.floor(Math.random() * 50);
trace("My random number now = "+ myrandom );

Cojones893
Cojones893
  • Member since: Mar. 9, 2003
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to Random Number Generator 2009-02-12 09:58:11 Reply

Change every week? So lets say 5 people view your flash file. You want all 5 to see the same number until sunday, then it changes and they all now see a new number?

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Random Number Generator 2009-02-12 10:00:17 Reply

The problem you have is not so much the random generator as the date/time issue, since the 'clock' will only run while a user is viewing the swf file. Since there's no guarantee they'll have it open every Sunday at 12 pm for your 'random' code to run, the only feasible way to do this is to do something with the Date & getTime() methods, and probably sharedObjects for saving/loading data to/from a user's PC.

I may be thinking with more complexity than is necessary, but what you want isn't as simple as it may seem. I'll have a think about it while I work for a bit and try to come up with a solution a bit later, assuming no-one else does so first.


- - Flash - Music - Images - -

BBS Signature
WolfAkela
WolfAkela
  • Member since: Dec. 19, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Random Number Generator 2009-02-12 10:26:54 Reply

I get the feeling it's not Flash that he needs.

Argentin
Argentin
  • Member since: Aug. 1, 2007
  • Offline.
Forum Stats
Member
Level 15
Game Developer
Response to Random Number Generator 2009-02-12 10:30:12 Reply

At 2/12/09 10:00 AM, Denvish wrote: The problem you have is not so much the random generator as the date/time issue, since the 'clock' will only run while a user is viewing the swf file. Since there's no guarantee they'll have it open every Sunday at 12 pm for your 'random' code to run, the only feasible way to do this is to do something with the Date & getTime() methods, and probably sharedObjects for saving/loading data to/from a user's PC.

I may be thinking with more complexity than is necessary, but what you want isn't as simple as it may seem. I'll have a think about it while I work for a bit and try to come up with a solution a bit later, assuming no-one else does so first.

Yes you're right
It's not that easy =P
But it can be done
The script should check the computer date
Let's say we set it on this hour to start
After 1 week from this time it changes and it stays changed
And after it is changed it counts 1 weeks and after that it changes

Argentin
Argentin
  • Member since: Aug. 1, 2007
  • Offline.
Forum Stats
Member
Level 15
Game Developer
Response to Random Number Generator 2009-02-12 10:37:34 Reply

Sorry for the double post but I have an even better idea
Instead of making it change after 1 week it should be changed when I say it
It would need the number and a buton
when i click the button it takes me to a frame that requires a password
After I insert the password I get to a button that allows me to click the reset button
It's easy :D

Glaiel-Gamer
Glaiel-Gamer
  • Member since: Dec. 28, 2004
  • Offline.
Forum Stats
Member
Level 28
Game Developer
Response to Random Number Generator 2009-02-12 11:28:44 Reply

You seed a RNG with the date (converted to # of days in int) / 7.

That way everyone is fed the same seed until the # of days passes the 7 mark.

I can't be arsed to look up the RNG right now, it's not that bad

Argentin
Argentin
  • Member since: Aug. 1, 2007
  • Offline.
Forum Stats
Member
Level 15
Game Developer
Response to Random Number Generator 2009-02-14 15:44:33 Reply

So can anybody help me make a simple random number generator ?