A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: stoping random numbers?

  1. #1
    Member
    Join Date
    Apr 2002
    Posts
    56

    stoping random numbers?

    hi dear developers;
    i want to stop random numbers when a button press or any time..
    for example i set the numbers 100 between 300 and click this button
    script start to produce random numbers when i cllick other buton it will stop and any text show me number?
    is it imposible? any one can help me?

  2. #2
    Senior Member ryantsi's Avatar
    Join Date
    Sep 2005
    Location
    Exeter, Devon
    Posts
    288

    hey

    random numbers are not where i specialize in as :P but, i am sure your random number script will be using the onEnterFrame() method, IMO i would have the random number being outputed to a text field, then in your script put

    myButton.onRelease = function() {
    delete this.onEnterFrame
    }

    as long as you are using onEnterFrame this should work fine

    Ryan

  3. #3
    Member
    Join Date
    Apr 2002
    Posts
    56
    onClipEvent (enterFrame) {
    shuffle = random(9);
    }
    i am using this script but your script didnot stop it
    maybe you can give a new random script that i try to told?

  4. #4
    Member
    Join Date
    Apr 2002
    Posts
    56
    anyone help?

  5. #5
    Member
    Join Date
    Sep 2003
    Location
    Verona, Italy
    Posts
    61
    maybe because of the target.. instead of putting your as in your clip, name the istance of your clip "clip" and add this code in the first frame of the main timeline:

    clip.onEnterFrame = function():Void {
    this.shuffle = random(1000);
    }

    clip.onPress = function():Void {
    delete this.onEnterFrame;
    }

    hopefully it will work

  6. #6
    Member
    Join Date
    Apr 2002
    Posts
    56
    i am sorry but any example .fla can you send me

  7. #7
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    on the main timeline -

    2 buttons
    <instance names> go_btn & stop_btn

    a dynamic textfield
    <variable name> randTxt

    and code -
    Code:
    function randRange(mi, ma){
    var randomNum = Math.round(Math.random()*(ma-mi))+mi;
    return randomNum;
     }
    
    go_btn.onRelease = function(){
    onEnterFrame = function(){
    randTxt = randRange(100,300);
    }
    }
    
    stop_btn.onRelease = function(){
    onEnterFrame = null;
    }

  8. #8
    Member
    Join Date
    Apr 2002
    Posts
    56
    thanx my bro..

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