Mil disculpas, se fue antes y no pude seguir. la idea es que de 50 jugadas, 11 tengan premios, como dije divididos por categoría. Encontré un código que adapté y que permite hacer el random, y ya están identificadas las combinaciones ganadoras, ahora lo que falta es que si bien sea random, pueda asignarse esta cantidad de premios
Esto es lo que llevo, si alguien me ayuda con el tema de forzar los premios y que sigan siendo random sus apariciones sería notable.
Saludos
Código ActionScript :
import flash.display.BitmapData;
Stage.scaleMode = "noscale";
#include "mc_tween2.as"
var demo = true;
oddsvar = 0;
txtcredits.text = 50;
var l = 215;
var t = 200;
var w = 420;
var h = 360;
var gap = 200;
var speed = 3;
var weight = 140;
var imgheight = 120;
var animation = "easeinoutSine";
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.load("settings.xml");
xml.onLoad = function()
{
oddsvar = this.firstChild.childNodes[0].attributes.Odds;
if(!demo) txtodds.text = this.firstChild.childNodes[0].attributes.Odds;
txtcredits.text = this.firstChild.childNodes[0].attributes.StartCredits;
}
var flag = 0;
var flag2= 0;
var orig = new Array();
var arr = new Array();
function Spin()
{
if (txtcredits.text > 0)
{
if(demo) oddsvar = int(txtodds.text);
oss = Math.floor(Math.random()*9)+1;
var depth= 0;
var xpos = l;
var num = 1;
for (j=1; j<4; j++) {
createEmptyMovieClip('slot_mc_L'+j, depth++);
_root["slot_mc_L"+j].attachBitmap(img, depth++, "auto", true);
_root["slot_mc_L"+j]._x = xpos;
_root["slot_mc_L"+j]._y = imgheight;
xpos += gap;
var ypos =t-imgheight;
arr[j] = new Array();
for (i=1; i<weight; i++) {
if (i < 4) {
if (flag < 2) {
var img:BitmapData = BitmapData.loadBitmap("cc"+1);
arr[j][i] = 4;
}
else {
r = orig[num];
var img:BitmapData = BitmapData.loadBitmap("cc"+r);
arr[j][i] = r;
num++;
}
}
else {
fl = Math.floor(Math.random()*49)+1;
r = Math.floor(Math.random()*9)+1;
fx = 0;
if (i > weight - 4) {
for (odds = 1; odds < oddsvar; odds++) {
if(fl == odds && fx == 0) { r = oss; fx = 1; }
}
}
var img:BitmapData = BitmapData.loadBitmap("cc"+r);
arr[j][i] = r;
}
_root["slot_mc_L"+j].createEmptyMovieClip("slot_mc"+i, depth++);
_root["slot_mc_L"+j]["slot_mc"+i].attachBitmap(img, depth++, "auto", true);
_root["slot_mc_L"+j]["slot_mc"+i]._x = 0;
_root["slot_mc_L"+j]["slot_mc"+i]._y = ypos;
ypos += imgheight;
}
}
for (k=1; k<4; k++) {
createEmptyMovieClip('mask_mc'+k, depth++);
_root["mask_mc"+k].beginFill(0x000088);
_root["mask_mc"+k].moveTo(_root["slot_mc_L"+k]._x, t); // L,T
_root["mask_mc"+k].lineTo(_root["slot_mc_L"+k]._x + _root["slot_mc_L"+k]._width, t); // L+W,T
_root["mask_mc"+k].lineTo(_root["slot_mc_L"+k]._x + _root["slot_mc_L"+k]._width, t + h); // L+W,T+H
_root["mask_mc"+k].lineTo(_root["slot_mc_L"+k]._x, t + h); // L, T+H
_root["mask_mc"+k].endFill();
_root["slot_mc_L"+k].setMask(_root["mask_mc"+k]);
}
if (flag > 0) {
status.text='spinning';
txtcredits.text = int(txtcredits.text) - 1;
slot_mc_L1.slideTo(slot_mc_L1._x, slot_mc_L1._y - slot_mc_L1._height+h-1, speed, animation);
slot_mc_L2.slideTo(slot_mc_L2._x, slot_mc_L1._y - slot_mc_L1._height+h-1, speed+1, animation);
slot_mc_L3.slideTo(slot_mc_L3._x, slot_mc_L1._y - slot_mc_L1._height+h-1, speed+1.5, animation);
orig[1] = arr[1][weight - 3]; orig[4] = arr[2][weight - 3]; orig[7] = arr[3][weight - 3];
orig[2] = arr[1][weight - 2]; orig[5] = arr[2][weight - 2]; orig[8] = arr[3][weight - 2];
orig[3] = arr[1][weight - 1]; orig[6] = arr[2][weight - 1]; orig[9] = arr[3][weight - 1];
flag2 = 1;
}
flag++;
}
}
Spin();
this.onEnterFrame = function() {
if (flag2 == 1)
{
if(!slot_mc_L3.isTweening()) {
iSlider.removeReplay();
flag2 = 0;
status.text = 'no gain';
same = txtcredits.text;
//TL
if (arr[1][weight-3] == arr[2][weight-3] && arr[1][weight-3] == arr[3][weight-3])
{
if (arr[1][weight-3] == 1) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 2) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 3) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 4) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 5) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 6) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 7) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 8) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 9) txtcredits.text = int(txtcredits.text) +1;
}
//ML
if (arr[1][weight-2] == arr[2][weight-2] && arr[1][weight-2] == arr[3][weight-2])
{
if (arr[1][weight-2] == 1) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-2] == 2) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-2] == 3) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-2] == 4) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-2] == 5) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-2] == 6) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-2] == 7) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-2] == 8) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-2] == 9) txtcredits.text = int(txtcredits.text) +1;
}
//BL
if (arr[1][weight-1] == arr[2][weight-1] && arr[1][weight-1] == arr[3][weight-1])
{
if (arr[1][weight-1] == 1) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 2) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 3) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 4) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 5) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 6) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 7) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 8) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 9) txtcredits.text = int(txtcredits.text) +1;
}
//LT
if (arr[1][weight-1] == arr[1][weight-2] && arr[1][weight-1] == arr[1][weight-3])
{
if (arr[1][weight-1] == 1) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 2) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 3) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 4) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 5) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 6) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 7) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 8) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 9) txtcredits.text = int(txtcredits.text) +1;
}
//MT
if (arr[2][weight-1] == arr[2][weight-2] && arr[2][weight-1] == arr[2][weight-3])
{
if (arr[2][weight-1] == 1) txtcredits.text = int(txtcredits.text) +1;
if (arr[2][weight-1] == 2) txtcredits.text = int(txtcredits.text) +1;
if (arr[2][weight-1] == 3) txtcredits.text = int(txtcredits.text) +1;
if (arr[2][weight-1] == 4) txtcredits.text = int(txtcredits.text) +1;
if (arr[2][weight-1] == 5) txtcredits.text = int(txtcredits.text) +1;
if (arr[2][weight-1] == 6) txtcredits.text = int(txtcredits.text) +1;
if (arr[2][weight-1] == 7) txtcredits.text = int(txtcredits.text) +1;
if (arr[2][weight-1] == 8) txtcredits.text = int(txtcredits.text) +1;
if (arr[2][weight-1] == 9) txtcredits.text = int(txtcredits.text) +1;
}
//RT
if (arr[3][weight-1] == arr[3][weight-2] && arr[3][weight-1] == arr[3][weight-3])
{
if (arr[3][weight-1] == 1) txtcredits.text = int(txtcredits.text) +1;
if (arr[3][weight-1] == 2) txtcredits.text = int(txtcredits.text) +1;
if (arr[3][weight-1] == 3) txtcredits.text = int(txtcredits.text) +1;
if (arr[3][weight-1] == 4) txtcredits.text = int(txtcredits.text) +1;
if (arr[3][weight-1] == 5) txtcredits.text = int(txtcredits.text) +1;
if (arr[3][weight-1] == 6) txtcredits.text = int(txtcredits.text) +1;
if (arr[3][weight-1] == 7) txtcredits.text = int(txtcredits.text) +1;
if (arr[3][weight-1] == 8) txtcredits.text = int(txtcredits.text) +1;
if (arr[3][weight-1] == 9) txtcredits.text = int(txtcredits.text) +1;
}
//CT
if (arr[1][weight-3] == arr[2][weight-2] && arr[1][weight-3] == arr[3][weight-1])
{
if (arr[1][weight-3] == 1) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 2) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 3) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 4) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 5) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 6) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 7) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 8) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 9) txtcredits.text = int(txtcredits.text) +1;
}
//CB
if (arr[1][weight-1] == arr[2][weight-2] && arr[1][weight-1] == arr[3][weight-3])
{
if (arr[1][weight-1] == 1) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 2) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 3) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 4) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 5) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 6) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 7) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 8) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-1] == 9) txtcredits.text = int(txtcredits.text) +1;
}
//4C
if (arr[1][weight-3] == arr[3][weight-3] && arr[1][weight-3] == arr[1][weight-1] && arr[1][weight-3] == arr[3][weight-1])
{
if (arr[1][weight-3] == 1) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 2) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 3) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 4) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 5) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 6) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 7) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 8) txtcredits.text = int(txtcredits.text) +1;
if (arr[1][weight-3] == 9) txtcredits.text = int(txtcredits.text) +1;
}
if (same != txtcredits.text)
{
var se:Sound = new Sound();
se.attachSound("win");
se.setVolume(80);
se.start();
}
}
}
}