dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Slot machine

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    3

    Slot machine

    Hey all (im using Flash cs3)

    Im in the process of making a small movie showing a slot machine which is suppose to run randomly. I have made all tweens as seperate movieclips in my library. After this I have made the following actionscript (AS2) which should play my movieclips. I can't get this working

    Code:
    		/*Indstiller maskerne for containerne*/
    	this.Container1.setMask(Mask1_mc);
    	this.Container2.setMask(Mask2_mc);
    	this.Container3.setMask(Mask3_mc);
     
    		/*Opstiller arrays for henholdsvis start-, icon- og slut-rulningen*/
    	startArray = new Array("start1", "start2", "start3", "start4", "start5", "start6");
    	iconArray = new Array("icon1", "icon2", "icon3", "icon4", "icon5", "icon6");
    	slutArray = new Array("slut1", "slut2", "slut3", "slut4", "slut5", "slut6");
     
    		/*Udtrękker et random nummer for hvert vindue*/
    	iconRandom1 = Math.floor(Math.random()*6);
    	iconRandom2 = Math.floor(Math.random()*6);
    	iconRandom3 = Math.floor(Math.random()*6);
     
    	function startRul() {
    		/* Containers som omhandler start-rulningen*/
    	this.Container1.attachMovie(startArray[iconRandom1], icon, 1);
    	this.Container2.attachMovie(startArray[iconRandom2], icon, 1);
    	this.Container3.attachMovie(startArray[iconRandom3], icon, 1);
    	}
     
    	function iconRul() {
    		/* Containers som omhandler icon-rulningen*/
    			iconRandom1 = Math.floor(Math.random()*6);
    			iconRandom2 = Math.floor(Math.random()*6);
    			iconRandom3 = Math.floor(Math.random()*6);
     
    			this.Container1.attachMovie(iconArray[iconRandom1], icon, this.getNextHighestDepth());
    			this.Container2.attachMovie(iconArray[iconRandom2], icon, this.getNextHighestDepth());
    			this.Container3.attachMovie(iconArray[iconRandom3], icon, this.getNextHighestDepth());
    			trace(i);
     
    			if (iconRandom1 == iconRandom2 && iconRandom2 == iconRandom3) {
    				trace("WINNER!");
    			}
    			clearInterval(intervalID);		
    	}
     
    	function slutRul() {
    		/* Containers som omhandler slut-rulningen*/
    	this.Container1.attachMovie(slutArray[iconRandom1], icon, 1);
    	this.Container2.attachMovie(slutArray[iconRandom2], icon, 1);
    	this.Container3.attachMovie(slutArray[iconRandom3], icon, 1);
    	}
    What I want is the functions to run in the following order after each other:

    startRul();
    iconRul();
    iconRul();
    iconRul();
    iconRul();
    iconRul();
    iconRul();
    iconRul();
    stopRul();

    I don't know how to do this. You got any help for me?

    Thanks
    Last edited by artLtx; 10-02-2008 at 07:14 AM. Reason: Forgot to write Flash version

  2. #2
    Senior Member
    Join Date
    Nov 2005
    Location
    Milan
    Posts
    119
    Set a variable to act as a counter. This variable will increment each time you run iconRul(), and when it gets to 7 it will call stopRul().

    PHP Code:
    var counter=0;

    function 
    startRul() {
       ...
    your code...
      
    iconRul();
    }

    function 
    iconRul(){
          ...
    your code...
          
    counter++;
         if(
    counter==7){
              
    stopRul();
              
    counter 0//reset
        
    }else{
             
    iconRul();
        }

    HTH

  3. #3
    Junior Member
    Join Date
    Oct 2008
    Posts
    3
    I can't test it right now, but this will give time for each movieclip to play?

  4. #4
    Senior Member
    Join Date
    Nov 2005
    Location
    Milan
    Posts
    119
    Ah. No it wouldn't, you'd need to call iconRul() at the end of the movieclip in that case.

  5. #5
    Junior Member
    Join Date
    Oct 2008
    Posts
    3
    How is that done?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center