What I want is for my mc to slide to a new random x position when it is less than 5 pixels away from its target, it keeps doing this. the problem is for some bloody &*�$(()** reason my random numbers only keep going up!! why is this?? i want to produce random numbers between 1 and 770 - this is my code..
I am now using the code for my background image which will rotate when you enter a new gallery.I can't get it to randomize.[code]I have tried adding: Math.floor(Math.random() * total); and it almost works. It seems everytime the last node is called it stops working (also at other random times, haven't found a pattern).
basically I want my engine to display one out of three objects at random. I thought I had figured it out but apparently not. A familiar error message appears, "A term is undefined and has no properties". I'm sure it refers to the object I'm trying to spawn, however it rejects every object I refer to. Is my approach reasonable or should I scarp what I've got?
Code: var spawnObject:Array = new Array("Object1", "Object2", "Object3"); var randomNumber:Number = Math.round(Math.random() * (spawnObject.length - 1)); if(spawnObject[randomNumber] == "Object1")
So i think i have fully coded my calculator but it still doesn't seem to be performing the calculations correctly. I can't see where i am going wrong. If i perform a calculation let's say 6*2 it outputs NaN then i straight away + by let's say 5 it outputs NaN again. And it doesn't make the operators display only once, so if i click on '+' twice it will display twice in the display when it is meant to only display once and in one of my functions i cleared the display field so that it would replace the number's when the next operation is performed but it doesn't seem to be doing that. I have been going over the code several times but i can't seem to identify where the problem is coming from.
So I can create a circle and an oval using trig in flash. But what if I want to create an oval with rounder points? I'm using this code for circles and ovals:[code]Could anyone help me in editing the code so i can control the tips of the oval and make them rounder?
I have a movieclip with an image fading in and out (using an actionscript tween class set to yoyo). This movieclip is loaded into a dummy movieclip when a button is pressed. The first time you click the button the fading movieclip plays as it should, fading in and out continuously. However, the second or subsequent times the button is clicked the fading movieclip goes crazy, half fading in/out and half jumping from one alpha value to another.
Building a flash website in CS3. I've made every button the exact same way, draw a rectangle, convert to symbol, type as either button or movie clip (doesn't seem to matter and I'm not using rollover stuff), alpha 0% and stick it on its own layer above everything else.Action scrip is as follows:
main1.addEventListener(MouseEvent.CLICK, gotoMain); main2.addEventListener(MouseEvent.CLICK, gotoMain); function gotoMain(event:MouseEvent):void { gotoAndPlay(1); }
that's with 2 buttons for main. I have the exact same code multiple times for many different buttons. It works everywhere except the last two buttons on my page will work the first time you click them from the main page, but then don't work after that until you click on the main page again. Then it works.These two:
the function is described on an earlier action keyframe:
bcontact1.addEventListener(MouseEvent.CLICK, gotoBcontact1); function gotoBcontact1(event:MouseEvent):void[code]...
Of course I've tried just having one button do this and copy/pasting the button on different areas of the movie, but nothing I've done fixes. I've even gone through and deleted every button and AS and redone it. I've put every button on its own layer (shouldn't matter but I'm trying everything I can think of).if there is an easier way of using AS to navigate a flash movie let me know. The other options I've seen seem a bit too complex at the moment.
The first half of the tween doesn't work but the second half does. It only does this when I add the code link._visible = 0;. This is to make the alpha completly disappear.
I'm generating a random number between min and max with this code:return min + (max - min) * Math.random();And it works. However, the random numbers are very little usually between "1 or 3" even if the max is 80.
I have a function that creates a Movieclip every two seconds. I want each Movieclip to go to a random frame. But if there is already a Movieclip on the stage that is currently on frame 4 (for example), then no other Movieclips can be on frame 4 until the other Movieclip on frame 4 is removed.
How to use math.floor(math.random) on a movieclip. Basically I have 2 movieclip called apple and orange. Apple and orange will move out from the right of the stage to the left of stage. the ending part of the stage is at the 3/4 mark and it will disappear. The disappearing part I have already solved it but not the appearing at different speed part. How do you like use the above method <Math.floor(math.random)> to make the apple and orange appear at different timing? I went to research on how to make random objects move at random and found math.floor(math.random).. but I do not know how to do it..to make them move at random.
This is what I have come up with using logic. apple.x -= math.floor(math.random(something something)); Minus sign before equal sign to make it move from right to left on the x-axis but the rest of the method of math.floor and math.random i have no idea how to use it. [URL]
I am making a script so I can have a dynamic menu, this menu loads external buttons at random 8 at a time, and unloads and reloads every 25 seconds.[code]...
my current little project requires text to be displayed for random time intervals. The timer code is as follows:
Code: var timer:Timer = new Timer(Math.random() * 10000); timer.addEventListener(TimerEvent.TIMER, changeQuotes); timer.start();
HOWEVER the random intervals are not random at all. In actuality the interval is *always* about 5 seconds between each text change for the current code. I've tried *A LOT* of different things to try and get it to be random but no matter what I do, the interval between is always the same. I want the intervals between to be random e.g. text appears for 2 seconds then goes and the next text appears for 5 seconds, then the next for 1 second, then the next for 8 seconds etc etc.
quick question, i have a loop playing where two MC holers have math.random script applied to them, allowing random images to be generated as it plays from a folder of images. i've gotten everything to work,initially i had about 60 images, i then added an additional 40, changed the coe to reflect this and had no problems. today i added an additional 196 images, but when i test my movie the numbers generated never surpass #101
is there a limit to the ammount of numbers output by math.random script?
I am trying to create an effect where my movieclip appears to float in space-like a particle suspended in liquid. Actually, that's exactly what it is I've managed to make it randomly move around, but this code just makes it seem to jump around jerkily. I'd like to smooth out the transitions with a tween but am having a heck of a time figuring out how to do it.
Here's the code (mc is the movieclip):
var timer:Timer=new Timer(1000,100000000); timer.addEventListener(TimerEvent.TIMER, floatMC); timer.start();
I am designing a game in which the player can travel through doors when they are the same color.There are three doors on stage: "door1","door2" and "door3". Each door is an instance of the same symbol. The symbol contains six frames, 3 copies of the door in a different color and 3 copies of the door in different colors with an icon of the player.. The frames are labeled "color1", "color2" "color3" and also "player1","player2" and "player3".
I am attempting to write code that tells Flash to a)select a door at random and then select a random frame for the randomly selected door to set the game for play. For instance, at startup, Flash randomly selects "door2"and then randomly selects "player2". So, the player's starting position will be on "door2" and the door will be red. After this, Flash will select the other door colors randomly from the frames labelled "color1","color2" or "color3".I am attempting to do this with this code:
var min:Number =1; var max:Number =3; ("door"+String(Math.floor(Math.random()* (max - min) + min) ));
This randomly selects the door.I would like this to randomly select the color of the randomly selected door.
I wonder how to make a Math.random() function, or something similar where it chooses a number from 0-9. But as the program progresses, another random variable will appear. That random value is what I want removed from the 0-9 scale. (The other random variable is also from 0-9)
Right now it generates a random number from between -1022 and -16 (positions along the x axis).
However, sometimes the skyline movie clip only moves a few pixels and looks boring.
I added 200 pixels to the movement (Math.random() * (-1022 - -16) +200 ) and it looks better. However, sometimes this slides the movie clip past -1022 or -16 and off the stage.
How can I set the value to +200 without passing -1022 or -16?
Im building an activity whereby I want random math questions to appear and for them to be addition, subtraction, division and multiplication with just two integers where the answer is never more than 50
so far I have
ActionScript Code: genQuestion.addEventListener(MouseEvent.CLICK, onGenerate); function onGenerate(e:Event = null):void
[code]....
which randomly generate addition questions whereby each integer couldn't be more than 25. But this isn't right because I could also have 40 +5 and it still be under 50.
[code], but I need to eliminate a 0 outcome from that formula. Is there a way to make sure I never get '0' as the result or should I do this another way?My goal is to multiply a Number with +/- 1, but it needs to be random of which one i multiply with.