dcsimg
A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Need a code..

  1. #1
    Junior Member
    Join Date
    Apr 2005
    Location
    The Netherlands
    Posts
    15

    Need a code..

    I need a code to when you click on a button, the button dissappears, delay 2 sec. than it comes back at a random spot

    I tried a code but i can't get it to work:
    Code:
    var sec = getSeconds();
    if (timer==2)
    {
    wbrth1.x=random (// Here comes the max random X);
    wbrth1.y=random (// Here comes the max random Y);
    }
    And yes, i know i'm a n00b in actionscript

    Thanks in advance, Purplemadness
    N00b flasheR
    -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    First in your start script put:
    code:

    //*************************************
    //Randomrange Function
    //Function to get a range of random numbers
    //*************************************
    function randomRange(Min,Max){
    return random(Max-Min+1)+Min;
    }



    then in your button put
    code:

    pressed=true
    this.hide()



    then make a script element that runs every 24 frames (assuming 12fps)
    code:

    if (pressed){
    element ("TextButton 86").x=root.randomRange(0,400)
    element ("TextButton 86").show()
    pressed=false
    }



    this assumes the button is named TextButton 86

  3. #3
    Junior Member
    Join Date
    Apr 2005
    Location
    The Netherlands
    Posts
    15
    Thank you!!!
    It worked
    Can you also get a counter how many times you clicked on the button in time?

    like this:
    _______________________________________________
    | Hit: 5 times Clicked: 8 times
    |
    |
    |
    | (Button)
    |
    -----------------------------------------------------
    N00b flasheR
    -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

  4. #4
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    473
    yeh make two edit boxes and name, under variable, hit and clicked. Than in the button make a script saying hit++ (that will add 1 to hit everytime the button is clicked). Than make a "mouse" element and say under "mouse clicked" clicked++. That will add one to clicked everytime you click.
    BC

  5. #5
    Junior Member
    Join Date
    Apr 2005
    Location
    The Netherlands
    Posts
    15
    Thanks, works great inside 3DFA, but when i export it, and open it, it wont detect the mouse when i click the screen, if i click on it nothing happens

    Look at this:

    Click
    Last edited by purplemadness; 09-26-2005 at 10:03 AM.
    N00b flasheR
    -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

  6. #6
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    473
    try opening the html file instead of the flash, I had some problems with that once. If you were already doing that, I suggest putting the movie file into a zip folder and posting it here for me to look at. Or maby someone else can help you.
    BC

  7. #7
    Junior Member
    Join Date
    Apr 2005
    Location
    The Netherlands
    Posts
    15
    Here it is, i am glad you want to help me
    Attached Files Attached Files
    N00b flasheR
    -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

  8. #8
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    473
    yeh ok, got it. You have to put in the starting script clicked=0 and hit=0 or it wont recognize it as a number. so yeh good luck.
    BC

  9. #9
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    473
    PS: swish!! (into the basket). score one for me
    BC

  10. #10
    Junior Member
    Join Date
    Apr 2005
    Location
    The Netherlands
    Posts
    15
    Thanks but it still doesn't work when i export it
    N00b flasheR
    -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

  11. #11
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    473
    uhh are you talking about the number adding? well one more thing to try, make the hitt++ and clicked++ into hit+=1 and clicked+=1. Are you sure you put the hit=0 and clicked=0 in the starting script after the random script? Well if that doesnt wokr pst the movie file again.
    BC

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