A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Quick Help on Random

  1. #1
    Member
    Join Date
    Jun 2002
    Posts
    45

    Quick Help on Random

    I have three (say) button actions

    (1) on (release) {
    _root.eck.jimmye._visible = false ;
    _root.leg.jimmyl._visible = false ;
    _root.murr1.jimmym._visible = false ;
    )

    (2) on (release) {
    _root.leg.blul._visible = false ;
    _root.eck.bluc._visible = false ;
    _root.leg.irishl._visible = false;
    )

    (3) on (release) {
    _root.eck.jimmye._visible = false ;
    _root.leg.jimmyl._visible = false ;
    )

    Is there any way, on pressing one button that one of above actions are executed randomly.

    any help appreciated!

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    in this example -
    clipA has nested clips - a1, a2, a3
    clipB has nested clips - b1, b2, b3
    clipC has nested clips - c1, c2, c3, c4, c5
    you need to put the clip names into an array and select a random clip
    Code:
    tgt = this;
    arr = [['clipA','a1','a2','a3'],
    ['clipB','b1','b2','b3'],
    ['clipC','c1','c2','c3','c4','c5']];
    
    function randVisible(){
    N1 = arr.length;
    rN1 = random(N1); 
    N2 = arr[rN1].length;
    rN2 = random(N2);
    rN2 == 0 ? rN2++ : null;
    trace(this[arr[rN1][0]][arr[rN1][rN2]]);
    tgt[arr[rN1][0]][arr[rN1][rN2]]._visible = false;
    };
    
    btn.onPress = function(){
    tgt[arr[rN1][0]][arr[rN1][rN2]]._visible = true; //reset
    }
    btn.onRelease = function(){
    randVisible();
    }

  3. #3
    Member
    Join Date
    Jun 2002
    Posts
    45
    thanks - I'll have go at it, although I was trying to avoid arrays! tks again.

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