RE: [Flashcoders] OT conver java code to flash

2006-11-05 Thread jim
Sorry, been off a couple of days. It doesn't need the % anymore as they
modulus was giving the rand.nextInt() an upper bound of 1 but not we are
multiplying the Math.random() by 1 which rives a similar result.

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 03 November 2006 14:19
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim, I had overlooked that fact and is probably why the game is not
behaving correctly.

Just to clarify, does it still need the % operator.

The java code is:

if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual))
  bestXPos = i;
}

And what you suggested was:

var intUpperBound :Number = 1;

if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /numOfEqual)) {

bestXPos = i; 
}

Should it be the following to be equivalent to the java functionality?

var intUpperBound :Number = 1;

if(Math.abs(Math.random()*intUpperBound) % 1  (intUpperBound
/numOfEqual)) {

bestXPos = i; 

}

Thanks

Paul



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 03 November 2006 13:52
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Its not quite just a random choice. I think that the other variables affect
what is happening here. The numOfEqual is filtering the returned number to
make sure that the bestXPos is always larger than the last one (I think)

So if we take this and enter some actual values on say the third loop
through:

Step 1:

numOfEqual++;

if(Math.abs(Math.random()*intUpperBound)  (intUpperBound / numOfEqual))
{
bestXPos = i; 
}

Step 2:

3;

if(Math.abs(0.333*1)  (1/ 3))
{
bestXPos = i; 
}

Step 3:

3;

if(3330  .333)
{
bestXPos = i; 
}

So you see in that case the Math.random() returned 0.333 so the resulting
number allowed you to pass the if statement but if it had been 0.334 or more
it would not have let you pass so bestXPos would not have been set.

The function you are using now is just giving you a 50/50 chance of passing
but the old java function was giving you variable odds depending on how many
passes had been performed.

Hope you understand as I am not great at explaining these things

Jim





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 03 November 2006 13:35
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim. I was curious as I have seen Math.rand() mentioned on various
flash forums and even on one of the macromedia / adobe live docs page. But I
guess these were just mistakes by people familiar with Java.

For my particular need, I have just simplified it to

if (Math.abs(Math.random())  (0.5)) {
bestXPos = i; 
}

As I was not sure what exactly the Java code did but realised it simply
wanted to implement making a random choice.

Thanks

Paul

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 03 November 2006 13:17
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

It is Math.random() sorry. The Math.random() function returns a number
between 1  0. The Java function that you are using returns a random integer
or whole number, I don think there is an upper bound to it.

The rest of your function is getting the modulus of the random number which
in fact is setting the upper bound to 1.

So to get the same sort of function you will need to set what upper bound
you want, I will use 1 for now. I havnt tested this but it should give a
similar result.

var intUpperBound :Number = 1;

if(goodness == bestWorst)
{
numOfEqual++;

  if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /
numOfEqual)) {

bestXPos = i; 

}

}

Hth
Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 23:15
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim

It is AS2, and the context is below. Btw what is the difference between
Math.rand() and Math.random()?

// ---
// If two moves are equally good, make a random choice
// ---

if (goodness == bestWorst) {

  numOfEqual++;

  if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual)) {

bestXPos = i; 

}

}

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 02 November 2006 22:50
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Which version of actionscript? And in whats the context? 

The only thing that dosnt look like it will directlty port over is the
rand.nextInt

RE: [Flashcoders] OT conver java code to flash

2006-11-05 Thread Paul Steven
Ah ok thanks Jim. Fortunately the connect4 game is all done and dusted now
and I have moved on to something more complex i.e a 3D rugby game hehe

Thanks for all your help

Paul

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 05 November 2006 20:58
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Sorry, been off a couple of days. It doesn't need the % anymore as they
modulus was giving the rand.nextInt() an upper bound of 1 but not we are
multiplying the Math.random() by 1 which rives a similar result.

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 03 November 2006 14:19
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim, I had overlooked that fact and is probably why the game is not
behaving correctly.

Just to clarify, does it still need the % operator.

The java code is:

if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual))
  bestXPos = i;
}

And what you suggested was:

var intUpperBound :Number = 1;

if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /numOfEqual)) {

bestXPos = i; 
}

Should it be the following to be equivalent to the java functionality?

var intUpperBound :Number = 1;

if(Math.abs(Math.random()*intUpperBound) % 1  (intUpperBound
/numOfEqual)) {

bestXPos = i; 

}

Thanks

Paul



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 03 November 2006 13:52
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Its not quite just a random choice. I think that the other variables affect
what is happening here. The numOfEqual is filtering the returned number to
make sure that the bestXPos is always larger than the last one (I think)

So if we take this and enter some actual values on say the third loop
through:

Step 1:

numOfEqual++;

if(Math.abs(Math.random()*intUpperBound)  (intUpperBound / numOfEqual))
{
bestXPos = i; 
}

Step 2:

3;

if(Math.abs(0.333*1)  (1/ 3))
{
bestXPos = i; 
}

Step 3:

3;

if(3330  .333)
{
bestXPos = i; 
}

So you see in that case the Math.random() returned 0.333 so the resulting
number allowed you to pass the if statement but if it had been 0.334 or more
it would not have let you pass so bestXPos would not have been set.

The function you are using now is just giving you a 50/50 chance of passing
but the old java function was giving you variable odds depending on how many
passes had been performed.

Hope you understand as I am not great at explaining these things

Jim





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 03 November 2006 13:35
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim. I was curious as I have seen Math.rand() mentioned on various
flash forums and even on one of the macromedia / adobe live docs page. But I
guess these were just mistakes by people familiar with Java.

For my particular need, I have just simplified it to

if (Math.abs(Math.random())  (0.5)) {
bestXPos = i; 
}

As I was not sure what exactly the Java code did but realised it simply
wanted to implement making a random choice.

Thanks

Paul

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 03 November 2006 13:17
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

It is Math.random() sorry. The Math.random() function returns a number
between 1  0. The Java function that you are using returns a random integer
or whole number, I don think there is an upper bound to it.

The rest of your function is getting the modulus of the random number which
in fact is setting the upper bound to 1.

So to get the same sort of function you will need to set what upper bound
you want, I will use 1 for now. I havnt tested this but it should give a
similar result.

var intUpperBound :Number = 1;

if(goodness == bestWorst)
{
numOfEqual++;

  if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /
numOfEqual)) {

bestXPos = i; 

}

}

Hth
Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 23:15
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim

It is AS2, and the context is below. Btw what is the difference between
Math.rand() and Math.random()?

// ---
// If two moves are equally good, make a random choice
// ---

if (goodness == bestWorst) {

  numOfEqual++;

  if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual

RE: [Flashcoders] OT conver java code to flash

2006-11-05 Thread jim
Ahh you are making the rugby game too. If you can I would suggest using
Actionscript 3 rather than 2, it is a lot more powerful. 

Im not sure what the pervasion of the latest player is but it should not be
a problem in terms of clients seeing the content if anyone raises that issue
with you. There was a documented severe security hole in the flash 8 player
that really requires you to use the latest version anyway, I can't remember
where the article is.

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 05 November 2006 21:13
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Ah ok thanks Jim. Fortunately the connect4 game is all done and dusted now
and I have moved on to something more complex i.e a 3D rugby game hehe

Thanks for all your help

Paul

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 05 November 2006 20:58
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Sorry, been off a couple of days. It doesn't need the % anymore as they
modulus was giving the rand.nextInt() an upper bound of 1 but not we are
multiplying the Math.random() by 1 which rives a similar result.

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 03 November 2006 14:19
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim, I had overlooked that fact and is probably why the game is not
behaving correctly.

Just to clarify, does it still need the % operator.

The java code is:

if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual))
  bestXPos = i;
}

And what you suggested was:

var intUpperBound :Number = 1;

if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /numOfEqual)) {

bestXPos = i; 
}

Should it be the following to be equivalent to the java functionality?

var intUpperBound :Number = 1;

if(Math.abs(Math.random()*intUpperBound) % 1  (intUpperBound
/numOfEqual)) {

bestXPos = i; 

}

Thanks

Paul



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 03 November 2006 13:52
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Its not quite just a random choice. I think that the other variables affect
what is happening here. The numOfEqual is filtering the returned number to
make sure that the bestXPos is always larger than the last one (I think)

So if we take this and enter some actual values on say the third loop
through:

Step 1:

numOfEqual++;

if(Math.abs(Math.random()*intUpperBound)  (intUpperBound / numOfEqual))
{
bestXPos = i; 
}

Step 2:

3;

if(Math.abs(0.333*1)  (1/ 3))
{
bestXPos = i; 
}

Step 3:

3;

if(3330  .333)
{
bestXPos = i; 
}

So you see in that case the Math.random() returned 0.333 so the resulting
number allowed you to pass the if statement but if it had been 0.334 or more
it would not have let you pass so bestXPos would not have been set.

The function you are using now is just giving you a 50/50 chance of passing
but the old java function was giving you variable odds depending on how many
passes had been performed.

Hope you understand as I am not great at explaining these things

Jim





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 03 November 2006 13:35
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim. I was curious as I have seen Math.rand() mentioned on various
flash forums and even on one of the macromedia / adobe live docs page. But I
guess these were just mistakes by people familiar with Java.

For my particular need, I have just simplified it to

if (Math.abs(Math.random())  (0.5)) {
bestXPos = i; 
}

As I was not sure what exactly the Java code did but realised it simply
wanted to implement making a random choice.

Thanks

Paul

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 03 November 2006 13:17
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

It is Math.random() sorry. The Math.random() function returns a number
between 1  0. The Java function that you are using returns a random integer
or whole number, I don think there is an upper bound to it.

The rest of your function is getting the modulus of the random number which
in fact is setting the upper bound to 1.

So to get the same sort of function you will need to set what upper bound
you want, I will use 1 for now. I havnt tested this but it should give a
similar result.

var intUpperBound :Number = 1;

if(goodness == bestWorst)
{
numOfEqual++;

  if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /
numOfEqual

RE: [Flashcoders] OT conver java code to flash

2006-11-03 Thread jim
It is Math.random() sorry. The Math.random() function returns a number
between 1  0. The Java function that you are using returns a random integer
or whole number, I don think there is an upper bound to it.

The rest of your function is getting the modulus of the random number which
in fact is setting the upper bound to 1.

So to get the same sort of function you will need to set what upper bound
you want, I will use 1 for now. I havnt tested this but it should give a
similar result.

var intUpperBound :Number = 1;

if(goodness == bestWorst)
{
numOfEqual++;

  if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /
numOfEqual)) {

bestXPos = i; 

}

}

Hth
Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 23:15
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim

It is AS2, and the context is below. Btw what is the difference between
Math.rand() and Math.random()?

// ---
// If two moves are equally good, make a random choice
// ---

if (goodness == bestWorst) {

  numOfEqual++;

  if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual)) {

bestXPos = i; 

}

}

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 02 November 2006 22:50
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Which version of actionscript? And in whats the context? 

The only thing that dosnt look like it will directlty port over is the
rand.nextInt() but you can use Math.rand() the rest is basic maths stuff you
can do in actionscript.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 17:15
To: 'Flashcoders mailing list'
Subject: [Flashcoders] OT conver java code to flash

Not familiar with Java code but trying to rewrite some code in Flash. Anyone
convert this line to flash actionscript please

if (Math.abs(rand.nextInt()) % 1 
(1 / numOfEqual)) 
bestXPos = i;

Thanks

Paul

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] OT conver java code to flash

2006-11-03 Thread jim
Yeah, sorry got my code mixed up, its Math.random() not Math.rand(). My
mistake.

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike Keesey
Sent: 03 November 2006 00:50
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:flashcoders-
 [EMAIL PROTECTED] On Behalf Of Paul Steven
 Sent: Thursday, November 02, 2006 3:15 PM
 To: 'Flashcoders mailing list'
 Subject: RE: [Flashcoders] OT conver java code to flash
 
 Thanks Jim
 
 It is AS2, and the context is below. Btw what is the difference
between
 Math.rand() and Math.random()?

There is no Math.rand(). There was a top-level function, random(), which
returned integers (I think), but it is deprecated. Just use
Math.random():

var MAX:Number = [some positive integer value];
var randomInt:Number = Math.floor(MAX * Math.random()); // Sets it to
some number from 0 to MAX - 1.

―
Mike Keesey



___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] OT conver java code to flash

2006-11-03 Thread Chris Benjaminsen

Hi Paul

Actually Math.random always return a positive number between 0 and 1 so 
you can further simplify to:


if (Math.random()  .5) {
	bestXPos = i; 
}



/Chris


Paul Steven wrote:

Thanks Jim. I was curious as I have seen Math.rand() mentioned on various
flash forums and even on one of the macromedia / adobe live docs page. But I
guess these were just mistakes by people familiar with Java.

For my particular need, I have just simplified it to

if (Math.abs(Math.random())  (0.5)) {
	bestXPos = i; 
}


As I was not sure what exactly the Java code did but realised it simply
wanted to implement making a random choice.

Thanks

Paul

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 03 November 2006 13:17
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

It is Math.random() sorry. The Math.random() function returns a number
between 1  0. The Java function that you are using returns a random integer
or whole number, I don think there is an upper bound to it.

The rest of your function is getting the modulus of the random number which
in fact is setting the upper bound to 1.

So to get the same sort of function you will need to set what upper bound
you want, I will use 1 for now. I havnt tested this but it should give a
similar result.

var intUpperBound :Number = 1;

if(goodness == bestWorst)
{
numOfEqual++;

  if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /
numOfEqual)) {

	bestXPos = i; 


}

}

Hth
Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 23:15
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim

It is AS2, and the context is below. Btw what is the difference between
Math.rand() and Math.random()?

// ---
// If two moves are equally good, make a random choice
// ---

if (goodness == bestWorst) {

  numOfEqual++;

  if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual)) {

	bestXPos = i; 


}

}

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 02 November 2006 22:50
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Which version of actionscript? And in whats the context? 


The only thing that dosnt look like it will directlty port over is the
rand.nextInt() but you can use Math.rand() the rest is basic maths stuff you
can do in actionscript.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 17:15
To: 'Flashcoders mailing list'
Subject: [Flashcoders] OT conver java code to flash

Not familiar with Java code but trying to rewrite some code in Flash. Anyone
convert this line to flash actionscript please

if (Math.abs(rand.nextInt()) % 1 
(1 / numOfEqual)) 
bestXPos = i;


Thanks

Paul

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
  


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo

RE: [Flashcoders] OT conver java code to flash

2006-11-03 Thread jim
Its not quite just a random choice. I think that the other variables affect
what is happening here. The numOfEqual is filtering the returned number to
make sure that the bestXPos is always larger than the last one (I think)

So if we take this and enter some actual values on say the third loop
through:

Step 1:

numOfEqual++;

if(Math.abs(Math.random()*intUpperBound)  (intUpperBound / numOfEqual))
{
bestXPos = i; 
}

Step 2:

3;

if(Math.abs(0.333*1)  (1/ 3))
{
bestXPos = i; 
}

Step 3:

3;

if(3330  .333)
{
bestXPos = i; 
}

So you see in that case the Math.random() returned 0.333 so the resulting
number allowed you to pass the if statement but if it had been 0.334 or more
it would not have let you pass so bestXPos would not have been set.

The function you are using now is just giving you a 50/50 chance of passing
but the old java function was giving you variable odds depending on how many
passes had been performed.

Hope you understand as I am not great at explaining these things

Jim





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 03 November 2006 13:35
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim. I was curious as I have seen Math.rand() mentioned on various
flash forums and even on one of the macromedia / adobe live docs page. But I
guess these were just mistakes by people familiar with Java.

For my particular need, I have just simplified it to

if (Math.abs(Math.random())  (0.5)) {
bestXPos = i; 
}

As I was not sure what exactly the Java code did but realised it simply
wanted to implement making a random choice.

Thanks

Paul

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 03 November 2006 13:17
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

It is Math.random() sorry. The Math.random() function returns a number
between 1  0. The Java function that you are using returns a random integer
or whole number, I don think there is an upper bound to it.

The rest of your function is getting the modulus of the random number which
in fact is setting the upper bound to 1.

So to get the same sort of function you will need to set what upper bound
you want, I will use 1 for now. I havnt tested this but it should give a
similar result.

var intUpperBound :Number = 1;

if(goodness == bestWorst)
{
numOfEqual++;

  if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /
numOfEqual)) {

bestXPos = i; 

}

}

Hth
Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 23:15
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim

It is AS2, and the context is below. Btw what is the difference between
Math.rand() and Math.random()?

// ---
// If two moves are equally good, make a random choice
// ---

if (goodness == bestWorst) {

  numOfEqual++;

  if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual)) {

bestXPos = i; 

}

}

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 02 November 2006 22:50
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Which version of actionscript? And in whats the context? 

The only thing that dosnt look like it will directlty port over is the
rand.nextInt() but you can use Math.rand() the rest is basic maths stuff you
can do in actionscript.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 17:15
To: 'Flashcoders mailing list'
Subject: [Flashcoders] OT conver java code to flash

Not familiar with Java code but trying to rewrite some code in Flash. Anyone
convert this line to flash actionscript please

if (Math.abs(rand.nextInt()) % 1 
(1 / numOfEqual)) 
bestXPos = i;

Thanks

Paul

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your

RE: [Flashcoders] OT conver java code to flash

2006-11-03 Thread jim
That is true, and its true in the Java code too, as the rand.nextInt() will
always return an integer which must be positive.

Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chris
Benjaminsen
Sent: 03 November 2006 13:42
To: Flashcoders mailing list
Subject: Re: [Flashcoders] OT conver java code to flash

Hi Paul

Actually Math.random always return a positive number between 0 and 1 so 
you can further simplify to:

if (Math.random()  .5) {
bestXPos = i; 
}


/Chris


Paul Steven wrote:
 Thanks Jim. I was curious as I have seen Math.rand() mentioned on various
 flash forums and even on one of the macromedia / adobe live docs page. But
I
 guess these were just mistakes by people familiar with Java.

 For my particular need, I have just simplified it to

 if (Math.abs(Math.random())  (0.5)) {
   bestXPos = i; 
 }

 As I was not sure what exactly the Java code did but realised it simply
 wanted to implement making a random choice.

 Thanks

 Paul

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of jim
 Sent: 03 November 2006 13:17
 To: 'Flashcoders mailing list'
 Subject: RE: [Flashcoders] OT conver java code to flash

 It is Math.random() sorry. The Math.random() function returns a number
 between 1  0. The Java function that you are using returns a random
integer
 or whole number, I don think there is an upper bound to it.

 The rest of your function is getting the modulus of the random number
which
 in fact is setting the upper bound to 1.

 So to get the same sort of function you will need to set what upper bound
 you want, I will use 1 for now. I havnt tested this but it should give
a
 similar result.

 var intUpperBound :Number = 1;

 if(goodness == bestWorst)
 {
   numOfEqual++;

   if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /
 numOfEqual)) {

   bestXPos = i; 

   }

 }

 Hth
 Jim

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Paul
Steven
 Sent: 02 November 2006 23:15
 To: 'Flashcoders mailing list'
 Subject: RE: [Flashcoders] OT conver java code to flash

 Thanks Jim

 It is AS2, and the context is below. Btw what is the difference between
 Math.rand() and Math.random()?

 // ---
 // If two moves are equally good, make a random choice
 // ---

 if (goodness == bestWorst) {

   numOfEqual++;

   if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual)) {

   bestXPos = i; 

   }

 }

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of jim
 Sent: 02 November 2006 22:50
 To: 'Flashcoders mailing list'
 Subject: RE: [Flashcoders] OT conver java code to flash

 Which version of actionscript? And in whats the context? 

 The only thing that dosnt look like it will directlty port over is the
 rand.nextInt() but you can use Math.rand() the rest is basic maths stuff
you
 can do in actionscript.

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Paul
Steven
 Sent: 02 November 2006 17:15
 To: 'Flashcoders mailing list'
 Subject: [Flashcoders] OT conver java code to flash

 Not familiar with Java code but trying to rewrite some code in Flash.
Anyone
 convert this line to flash actionscript please

 if (Math.abs(rand.nextInt()) % 1 
 (1 / numOfEqual)) 
 bestXPos = i;

 Thanks

 Paul

 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com

 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com

 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com

 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com

RE: [Flashcoders] OT conver java code to flash

2006-11-03 Thread Paul Steven
Thanks Jim, I had overlooked that fact and is probably why the game is not
behaving correctly.

Just to clarify, does it still need the % operator.

The java code is:

if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual))
  bestXPos = i;
}

And what you suggested was:

var intUpperBound :Number = 1;

if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /numOfEqual)) {

bestXPos = i; 
}

Should it be the following to be equivalent to the java functionality?

var intUpperBound :Number = 1;

if(Math.abs(Math.random()*intUpperBound) % 1  (intUpperBound
/numOfEqual)) {

bestXPos = i; 

}

Thanks

Paul



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 03 November 2006 13:52
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Its not quite just a random choice. I think that the other variables affect
what is happening here. The numOfEqual is filtering the returned number to
make sure that the bestXPos is always larger than the last one (I think)

So if we take this and enter some actual values on say the third loop
through:

Step 1:

numOfEqual++;

if(Math.abs(Math.random()*intUpperBound)  (intUpperBound / numOfEqual))
{
bestXPos = i; 
}

Step 2:

3;

if(Math.abs(0.333*1)  (1/ 3))
{
bestXPos = i; 
}

Step 3:

3;

if(3330  .333)
{
bestXPos = i; 
}

So you see in that case the Math.random() returned 0.333 so the resulting
number allowed you to pass the if statement but if it had been 0.334 or more
it would not have let you pass so bestXPos would not have been set.

The function you are using now is just giving you a 50/50 chance of passing
but the old java function was giving you variable odds depending on how many
passes had been performed.

Hope you understand as I am not great at explaining these things

Jim





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 03 November 2006 13:35
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim. I was curious as I have seen Math.rand() mentioned on various
flash forums and even on one of the macromedia / adobe live docs page. But I
guess these were just mistakes by people familiar with Java.

For my particular need, I have just simplified it to

if (Math.abs(Math.random())  (0.5)) {
bestXPos = i; 
}

As I was not sure what exactly the Java code did but realised it simply
wanted to implement making a random choice.

Thanks

Paul

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 03 November 2006 13:17
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

It is Math.random() sorry. The Math.random() function returns a number
between 1  0. The Java function that you are using returns a random integer
or whole number, I don think there is an upper bound to it.

The rest of your function is getting the modulus of the random number which
in fact is setting the upper bound to 1.

So to get the same sort of function you will need to set what upper bound
you want, I will use 1 for now. I havnt tested this but it should give a
similar result.

var intUpperBound :Number = 1;

if(goodness == bestWorst)
{
numOfEqual++;

  if(Math.abs(Math.random()*intUpperBound)  (intUpperBound /
numOfEqual)) {

bestXPos = i; 

}

}

Hth
Jim

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 23:15
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Thanks Jim

It is AS2, and the context is below. Btw what is the difference between
Math.rand() and Math.random()?

// ---
// If two moves are equally good, make a random choice
// ---

if (goodness == bestWorst) {

  numOfEqual++;

  if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual)) {

bestXPos = i; 

}

}

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 02 November 2006 22:50
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Which version of actionscript? And in whats the context? 

The only thing that dosnt look like it will directlty port over is the
rand.nextInt() but you can use Math.rand() the rest is basic maths stuff you
can do in actionscript.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 17:15
To: 'Flashcoders mailing list'
Subject: [Flashcoders] OT conver java code to flash

Not familiar with Java code but trying to rewrite some code in Flash. Anyone
convert this line to flash actionscript please

if (Math.abs

RE: [Flashcoders] OT conver java code to flash

2006-11-03 Thread Mike Keesey
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:flashcoders-
 [EMAIL PROTECTED] On Behalf Of Chris Benjaminsen
 Sent: Friday, November 03, 2006 5:42 AM
 To: Flashcoders mailing list
 Subject: Re: [Flashcoders] OT conver java code to flash
 
 Hi Paul
 
 Actually Math.random always return a positive number between 0 and 1
 [...]

Strictly speaking, it returns a *nonnegative* number from 0 (inclusive)
to 1 (exclusive). I.e, once in a blue moon it might actually return 0,
but it will never return 1; 0.9 (or something like that) is as close
as it gets.

The distinction doesn't matter much in practice, but
―
Mike Keesey


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] OT conver java code to flash

2006-11-03 Thread Igor Costa

You can use the Open-Source Framework

http://carbonfive.sourceforge.net/astranslator/api/com/carbonfive/flash/package-summary.html#documentation

Regards.

On 11/3/06, Mike Keesey [EMAIL PROTECTED] wrote:


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:flashcoders-
 [EMAIL PROTECTED] On Behalf Of Chris Benjaminsen
 Sent: Friday, November 03, 2006 5:42 AM
 To: Flashcoders mailing list
 Subject: Re: [Flashcoders] OT conver java code to flash

 Hi Paul

 Actually Math.random always return a positive number between 0 and 1
 [...]

Strictly speaking, it returns a *nonnegative* number from 0 (inclusive)
to 1 (exclusive). I.e, once in a blue moon it might actually return 0,
but it will never return 1; 0.9 (or something like that) is as close
as it gets.

The distinction doesn't matter much in practice, but
―
Mike Keesey


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com





--

Igor Costa
www.igorcosta.com
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

[Flashcoders] OT conver java code to flash

2006-11-02 Thread Paul Steven
Not familiar with Java code but trying to rewrite some code in Flash. Anyone
convert this line to flash actionscript please

if (Math.abs(rand.nextInt()) % 1 
(1 / numOfEqual)) 
bestXPos = i;

Thanks

Paul

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] OT conver java code to flash

2006-11-02 Thread slangeberg

Probably similar to:

var bestXPos:Number;
var numOfEqual:Number = (??); //whatever you set it to..

if  ( Math.abs( random() ) % 1(1 / numOfEqual ) ) {
  bestXPos = i;
}

On 11/2/06, Paul Steven [EMAIL PROTECTED] wrote:


Not familiar with Java code but trying to rewrite some code in Flash.
Anyone
convert this line to flash actionscript please

if (Math.abs(rand.nextInt()) % 1 
(1 / numOfEqual))
bestXPos = i;

Thanks

Paul

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com





--

: : ) Scott
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] OT conver java code to flash

2006-11-02 Thread Mark Winterhalder

Paul,

maybe this will make your work easier:
http://osflash.org/j2as

As for the code snippet, I have no idea what 'rand' is. Other than
that, it's exactly the same in ActionScript.

Mark


On 11/2/06, Paul Steven [EMAIL PROTECTED] wrote:

Not familiar with Java code but trying to rewrite some code in Flash. Anyone
convert this line to flash actionscript please

if (Math.abs(rand.nextInt()) % 1 
(1 / numOfEqual))
bestXPos = i;

Thanks

Paul

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] OT conver java code to flash

2006-11-02 Thread Paul Steven
Thanks Mark

I did see that but it involves installing Eclipse and a few other things and
I have a rather tight deadline of tomorrow so didn't want to spend a few
hours working out how to use a new app. Will look into it after I finish
this though

Paul

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark
Winterhalder
Sent: 02 November 2006 20:57
To: Flashcoders mailing list
Subject: Re: [Flashcoders] OT conver java code to flash

Paul,

maybe this will make your work easier:
http://osflash.org/j2as

As for the code snippet, I have no idea what 'rand' is. Other than
that, it's exactly the same in ActionScript.

Mark


On 11/2/06, Paul Steven [EMAIL PROTECTED] wrote:
 Not familiar with Java code but trying to rewrite some code in Flash.
Anyone
 convert this line to flash actionscript please

 if (Math.abs(rand.nextInt()) % 1 
 (1 / numOfEqual))
 bestXPos = i;

 Thanks

 Paul

 ___
 Flashcoders@chattyfig.figleaf.com
 To change your subscription options or search the archive:
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Brought to you by Fig Leaf Software
 Premier Authorized Adobe Consulting and Training
 http://www.figleaf.com
 http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] OT conver java code to flash

2006-11-02 Thread jim
Which version of actionscript? And in whats the context? 

The only thing that dosnt look like it will directlty port over is the
rand.nextInt() but you can use Math.rand() the rest is basic maths stuff you
can do in actionscript.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 17:15
To: 'Flashcoders mailing list'
Subject: [Flashcoders] OT conver java code to flash

Not familiar with Java code but trying to rewrite some code in Flash. Anyone
convert this line to flash actionscript please

if (Math.abs(rand.nextInt()) % 1 
(1 / numOfEqual)) 
bestXPos = i;

Thanks

Paul

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] OT conver java code to flash

2006-11-02 Thread Paul Steven
Thanks Jim

It is AS2, and the context is below. Btw what is the difference between
Math.rand() and Math.random()?

// ---
// If two moves are equally good, make a random choice
// ---

if (goodness == bestWorst) {

  numOfEqual++;

  if (Math.abs(rand.nextInt()) % 1  (1 / numOfEqual)) {

bestXPos = i; 

}

}

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim
Sent: 02 November 2006 22:50
To: 'Flashcoders mailing list'
Subject: RE: [Flashcoders] OT conver java code to flash

Which version of actionscript? And in whats the context? 

The only thing that dosnt look like it will directlty port over is the
rand.nextInt() but you can use Math.rand() the rest is basic maths stuff you
can do in actionscript.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven
Sent: 02 November 2006 17:15
To: 'Flashcoders mailing list'
Subject: [Flashcoders] OT conver java code to flash

Not familiar with Java code but trying to rewrite some code in Flash. Anyone
convert this line to flash actionscript please

if (Math.abs(rand.nextInt()) % 1 
(1 / numOfEqual)) 
bestXPos = i;

Thanks

Paul

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] OT conver java code to flash

2006-11-02 Thread Mike Keesey
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:flashcoders-
 [EMAIL PROTECTED] On Behalf Of Paul Steven
 Sent: Thursday, November 02, 2006 3:15 PM
 To: 'Flashcoders mailing list'
 Subject: RE: [Flashcoders] OT conver java code to flash
 
 Thanks Jim
 
 It is AS2, and the context is below. Btw what is the difference
between
 Math.rand() and Math.random()?

There is no Math.rand(). There was a top-level function, random(), which
returned integers (I think), but it is deprecated. Just use
Math.random():

var MAX:Number = [some positive integer value];
var randomInt:Number = Math.floor(MAX * Math.random()); // Sets it to
some number from 0 to MAX - 1.

―
Mike Keesey



___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com