Click to See Complete Forum and Search --> : Need a code..
purplemadness
09-25-2005, 04:43 AM
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:
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
blanius
09-25-2005, 08:18 AM
First in your start script put:
//*************************************
//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
pressed=true
this.hide()
then make a script element that runs every 24 frames (assuming 12fps)
if (pressed){
element ("TextButton 86").x=root.randomRange(0,400)
element ("TextButton 86").show()
pressed=false
}
this assumes the button is named TextButton 86
purplemadness
09-25-2005, 11:00 AM
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)
|
-----------------------------------------------------
ConnELITE
09-25-2005, 03:07 PM
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.
purplemadness
09-26-2005, 10:56 AM
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 (http://wormsvideosbeta.wo.funpic.de/videos%20flash/movie_36.html)
ConnELITE
09-26-2005, 03:46 PM
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.
purplemadness
09-27-2005, 09:29 AM
Here it is, i am glad you want to help me :)
ConnELITE
09-27-2005, 04:29 PM
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.
ConnELITE
09-27-2005, 04:32 PM
PS: swish!! (into the basket). score one for me
purplemadness
09-28-2005, 03:09 AM
Thanks but it still doesn't work when i export it :(
ConnELITE
09-28-2005, 09:40 PM
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.
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.