View Full Version : Help me please
.:.:Lui:.:.
July 6th, 2005, 02:43 AM
ok i need help with this one...URGENT
so could someone please reply this ASAP,
is there a code where when u get to this frame, it randomly chooses which code to use?
like
(code on frame)
gotoAndPlay(1);
//the random code here
gotoAndPlay(2);
, it would be like it wil lrandomly choose which one to do, the gotoAndPlay(1); or the gotoAndPlay(3);
if there is not, can someone tell me when u get on this frame it randomly chooses a frame that i specified?
please explain with proper instructions.
Thanks
,Lui
Blackspirit
July 6th, 2005, 03:28 AM
if(question)
{
Do search();
if(search()=="no result")
{
makeNewThread();
}
}
Look here for random frames:
http://www.kirupa.com/forum/showthread.php?t=95639&highlight=random+frame
.:.:Lui:.:.
July 6th, 2005, 03:42 AM
how do i work it?
(the 1 in the URL)
Blackspirit
July 6th, 2005, 04:15 AM
number=Math.ceil(Math.random()*2);
if(number==1){
gotoAndPlay(#);
}
if(number==2){
gotoAndPlay(#);
}
first it does random number, its either going to be a 1 or a 2.....
if its a 1, then gotoandplay(#)......where the # is any frame number you want.
So if you wanted it to go randomly between frame 1 and 3 you'd have.
number=Math.ceil(Math.random()*2);
if(number==1){
gotoAndPlay(1);
}
if(number==2){
gotoAndPlay(3);
}
.:.:Lui:.:.
July 6th, 2005, 04:34 AM
keeps going on the second one,
here's the code:
onClipEvent (enterFrame) {
onMouseDown = function() {
number=Math.ceil(Math.random()*1);
if(number==1){
this.gotoAndPlay(42);
}
if(number==2){
this.gotoAndPlay(48);
}
}}
Blackspirit
July 6th, 2005, 04:40 AM
Ok, you put Math.random()*1, your only ever going to get 1!
if you want a random number between 1 and 5 say
Math.ceil(Math.random()*5)
or between 1 and 2 say
Math.ceil(Math.random()*2)
.:.:Lui:.:.
July 6th, 2005, 04:45 AM
woopsie, i did it in 2 but then since it didnt work i tried it with..lol
.:.:Lui:.:.
July 7th, 2005, 01:21 AM
well can anyone help me please??
Lord Rahl
July 7th, 2005, 01:32 AM
Well Blackspirit put it as simple as its getting. Its like he said, all you have to do is change a few numbers. :cons:
number=Math.ceil(Math.random()*2);
if(number==1){
gotoAndPlay(42);
}
if(number==2){
gotoAndPlay(48);
}
</PRE>
.:.:Lui:.:.
July 7th, 2005, 01:37 AM
yes but it keeps choosing 2!!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.