ActionScript 3.0 :: Calling Phd Maths Gods Best Random Formula?
Apr 13, 2010
I have an app that was actually written for me. It's a multiple choice quiz basically where a question comes up and there are 4 answers. HOWEVER the answer always seems to be 80% on the same answer ie: BUTTON ONE out of the four. BILLIANT random function I don't think.Would this be a better answer formula to use?
function randomBetween(a:Number, b:Number):Number { return (a + Math.floor(Math.random()*(b-a+1)));}
View 8 Replies
Similar Posts:
Jan 13, 2012
i want to finish it in the end! i have this code which generated 20 stars and an ai player collects all of them (going for the one which is closest to it). This code was courtesy of -lauri... the code was
ActionScript Code:
import flash.events.Event;
import flash.display.MovieClip;[code].........
what i have currently is a player who moves around with the arrow keys collecting stars which appear at random moments... i wanted to make it so that the ai can also collect these stars and i am pretty sure that the code for that would be linked to what.
View 6 Replies
Mar 9, 2012
im working on a maths style jigsaw, and ive come across a problem of sorts, ive set random1_txt.text to 1 and random1_txt.text to 2 for testing, basically i want to randomise two textfields between 1 and 10, and also randomise the sign between either a - or a +
the answer can be computed by flash, now what i need it to do is stop on the frame number of the answer in answer_mc, these frames contain graphics of all numbers 1-20 in alpha format, this is so that the answer is in place, now the user can drag and drop movieclips into the answer box, and receive a correct or incorrect response
im at a loss on how to do this, i havent gotten around to randomising the sign as of yet i need to do more research but the general idea is as above
Code:
var startX:Number; //start of draggable piece
var startY:Number;
random1_txt.text = "1"
[Code].....
View 3 Replies
Feb 12, 2009
I have a Master SWF file that needs to load one of five different content SWFs on a random basis. In other words, I would like the visitor to see a different one of five content animations each time he/she visits the page. Is there a way to just call one of five different URLs on a random basis? Here's my code so far:
var swfLoader:Loader = new Loader();
swfLoader.x = 12;
var swfURL:String = "b2bAnim1.swf"
[code]...
I would like to randomly differ the URL variable (swfURL) to select one of the following five URLs:
b2bAnim1.swf
b2bAnim2.swf
b2bAnim3.swf
b2bAnim4.swf
b2bAnim5.swf
View 3 Replies
Nov 20, 2008
I was able to find different threads about random loads: the most are photocontainer, well I also found a text random loader But I can't find some about function random calling: in a site I'm building I have three functions (but other will be added) that when called in callback change general graphic appearance, loading a dozen of different parts in various container with attachMovie; I wish a function that loads them randomly
Actually I'm trying:
//variable "funArr" with the three function names
var funArr:Array = new Array("montaspazio", "montabilancia", "montaaereo");
[Code]...
View 1 Replies
Feb 17, 2009
I'm learning AS3. I would like to call an Array which contains five mc. Although when I check for errors on the script it says that it doesn't have errors, when I test the movie I have a
couple of errors.
1046 Type was not found or wan not a compile...
1180 Call to a possibly undefined method
placeRandomPicture();
Here is my script.
var listLoader:Array = new Array(back_1, back_2, back_3,back_4, back_5);
bt_1.addEventListener(MouseEvent.CLICK,
function (evt:MouseEvent): void {
function placeRamdomPicture (): void {
var iRandomImage = Math.round (Math.random() *
listLoader.length-1);
iRandomImage = (iRandomImage > -1) ? iRandomImage : 0;
picHolder.addChild(new listLoader [iRandomImage]);
} placeRandomPicture();
});
View 15 Replies
Feb 2, 2010
I've seen similar threads on here but nothing quite works for me, so sorry if this has been previously answered.I'm creating buttons dynamically in functions, and I want to load them ALL in randomly as you enter the frame.Let's say I've made an array, and it looks like this:
ActionScript Code:
var ButtonsArray:Array = new Array (6);
ButtonsArray[0] = ZeroButton;
[code]......
View 2 Replies
Jul 24, 2011
I am currently making a game with Flash CS5 and AS3... namely Tetris I have created my main menu and the objects and so on and have a few questions
1) How do I quit the game should a player press the quit button?
2) How do I get a button (Z and X) to rotate an object whilst the object is moving downwards (it is moving downwards using the timer function)?
3) How do I get the object to stop once it reaches the bottom of the screen? (im thinking something along the line of the hit detect but havent had much luck)
4) Any ideas on how to get flash to detect if a line is complete and therefore delete it? (it needs to segment blocks off the graphic)
5) My final and most important question (the bit im working on at the minute) how do i get flash to call random functions so that random tetrominoes appear on screen so that the game is different everytime and the blocks are random as the player plays)
View 2 Replies
Feb 27, 2009
I have a square grid with 100 grid squares in it.I want the cursor to display its grid position.Does Flash plot the position based on pixels - ie would my grid square have to be 100x100px or a multiple of that eg 200x200px? Or could it calculate the position no matter what size the square was? eg 186x186px ?
View 1 Replies
Dec 27, 2010
To create a sort of thick-pixel gradient shadow, I've got a simple loop which creates a new 200x5 pixel Shape (rectangle) with each iteration, assigning an alpha value and y value that changes relative to the loop's iteration.
Code:
var upperShadow:Shape = new Shape();
for (var k:int=0; k<10; k++) {
shadowAlpha = (1-(k/10))*.5;
trace(shadowAlpha); // traces .5, .45, .4, .35, .3, .25, .2, .15, .1, .05
[code]....
This creates a simple linear gradient since the alpha value changes linearly, but how would I go about creating some sort of exponential/logarithmic/cubic/circular value for the alpha, so that it falls off differently?
Are there a set of common equations that people use for this sort of thing, similar to the simple (1-(k/10))*.5 I use for the linear change from .5 to 0 in ten .5 increments?
View 3 Replies
Jun 6, 2006
how to do a random internal movie clips NOT calling external mcs with loadmovie?Let's say I have two internal mc's with instance name : my_mc1, my_mc2 and I want them to load randomly in starting in frame 2 here what I did so far:
var tab_mc = [this.my_mc1, this.my_mc2];
function randomMC(tab_mc) {
var i=tab_mc.length;
var r = (Math.floor(Math.random()*i);
[code]....
View 4 Replies
Apr 23, 2011
I have some code that looks like this:
ActionScript Code:
level_btn.x = 50 + (i - 1) % 10 * 50;
It sets the x location of my level button. But this is in a for loop (that's what the 'i' is for.) I run it and everything works perfectly, as it should, not a single problem. Then I press the auto format button in the flash actionscript editor. (It's the button that adds all of the ; to the end of each line and other stuff)
Well that changes my code to this:
ActionScript Code:
level_btn.x = 50 + i - 1 % 10 * 50;
thinking it's done me a favour but it hasn't. It's got rid of the brackets so it won't do the maths functions in the correct order. I've tried adding more brackets in places and other stuff but I just don't know how to fix it. It's annoying because every time I press the auto format button I have to add the brackets in again.
View 1 Replies
Jan 4, 2012
In the scene there is a star and an AI player.what equation would take the AI player on the most direct route to the star...i.e guide it into the path of the star...just to make things clear, the star is static and the ai plaer is controlled by the computer. i think you have to make two variables distx and disty and use some sort of trigonometry on them but i'm not entirely sure on how to go along doing this.
View 9 Replies
Jun 23, 2008
I have an application performing a simple calculation of adding and subtracting a amout to/from a balance amount.The problem is that every thing works fine except that when i remove the lkast amout from the balance ie: 15.25 -15.25 suppose i get something like -5.32907051820075e-15
View 2 Replies
Aug 1, 2010
I am trying to create a script, where the user inputs a maths equation (something simple like 5 + 2 * 10), I have managed to break down the text into an array and have the numbers in one array and the symbols in another, I wanted the computer to then work it out, however I cant seem to think of how to do this and the methods that I have tried have failed.there is one dynamic box and the value of that is then broken down by an array split(" "), however this leaves the values in an array and it is percieved as a string not a number and so when i try to work it outit just displays 5 * 10, how would i get it to work that out?
View 1 Replies
Mar 11, 2011
Code:
knob_mc.addEventListener(MouseEvent.MOUSE_DOWN,turn);
stage.addEventListener(MouseEvent.MOUSE_UP,endTurn );
function turn(e:Event):void[code].....
This is the code I'm using to move a knob the challenge is when i click on the knob it turns 90 either left or right depending where i click, I'd like it to stay still until I turn the knob, and second how do I get the angle in whole numbers??
View 3 Replies
Mar 14, 2009
I'm having a real problem trying to work this out...
A: I start with a movieclip on stage. it's 100x100.
B: I set xscale and yscale to 150.
C: I use "attachMovie" to add a little man into the square.The problem is, the man has an xscale of 100, but he is also scaled with the movieclip square container. So he appears too big.
D: What i would like to know, is what formula you would use to reduce his scale so he is the correct height, if the container movieclip had an xscale of 100?
[Code]...
View 2 Replies
Oct 21, 2009
I need to calculate the value of a formula which is passed dynamically by using text box.This formula contains a set of variables which are already declared and assigned a value(hard coded). I will provide a submit button , on clicking this button I must be able to evaluate the formula that I have passed dynamically using the text box.
View 2 Replies
Nov 7, 2011
I've been trying to look this up but not had any luck so far. I'm trying to make a simple pseudo-3D app, but I'm stuck on how to pull off the movement. If I have an object with x,y,z coordinates, and its movement speed, pitch, and yaw, what formula would I use for movement? So for example, if the object is at 0,0,0, moves 6 units per frame, and has pitch 30 degrees and yaw 15 degrees, what will be its coordinates next frame?
View 1 Replies
Oct 19, 2009
I have a little math problem with a game I'm making, and I can't for the life of me figure out the formula needed to accomplish something..Say, there's a sniping game, and a BIG image that must scroll from left to right according to the mouse movement.
Something like this:[URL]... In that example, the scene is 550 pixels wide, and the image is 1100, exactly two times the scene, so the formula is kinda easy..
[Code]...
the center of the image would be at x 1500, way over to the right of the scene, outside it, but it would fit inside the screen, like this (the blue square represents the real size of the scene):[URL]..Then when the mouse is at the far right side, that is 550 x, the image center should be at -950 x, like this:[URL]...
View 3 Replies
Jun 21, 2011
I'm not that good with Math and i have a formula for a that it's universal from what i understood but i dont know how to transform it to work with Flash's Math API.
View 2 Replies
Oct 1, 2011
I've been searching for the formula used intrinsically in Flash but I couldn't find anything. Does anybody know how the result colors are obtained when the 'layer' blend mode is chosen for the upper object? I thinks it's done separately in each channel using the transparency values.There might be some bitwise operations going on there but I'm not sure.
View 7 Replies
Apr 15, 2004
Someone got code for showing time left to download requested flash file?.
View 2 Replies
Jul 12, 2004
i'm trying to dynamically layout a calendar using actionscript and i'm no good at determining algorithms to quickly and efficiently lay things out.what i want to do is set it up per the image attached:
* where there are 7 columns and a varying number of rows.
* the top row has the 2 arrows and the month and year display.
* the second row has all the day headings, i.e. S, M, T, W, R, F, S
* and the rest of the rows will have the dates.
how do i come up with a nice clean formula to calculate the positions so all these elements align?
View 3 Replies
Mar 31, 2011
I am trying to code a loan calculator into Flash, however AS3 doesn't like my formula and won't calculate it, can someone help? Here is what I have:
loan=15000
apr=13
term=48
var loan_amount = (apr + (apr / (Math.pow(trm, (1 + apr)) -1 ))) * loan;
When I print out the loan_amount I get a 0.If I do: var loan_amount = (Math.pow(trm, (1 + apr)) -1); it will give me the result 1.0331079714165e55
As soon as I add the next part of the equation (apr / (Math.pow(trm, (1 + apr)) -1 )); it will give me the actual apr value as the result instead of the apr divided by the 1.0331079714165e55.Likewise, if I try to add a fixed value instead of the apr variable, it will return that fixed value instead of doing the math.
View 6 Replies
Jan 3, 2011
I´d like to know how would I make a formula for the calculation of speed.It´s not as simple as distance divided by time.I want something different.I have an helicopter.This helicopter is landed.He will take off with a small speed, but increasing speed.What I want is.This helicopter movement. In other words, increasing vertical speed, in a given time, say, 2.4 seconds, in a give distance, say, 100 pixels.After that he keeps vertical speed constantly. So I think the helicopter will start with its vertical speed slow, increasing, then, decreasing untill it reachs its constant vertical speed.
View 1 Replies
Dec 24, 2011
how to convert it to 0 and also if the number wsa 9, convert it to 1, and if it was 8 it gets converted to 2.. and so on.. where if it was 0 it would then be 10 Is there a formula? The 0 to 10, and 10 to 0 may not be possible but that's ok.
View 1 Replies
Dec 24, 2011
How to create a formula with 'POST' or 'GET' method
View 2 Replies
Jan 7, 2010
Currently, we have an activity in class wherein we're supposed to resize a Movieclip to a specified size restricted to any value between 50 and 250% that will be entered in an input text field. If the value entered goes beyond 250 or below 50%, it's also supposed to show a warning that the entered value isn't valid. Also, when a value is entered in the textfield, supposedly, it can be entered either by using the ENTER key or by clicking the resize button.
I've already managed to resize the movie clip according to the amount specified but I think there's something wrong with the "If" condition in my resizeShape function, because it still accepts values above 250 and below 50%. Also, I don't know how to make it so that both pressing the ENTER key and clicking the resize button enters the value without repeating the whole resizeShape function.Here's what I've done so far:
ActionScript Code:
var input_txt:TextField=new TextField();
var warningBig:TextField=new TextField();
var warningSmall:TextField=new TextField();[code]...........
View 2 Replies
Mar 19, 2012
Im having a problem with this code to convert decimal to binary ive got the formula but it wont print to the screen_txt only on the console and also my calculator wont let me change any other number other than 3 so if i press 7 binary should be 111 but it stays 11...
[Code]...
View 3 Replies