Jump to content
Search Community

Determining a Match

Applauz test
Moderator Tag

Recommended Posts

I'm using blitmask to make a scrolling slot machine style interface.

 

Here is what I have so far .. which is working.

var blitMask1:BlitMask = new BlitMask(strip1,strip1.x,strip1.y,strip1.width,100,true,true,0xffffff,true);
var blitMask2:BlitMask = new BlitMask(strip2,strip2.x,strip2.y,strip2.width,100,true,true,0xffffff,true);
var blitMask3:BlitMask = new BlitMask(strip3,strip3.x,strip3.y,strip3.width,100,true,true,0xffffff,true);



spin_btn.addEventListener(MouseEvent.CLICK, spin);



function spin(event:MouseEvent):void {

var i:int = 1;
    while (i <= 3) {
        var newNumber:Number = (randomNumber(0, 5) * 100) + 1400;
        
        
        
        TweenMax.to(this["strip" +i], 3 + (i*.5), {y:strip1.y + newNumber, onComplete:checkResults});
        
        i++;
        
    }



}







function randomNumber(min:Number, max:Number):Number {
    //good
    return Math.floor(Math.random() * (1 + max - min) + min);
}


function checkResults():void{
    
    trace("FINISHED");

    
}

The issue I am having is that even when 2 items are the same..  the Y coord is not the same.. so it's difficult for me to know which item was landed on.  

 

Hoping someone can help me be able to trace out which slot was actually landed on.

 

Any help is appreciated.

 

Cheers!

 

 

 

Link to comment
Share on other sites

Thanks so much for pointing me in the right direction.  My spinning is perfect.. even got the blur working nicely.

 

My final number is not calculating properly though :(   I think it has to do with the fact that in the original version each number height is 100 and there is 10 slots   ( 0 - 9 )

 

I've increased my number height to 300 and dropped down to 6 slots  ( 0 - 5 )

 

 

Do you spot anything I'm missing in my calculations ?

import com.greensock.*;
import com.greensock.easing.*;
import flash.events.MouseEvent;
import flash.display.MovieClip;

var blitMask1:BlitMask = new BlitMask(strip1,strip1.x,strip1.y,strip1.width,300,true,true,0xffffff,true);
var blitMask2:BlitMask = new BlitMask(strip2,strip2.x,strip2.y,strip2.width,300,true,true,0xffffff,true);
var blitMask3:BlitMask = new BlitMask(strip3,strip3.x,strip3.y,strip3.width,300,true,true,0xffffff,true);

var number1:int;
var number2:int;
var number3:int;

spin_btn.addEventListener(MouseEvent.CLICK, spin);



function spin(event:MouseEvent):void {

var i:int = 1;
	while (i <= 3) {
		var newNumber:Number = (randomNumber(0, 5) * 300) + 7200;
		
	
		
		//TweenMax.to(this["strip" +i], 1.5 + (i*.1), { y:strip1.y + newNumber, onComplete:checkResults});
		
		
		
		//tween to the relative value of newNumber
		TweenMax.to(this["strip" +i], 3 + (i*.1), {y:strip1.y + newNumber, onComplete:checkResults});
		//blur to 40 and then back to 0.
		TweenMax.to(this["strip" +i], 1.5, {blurFilter:{blurY:40}, repeat:1, yoyo:true});
		
		
		
		
		i++;
		
		
	}



}







function randomNumber(min:Number, max:Number):Number {
	//good
	return Math.floor(Math.random() * (1 + max - min) + min);
}


function checkResults():void{
	
	number1 = 6-((strip1.y % 1000)/100);
	number1 = number1 == 10 ? 0 : number1;
	
	number2 = 6-((strip2.y % 1000)/100);
	number2 = number2 == 10 ? 0 : number2;
	
	number3 = 6-((strip3.y % 1000)/100);
	number3 = number3 == 10 ? 0 : number3;
	
	trace("Number 1 is - " +  number1 );
	trace("Number 2 is - " +  number2 );
	trace("Number 3 is - " +  number3 );
	
	
	
	

	
}

In the original version I don't know why the number 1200 is there..   I increased this to 7200 as it makes the numbers spin longer.  I can't wrap my head around what I'm missing here.

 

 

Any help is appreciated.

 

 

 

 

Link to comment
Share on other sites

The problem is in this line

var newNumber:Number = (randomNumber(0, 5) * 300) + 7200;

I had to change to 300 because the height of each of my numbers is 300. 

 

The math doesn't seem to work with this

number1 = 10-((strip1.y % 1000)/100);
number1 = number1 == 10 ? 0 : number1;
Link to comment
Share on other sites

ok, the calculations had to be further adjusted as 

 

  • scaling messed up the height value
  • you had less numbers in each strip
  • your strips didn't start with a y of 0. they had a y of 200 which needed to be accounted for (which is why in my file I nested the clips inside a holder)

check the attached file. should work fine.

 

 

scrollNumbers_fixed.fla.zip

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...