Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can I create a button with a random event?

New Here ,
Jul 08, 2014 Jul 08, 2014

Well for example I have a deck of 52 cards, and I want the cards to be in different order everytime the game starts.

thanks

TOPICS
ActionScript
111
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2014 Jul 08, 2014
LATEST

use the shuffle function to reorder arrays,

function shuffle(a:Array) {

    var p:int;

    var t:*;

    var ivar:int;

    for (ivar = a.length-1; ivar>=0; ivar--) {

        p=Math.floor((ivar+1)*Math.random());

        t = a[ivar];

        a[ivar] = a

;

        a

= t;

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines