ActiveDen

Roulette Wheel Help!

1 post
  • Has been a member for 0-1 years
Moussetticus says

Hey everybody! So I’m working on a roulette probability application. (yes i know, it’ll most likely not work at all because roulette is completely random, but hell, i wanna give it a try and it gets me programming ) ive set it up so that i look at spaces that get hit most often in relation to where the ball last landed. That is…since it landed HERE , it’s most likely to go THIS many spaces from where it is or THAT many spaces. Its not concerned with what numbers are actually getting hit the most.

at the moment, i have it set up that there is another wheel inside the roulette wheel. The roulette wheel doesnt move, but the inside wheel does. within the inside wheel are 38 octants with one that is purple. it represents where the ball just landed: you tap/click the number it just landed, it changes the color of the space on the inside wheel (depending on how frequent that specific spot got hit[again – in relation to where the ball last was]) and then the inside wheel rotates (in radians) to coincide the purple space with the roulette space that was just hit…Make sense? I hope so lol.

Anyway, my issue is; I’m changing the inside spots color based on its name matching the name of the button tapped/clicked.

I’m trying to changing the inside spots color that matches the radian of the one associated to the button tapped/clicked.

here’s the code:

import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.ColorTransform;
var rouletteWheel:Array = [0,28,9,26,30,11,7,20,32,17,5,22,34,15,3,24,36,13,1,37,27,10,25,29,12,8,19,31,18,6,21,33,16,4,23,35,14,2];
var radianArray:Array = [0,9.473684211,18.94736842,28.42105263,37.89473684,47.36842105,56.84210526,66.31578947,75.78947368,85.26315789,94.73684211,104.2105263,113.6842105,123.1578947,132.6315789,142.1052632,151.5789474,161.0526316,170.5263158,180,189.4736842,198.9473684,208.4210526,217.8947368,227.3684211,236.8421053,246.3157895,255.7894737,265.2631579,274.7368421,284.2105263,293.6842105,303.1578947,312.6315789,322.1052632,331.5789474,341.0526316,350.5263158];
for(var i:Number = 0; i<38; i++){
    var currentBtn:MovieClip= MovieClip(this.getChildByName("btn_"+i));
currentBtn.btnNumber = i;
//create a attribute of hitNumber
currentBtn.hitNumber = 0;
currentBtn.radian = radianArray[i];
currentBtn.addEventListener(MouseEvent.CLICK, getInfo);
}//end of for loop
function getInfo(e:MouseEvent):void{
    var currentBtn:MovieClip = MovieClip(e.currentTarget);
currentBtn.hitNumber ++;
for(var i:Number = 0; i< rouletteWheel.length; i++){
if(currentBtn.btnNumber == rouletteWheel[i] ){
    var colorChange:MovieClip = MovieClip( hotWheel.getChildByName("spot_"+i) );
    var obj_color:ColorTransform = new ColorTransform();
if(currentBtn.btnNumber == 37){
            recentList.text =  "00 \n" + recentList.text;
        }
else{
    recentList.text =  currentBtn.btnNumber + "\n" + recentList.text;
}
angleText.text = String(currentBtn.radian);
//check currentBtn.hitNumber for color conditional
if(currentBtn.btnNumber !=0){
    if(currentBtn.btnNumber != recentList.text){
        if((currentBtn.hitNumber >= 7) && (currentBtn.hitNumber <= 13)){
            obj_color.color = 0x0099FF;
}//end of not 0
} else if ((currentBtn.hitNumber >= 14) && (currentBtn.hitNumber <= 20)){
        obj_color.color = 0x0000FF;
}
} else if ((currentBtn.hitNumber >= 21) && (currentBtn.hitNumber <= 27)){
    obj_color.color = 0x5959A6;
} else if ((currentBtn.hitNumber >= 28) && (currentBtn.hitNumber <= 34)){
obj_color.color = 0x808080;
} else if ((currentBtn.hitNumber >= 35) && (currentBtn.hitNumber <= 41)){
obj_color.color = 0xA6A659;
} else if ((currentBtn.hitNumber >= 42) && (currentBtn.hitNumber <= 48)){
obj_color.color = 0xE6E61A;
} else if (currentBtn.hitNumber >= 49){
obj_color.color = 0xFFFF00;
} else {
obj_color.color = 0x222222;
}
// applying the transform to our movieclip (this will affect the whole object including strokes)
colorChange.transform.colorTransform = obj_color;
hotWheel.rotation = radianArray[i];
}//end of conditional
}//end of for loop
}//end of getInfo

I’m doing this in Flash Professional btw. its easier I think so I can work with movieclips. the hotWheel is the inside wheel (its a movie clip). within it are 38 (movieclip) “spots” named spot_0 to spot_37. spot_0 marks where the ball just landed. I have another 38 movieclips that represent the visual table you’d place bets on. they act as the individual buttons you’d press – telling it where the ball just landed. (there are 2 text boxes as well. one that tells me the hotWheels rotation and another that displays the number of the most recent number)

http://img824.imageshack.us/img824/1917/explanationk.png

btw, its not because of the hypothetical ”...user presses 0 first…”; it would still misplace marks on spots that same way.

I hope I’ve given all the info you need. I’m really stumped on this.

by
by
by
by
by