Random Function Query
Hey guys,
Im very new to actionscripting and i am currently designing a scene where i want to enable the user to click a button which would in return play a random sound file....ive got the sounds already in my library. Can anyone give me any help/advice
would really appreciate it.
Thanks
ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)
Posted on: 03-06-2005, 03:53 PM
View Complete Forum Thread with Replies
Sponsored Links:
Random Movement Query
Hi all,
I am trying to get a bee to fly randomly around the screen. I have searched the forum and found a tutorial that works - the bee does fly in all directions, except I want the bee to turn around and face the direction in which it flies each time. The script that I am using is below and would appreciate any help with inserting the necessary code. I have tried a number of codes but nothing works.
Code for frame1
//special thanks to Suprabeener for the code
function getdistance(x, y, x1, y1) {
var run, rise;
run = x1-x;
rise = y1-y;
return (_root.hyp(run, rise));
}
function hyp(a, b) {
return (Math.sqrt(a*a+b*b));
}
MovieClip.prototype.reset = function() {
//specify the width and height of the movie
width = 300;
height = 200;
//-------------------
var dist, norm;
this.x = this._x;
this.y = this._y;
this.speed = Math.random()*4+2;
this.targx = Math.random()*width;
this.targy = Math.random()*height;
dist = _root.getdistance(this.x, this.y, this.targx, this.targy);
norm = this.speed/dist;
this.diffx = (this.targx-this.x)*norm;
this.diffy = (this.targy-this.y)*norm;
};
MovieClip.prototype.move = function() {
if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
this.x += this.diffx;
this.y += this.diffy;
} else {
this.x = this.targx;
this.y = this.targy;
if (!this.t) {
this.t = getTimer();
}
if (getTimer()-this.t>1000) {
this.reset();
this.t = 0;
}
}
this._x = this.x;
this._y = this.y;
};
Code for MC:
onClipEvent(enterFrame){
move();
}
Thanks,
B
View Replies !
View Related
Random Movement Query
Hi all,
I am trying to get a bee to fly randomly around the screen. I have searched the forum and found a tutorial that works - the bee does fly in all directions, except I want the bee to turn around and face the direction in which it flies each time. The script that I am using is below and would appreciate any help with inserting the necessary code. I have tried a number of codes but nothing works.
Code for frame1
//special thanks to Suprabeener for the code
function getdistance(x, y, x1, y1) {
var run, rise;
run = x1-x;
rise = y1-y;
return (_root.hyp(run, rise));
}
function hyp(a, b) {
return (Math.sqrt(a*a+b*b));
}
MovieClip.prototype.reset = function() {
//specify the width and height of the movie
width = 300;
height = 200;
//-------------------
var dist, norm;
this.x = this._x;
this.y = this._y;
this.speed = Math.random()*4+2;
this.targx = Math.random()*width;
this.targy = Math.random()*height;
dist = _root.getdistance(this.x, this.y, this.targx, this.targy);
norm = this.speed/dist;
this.diffx = (this.targx-this.x)*norm;
this.diffy = (this.targy-this.y)*norm;
};
MovieClip.prototype.move = function() {
if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
this.x += this.diffx;
this.y += this.diffy;
} else {
this.x = this.targx;
this.y = this.targy;
if (!this.t) {
this.t = getTimer();
}
if (getTimer()-this.t>1000) {
this.reset();
this.t = 0;
}
}
this._x = this.x;
this._y = this.y;
};
Code for MC:
onClipEvent(enterFrame){
move();
}
Thanks,
B
View Replies !
View Related
AS Query- How To Incorporate Random Load
HI all...this is the fourth version of this question (previous posts were not answered) so hopefully, it's clear this time.
I have this script assigned to a button.
homebutton.onRelease = function() {
if (_root.section != "home.swf") {
_root.section = "home.swf";
_root.transition.gotoAndPlay("closing");
}
I'd like the "home.swf" to be a random clip chosen out of three .swf's. Is there a way to expand this script to include a random choice script?
Thanks.
View Replies !
View Related
AS Query- How To Incorporate Random Load
HI all...this is the fourth version of this question (previous posts were not answered) so hopefully, it's clear this time.
I have this script assigned to a button.
homebutton.onRelease = function() {
if (_root.section != "home.swf") {
_root.section = "home.swf";
_root.transition.gotoAndPlay("closing");
}
I'd like the "home.swf" to be a random clip chosen out of three .swf's. Is there a way to expand this script to include a random choice script?
Thanks.
View Replies !
View Related
My Query String Function
In case anyone was interested, here's a query-string routine I wrote that may be of some use to people. It works just like __GET(tolken) in PHP or Request.QueryString(tolken) in ASP. Just call queryString(tolken) where you want the value of a string you passed to the .swf file in URL. For example: ...src="mymovie.swf?valA=hi&valB=there"
queryString("valA") will return 'hi' and queryString("valB") will return 'there'
Below is the function definition. Just slap it wherever, the function is defined on the global scope.
Code:
_global.queryString = function(tolken) {
// Written by Gus Crawford. No usage restrictions,
// don't have to credit me, be happy and solve problems.
// The entire queryString:
var theQueryString:String = new String();
var theStart:Number = new Number(0);
var theLength:Number = new Number(0);
theQueryString = unescape(_root._url);
theStart = theQueryString.indexOf("?", 0);
theLength = theQueryString.length - theStart;
theQueryString = theQueryString.substr(theStart, theLength);
//_root.out.text = tolken;
// Good, we have the ENTIRE qstring isolated.
// now find our specific tolken
// look for our tolken name preceded by a ? or & symbol.
// look for ?tolken= or &tolken=
var valStart:Number = new Number(0);
var valEnd:Number = new Number(0);
var valLen:Number = new Number(0);
valStart = theQueryString.indexOf("?" + tolken + "=", 0);
if (valStart == -1) {
valStart = theQueryString.indexOf("&" + tolken + "=", 0);
if (valStart == -1) {
return "undef";
}
}
valStart ++;
valEnd = theQueryString.indexOf("&", valStart);
if (valEnd == -1) {
valEnd = theQueryString.length;
}
else {
valEnd --;
}
valLen = (valEnd - valStart) + 1;
var FinalValue:String = new String();
FinalValue = theQueryString.substr(valStart, valLen);
var ChopHere:Number = new Number(0);
var ChopThisLong:Number = new Number(0);
ChopHere = FinalValue.indexOf("=", 0) + 1;
ChopThisLong = (FinalValue.length - ChopHere) + 1;
FinalValue = FinalValue.substr(ChopHere, ChopThisLong);
return FinalValue;
}
View Replies !
View Related
Tricky RandomBG Function: Query
I have came across a tricky situation to find a code for:
The following is a code i have generated for displaying random frames when a movie loads. (this is contained in the onClipEvent load)
function randomBg() {
//generate random BG based on random frames within the MC
randFrame = random(3)+1;
bg_graphics.gotoAndStop(randFrame);
}
stop();
There are 3 movie clips placed on each frame of this movie clip (bg_graphics). Each of these movie clips has a short animation that i want to trigger somewhere later in the script.
Q: How could i target this randomly generated frame/movie clip to gotoAndPlay frame 2.
Do i need to generate an ID name for this bg_graphics moive clip?
Please help, anyone?????
Cheers
Peter.D
View Replies !
View Related
Tricky RandomBG Function: Query
I have came across a tricky situation to find a code for:
The following is a code i have generated for displaying random frames when a movie loads. (this is contained in the onClipEvent load)
function randomBg() {
//generate random BG based on random frames within the MC
randFrame = random(3)+1;
bg_graphics.gotoAndStop(randFrame);
}
stop();
There are 3 movie clips placed on each frame of this movie clip (bg_graphics). Each of these movie clips has a short animation that i want to trigger somewhere later in the script.
Q: How could i target this randomly generated frame/movie clip to gotoAndPlay frame 2.
Do i need to generate an ID name for this bg_graphics moive clip?
Please help, anyone?????
Cheers
Peter.D
View Replies !
View Related
HELP NEEDED With Query And Array Search Function
Hi,
im havin trouble when im searching for a value from an array (all of it). The array is determined by a query string which follows:
order.swf&LOCT0=bedroom&LOCT1=dwelling&LOCT2=kitch en&LOCT3=landing
Below is the script i am using. It works but it only searches the first array instead of the whole set?? what is wrong with it??
PHP Code:
Location = new Array();
for (i=0; i<numLocs; i++) {
Location[i] = eval("LOCT"+i);
}
for (i=0; i<numLocs.length; i++) {
if (Location[i] == "bedroom") {
_root.mc_list.bedroom._visible = true;
} else {
_root.mc_list.bedroom._visible = false;
}
}
Please help!
thanks,
Shahid
View Replies !
View Related
Complex Button RollOver/RollOut Effects Goto Function Query
Hi, I'm having a bit of a problem applying a funtion to my rollover/roll out effets button and would be very grateful if any one could help me!
http://www.kirupa.com/developer/mx20...ton_effect.htm
I can get my anmation working perfectly but instead of the button going to a website on press:
this.onRelease = function(){
getURL("http://www.kirupa.com","_blank");
}
I would like to go to another frame in my movie instead i cant seem to get it to work. Can any body help?
View Replies !
View Related
Has Anyone Tested How Random Is The Math.Random() Function?
Just wondering whether anyone out there has ever run any tests on how random the Math.Random() function is as a random number generator?
I've been asked me to test it to prove that it is random and it seems a pointless waste of time, so I'm hoping to get evidence from elsewhere to convince the powers that be that there's no need to run the tests.
I've googled for it but come up with nothing so I'm hoping there might be someone out there who has already done the research?
View Replies !
View Related
Random Function & Unique Random Numbers
Hello, after some searching i can't seem to find any good explanation to how and why i should use the Math.random() function so maybe i should explain how a function i need should work and someone maybe has some ideas.
I'm making a guessing program where you guess the right answer.
The function i have now randomly selects a number from 0 to 5 and then put's these five numbers into an array, the thing is that i need the numbers to be unique and i have no idea on how to make this.
Another thing i need to do is between these numbers that the random() function gets one is to be removed and instead i put the right answer there so now i also need one of the randomizes numbers to not be the right answer.
Also, how should a Math.random() function call look like so i can edit the range of numbers to randomize from?
View Replies !
View Related
How Do U Use Random Function?
i have a password field, which collects passwords from about 20 people. i need to be able to redirect these people to out of falsh movie to a new site depending on their password. for example A goes to site 1, B goes to site 2 and so on.
How is this done??
thanks in advance,
tm
View Replies !
View Related
Random Function
Hi,
I am trying to use the randon function to send the needle of a compass to a random position on a circle, i seem to encounter problems because of the negative numbers that inevitably come up the needle then goes crazy. Could it have something to do with the bounce motion that i have scripted into the needle?
Any ideas, here is the code i have been trying:
on (release) {
var myRandom = Math.floor(Math.random()*360)-1
_root.bounce.hand.rotdest = myRandom;
}
Please help, cheers
Richthemarine
View Replies !
View Related
Random Function - How?
Hello all,
Ive got this function:
theme1(){
xxx......etc
}
Similiarly ive got 7 more theme functions.
When my movie begins I want to randomly activate one of these themes. I tried but no luck.I ve tried something like:
in frame 1:
randomtheme=random(5);
in next frame:
YO="theme" add randomtheme;
"theme" add randomtheme add "()";
YO add "()";
HELP
miiz
View Replies !
View Related
How Can I Use Random Function
hi all i have five movie clips and i want every time i play the flash one of them only is played how
emmmmm i want the code as the follow
4 example my movies are named as follow
1 2 3 4 5
i want a telltarget function to pick one of them and play it i hope im clear
thanks alot
View Replies !
View Related
Random Function
was wonder with the random function, when you write it
random (50)
this pulls a number random from 0 to 50.
how ever if i wanted to make something random from 50 to 100 if the only way i can do this is like this
random(50)+50
andy ideas?
View Replies !
View Related
Random Function
Hi,
Is it possible to create a random number between two specific numbers?
Rather than just a number between 0 and 1 less than the specified number.
I would particularly like to use this so I can set the alpha of a MC between 50 - 100, and position it in a certain area on the stage.
I am using FlashMX.
Thanks!
View Replies !
View Related
Random Function
Hi all,
I'm having a little difficulty with a random function.
Here is the source
filename = ["ad1.swf", "ad2.swf", "ad3.swf", "ad4.swf"];
path = "";
i = filename.length;
k = Math.floor(Math.random()*i);
loadMovie(path+filename[k], MovieTarget1);
This is a 1 frame 'holder' to randomly cycle through a series of flash movies.
This tests fine from flash with the [ctrl + enter] method, even when I click on the swf alone it works perfectly. I stick it in a web page, nothing. Even if I export the html page from flash, the html page doesn't display the .swf the way that it does directly from flash.
Has anybody else encountered this? It doesn't work when I test locally and when I placed it on a server, still nothing.
If you have any advice I'd appreciate it,
Regards,
Simon
View Replies !
View Related
[MX] Using The Random Function
Hi,
I been making a resource which when a user hits a button a random image is show in a window within an interface. I have adapted code from a fruit machine example which was on the adobe website. It is all working fine at the moment, I was just wondering if anyone had a way of making it so that a random image is generated, but not the same image twice in a row, thus making it different everytime the button is hit?
I'd be most greatful for any help.
wakey
View Replies !
View Related
Random Function
Hi,
I want to make the an ascending random function.
This is the code:
var totalFrames = 7;
this.gotoAndStop(Math.floor(Math.random()*totalFra mes+1));
What i mean is, when the frame choosen is 4 then the next random frame be higher than 4. When it hits the top then the function would stop.
Please let me know if there is a way to do this.
Thanks a lot,
Adrian
View Replies !
View Related
Random Function...
I'll try to be as descriptive in my problem as possible hopefully to receive a descriptive solution.
I need to create something that initializes a function randomly. Say I have 30 different functions, but I only want one of them called randomly, how would I do this?
I can't make a random variable (let's say var rand = Math.random(30)) and say all the functions are named function1(), function2(), etc... could i make it in such away as the random number has an influence on the function? like functionrand()? I dunno if that's the best way to go at it....
I know I could use a bunch of if /else if statements... i.e. if(rand == 3){ do this} --- but that could be daunting if i have upwards of 100 functions!
Am I going at this right? I have a hundred quotes (created in separate movie clips) and all I'm doing is using the functions to control each ones alpha. So the random generate would generate a random alpha at a time i specify.
I hope it makes sense. Basically I wanna either call a random function or make one function that calls a different movieclip using attachMovie("movie1" -- how would i make this random using linkage?, "quote" -- we can keep that the same bc it'll replace it with another random movieclip later, some depth);
thanks for any help
View Replies !
View Related
Random Function
hey guys,
can anyone help me, atm i have a game where the user hits bees, now the bees have a random function, so they can move around:
//this code is on the bees itself
acceleration = 5
newpos = function () {
ranx = Math.round((Math.random ()*200));
rany = Math.round ((Math.random ()*200));
}
newpos();
this.onEnterFrame = function() {
this._x += ((ranx-this._x)/acceleration);
this._y += ((rany-this._y)/acceleration);
if (Math.round(this._x) == ranx || Math.round(this._y) == rany) {
newpos();
}
};
now i have it so when they get hit, the acceleration = 30. the bees get dizzy.
after you hit it again it will splat, i want to make the bees come towards the screen, so they can splat on the screen, in the users face. can anyone help me, much appreciated
cheers
View Replies !
View Related
Help With A Random Function
Hello actionscripters,
I wanna make a random function:
I have 6 movieclips in the library, and I wanna select one random movieclip and add it to the stage. The only condition is that I dont want the same movieclip 2 times in a row.
Is it an easy way to do this?
Help would be appreciated!
View Replies !
View Related
Random Function
Hello!
What is the best way to find a random number that is not equal to two specific values?
ex:
1) find random number (let's say from 0 to 5)
2) check if the result is not 4 or 5
3) If it is, run the random function again and again until the condition is met.
Or maybe there's a way to set up that at once (find random number that is not equal to 4 or 5).
Thanks!
View Replies !
View Related
Random Function
Hello!
What is the best way to find a random number that is not equal to two specific values?
ex:
1) find random number (let's say from 0 to 5)
2) check if the result is not 4 or 5
3) If it is, run the random function again and again until the condition is met.
Or maybe there's a way to set up that at once (find random number that is not equal to 4 or 5).
Thanks!
View Replies !
View Related
Random Function
Hello!
What is the best way to find a random number that is not equal to two specific values?
ex:
1) find random number (let's say from 0 to 5)
2) check if the result is not 4 or 5
3) If it is, run the random function again and again until the condition is met.
Or maybe there's a way to set up that at once (find random number that is not equal to 4 or 5).
Thanks!
View Replies !
View Related
Random Function In Netscape
I have a simple flash intro at http://www.kiprc.uky.edu that has three different scenes. When the intro starts, it randomly picks one of the scenes and plays it. This works wonderfully with MSE but in Netscape, it only plays the first scene everytime. Why does the random function not work in Netscape? Is there an easy fix?
View Replies !
View Related
Q: Random Delay Function
Hi
I'm trying to write(unsuccessfully) a random delay function. I want it to be generic enough so that it can be applied to many MC's in one movie.
It should therfore accept arguments for:
1 minimum delay(in seconds),
2 maximum delay(in seconds),
3 name of MC the delay applies to
Can anyone help with the proper syntax?
As well, what is the best way to have this function constantly running,
a) call it constantly from an On clipEvent enterframe MC
or
b) intermittently from say, the end of the MC where the delay is occurring?
Thanks in advance!
View Replies !
View Related
Array With Random Function
Can anyone help me with this problem I have a array in the main timeline.
quotes=["john","david", "Joseph", "ted","tim", "Jack"]
temp=parseInt( Math.random ()*5);
randomName=quotes[temp];
Then I have a MC with a dynamic text field inside it and on the mc clip I have
onClipEvent ( enterFrame ) {
this.quote=_root.randomName[temp];
}
I want the names in the array to come up random every time the user launches the MC with the Dynamic text field in it .
The code seems correct but it doesn't work . What am I doing Wrong.
View Replies !
View Related
Random X Function Not Working
The function is supposed to assign a random x value to a movie clip, however it is not working.
Whats wrong with this function?
This actionscript is being called from frame 1 of layer 1 on the root:
function randomX() {
x = _x.random(490)+30;
return x;
}
This script is being called from a movie clip on frame 1 of layer 1 on the root:
onClipEvent (load) {
function randomX();
}
onClipEvent (enterFrame) {
if (_root._currentframe == 1) {
_x = (randomX.x());
}
}
View Replies !
View Related
Random Function With No Repeat
Guys, I have a big problem
It is to do with randomising which one of 4 frames the movie goes to.
I have a script which randomly selects 1 of four frames.
frames = 4;
frameno = Math.ceil(Math.random()*frames);
gotoAndStop (frameno+1);
But i want it so that it only selects each frame once
If anyone has any idea on how to do this i would be so graftul.
Matt
View Replies !
View Related
Random Picture Function? (mx)
using: Flash MX
I am new here, just have a question about a random picture function i'm trying to get my flash banner working for my website.
here is my testing page:
http://www.shoutoutdesigns.com/new/test.html
as you can see, it is a bit messed up! ...I cannot figure out the actionScript for a random picture...see, how there are a few pictures flashing at the moment? ...I generally want ONE picture show up at a time. (not really a rotating thing)
currently, i have a mask layer..under it, is the movie clip where those pictures are. I tried putting this:
------------------------------------------------------------
//invoke the functionl pick a random number between 1-10
var destinationFrame = myRandom(1,10);
// now, send the playhead to that frame and stop!
gotoAndStop(destinationFrame);
------------------------------------------------------------
in the 1st frame of the movie clip (where the pictures are located) ..but it doesn't work...
so bascially, when someone comes onto my webpage, i want 1 of the 10 pictures come up, so if they were to refresh the page, it different picture would show up --does that make sense?? maybe i'm just going overboard with this?!
I hope someone can help me!
thanks for reading y'all.
the confused
View Replies !
View Related
Calling Random Function
GDay FK, Ok, heres the deal... Ive got 4 MCs in the library all exported under the same name that call them in the array. What Im looking to do is have the timer randomly generate a time, than randomly attach a MC out of the array and play it. I have a 2 frames. the first frame is a menu screen, this code lies on the second frame. What happens is, after a random amount of time, it jumps back to frame ones menu screen? Not quite sure where its getting that crazy idea from. Anyways, if youre infinite knowledge can shed a little light on where I left turned Id appreciate it... thanks.
Geoff
Code:
function pause(){
play();
clearInterval(timer);
}
DangerEvent = new Array();
DangerEvent[1] = "BLMissile";
DangerEvent[2] = "BRMissile";
DangerEvent[3] = "TRMissile";
DangerEvent[4] = "Mig23";
function AttachDangerEvent(){
for (m=1; m<=4; m++) {
attachMovie("DangerEvent"+[m],"DangerEvent"+[m]+"MC",10);
}
}
timer = setInterval(pause, random(5000));
if (timer > 0 && timer < 2000){
AttachDangerEvent;
} else if (timer > 2000 && timer < 3000){
AttachDangerEvent;
} else if (timer > 3000 && timer < 5000){
AttachDangerEvent;
}
View Replies !
View Related
Random Position Function
i'm trying to attach a mc and have it's position be 1 of 5 random locations. it seems like the first positions override any of the if statements. how do i get this to work? if p=0, i'd like the position to be centered (320,480). the following is on my main timeline:
Code:
function stimPosition(q) {
var p = Math.random(5);
q._x = 320;
q._y = 240;
var k = 20;
if (p == 1) {
q._x -= k;
q._y += k;
} else if (p == 2) {
q._x -= k;
q._y -= k;
} else if (p == 3) {
q._x += k;
q._y += k;
} else if (p == 4) {
q._x += k;
q._y -= k;
}
}
attachMovie("blob1", "blob1", 1);
stimPosition(blob1);
thanks in advance.
View Replies !
View Related
Random () Function Question..
I was using the random function which returns an integer and has only one parameter. Say I have this code attached to line2 a movieclip..
onClipEvent(enterFrame){
_root.line2._x=random(500);
}
flash makes the line appear randomly across the movie from 0 to 499. If I want the line to appear say in an area, perhaps pixels 200 to 300, how would I do that?
TIA...
View Replies !
View Related
Random Function Excluding Zero
hi there!
T1ger once posted a random function, and it goes like this:
Code:
function rand(min, max) {
return(random(max-min+1)+min);
}
what's the best way to use this excellent function, and exclude a certain number?
In my case I want min= -3 and max= 3, but I don't want to achieve zero.
thanx in advance!
View Replies !
View Related
Random Number Function Help
Hi All,
Can someone point me in the correct direction on creating a Random Number that excludes the value from the last time the function was used.
////my actionscript stub
LastRandom = //some value that I store using StoreLast Random()
MakeRandom ()
{
var randomidx = Math.ceil(Math.random()*5);
if randomidx = LastRandom {
//generate a new number and recheck until randomidx != LastRandom
}
StoreLastRandom()
}
Thanks in advance. There's got to be a better way to do this.
View Replies !
View Related
Random Function, How To Reset?
Hey guys. I'm working on a program I use in class to keep my kids' heads from exploding on a daily basis. The major aspect of this is a grid with nine text boxes which get randomly filled with vocab words, grammar problems, etc. (language arts class) for them to puzzle over.
Here's my problem. It's kind of complicated. I've got three types of functions.
The first chooses a number from 1 - 5, and based on the outcome, decides whether to stick vocab, grammar, or prefixes into the boxes. Once this has been decided, it runs the next function, which randomly selects (out of 75 or 50 or 20) the one item to stick in each box. I save the item (as a string) to the variable I want to use, and then I assign that item to each individual text box. The outcome looks something like this:
boxfill();
_level0.box_1 = selection;
boxfill();
_level0.box_2 = selection;
boxfill();
_level0.box_3 = selection;
and so on for nine boxes. boxfill() is the function that decides WHAT goes in the box, and "selection" is what it has decided on. Here's the weird thing: it will re-randomize to choose whether it should stick a vocab, grammar, or prefix into the box - but then it KEEPS the same one it chose for the last one. God this is so confusing trying to explain it. (example: for nine boxes it will choose three vocab words, three grammar problems, and three prefixes, but each vocab word is the same, each grammar the same, etc.) Is anyone following this?
Basic question: How do I reset the "randomization" so that it returns a new item? I'm banging my head against the wall. (My seventh graders are, too.)
View Replies !
View Related
Random Function Not Working
Hello,
I've been trying to create a flash website for two days now. So far most of it is up. However Im having trouble with loading random movies or jpegs for display on my site. The code is correct - I've tested it. Im using swfobject and I would like to know if anyone else has had problems like this.
Here is my code...
_root.loadMovie("portfolio" + random(25)+ ".jpg");
container._xscale = 100;
container._yscale = 100;
Its just the random function that seems to be causing the problem as I've created a gallery that loads up specific images using the loadmovie command.
So is there a way to load up random images without the random function, perhaps using an array - if so how? Ot if anyone else could think of a way please let me know!
Thanks for Helping.
View Replies !
View Related
Random Function With Sound
Hello,
I am working on a piece now that will have 10 invisible MC's (1-10) stacked on frame 1 in seperate layers that function like buttons on the main timeline. Each of these mc's will trigger a corresponding mc (A-J) to become visible and play and also start a sound file. This I have all worked out.
What I am writing about is a random function. When 1 triggers A, I would like one of five distinct MC's inside of A to be randomly selected to play, both with sound and with image.
Right now I'm working on the random function with sound, and I'm in need of soome assistance. I'm not sure of my approach, but why I'm stuck in particular now is because ususally when attaching a sound to an MC, when the sound is called it is through the name of the sound rather than the mc name and as I've created a random function I can't very well call the sound name as then it won't be random. Here's what I've got:
sound1 = new Sound(soundHolder1_mc);
sound1.attachSound("chime");
sound2 = new Sound(soundHolder2_mc);
sound2.attachSound("psychic");
sound3 = new Sound(soundHolder3_mc);
sound3.attachSound("doctor");
snd1 = this._parent.soundHolder1_mc.sound1;
snd2 = this._parent.soundHolder2_mc.sound2;
snd3 = this._parent.soundHolder3_mc.sound3;
var i = Number = Math.ceil(Math.random()*3);
soundMaker1_mc = eval("snd"+i);
invisible1_mc.onRollOver = function() {
sound1.start(0,100);
}
Any and all help would be appreciated.
-Llyfre
View Replies !
View Related
Running A Random Function
Hey everyone,
I've searched and.. I think I'm just not quite sure what I'm looking at... so here's what I want to do.
I have these three functions, I want flash to pick one and run it when someone loads the page. I want it to pick a random one, either gozilla, bowie, or mj.
// Fun animation 1
function godzilla()
{
menu_mc.godzilla_master._alpha = 100;
godSound.start();
bow = setInterval(function(){rainbow();clearInterval(bow ); }, 200 );
//timer = setInterval(function(){rainbow(); }, 500 );
}
// Fun animation 2
function mj()
{
menu_mc.mj._alpha = 100;
mjSound.start();
mjoff = setInterval(function(){menu_mc.mj._alpha = 0; }, 3000 );
}
// Fun animation 3
function bowie()
{
menu_mc.car._alpha = 100;
getStage();
new Tween(menu_mc.car, '_x', null, sw + 500, -500, 2, true);
bowieSound.start();
}
Right now I have it so when this function finishes
function finishIntro()
{
fade(intro_ring.welcome, 'out', 5);
menuControl();
// This loads a certain animation to surprise the user
god = setInterval(function(){godzilla();clearInterval(go d); }, 5000 );
}
It sets an interval to call the function godzilla. I want basically to use this function finishIntro, and in that last line.. in 5 seconds call either godzilla, mj, or bowie and I want flash to pick.
How do I do this?
View Replies !
View Related
Function For Random With No Repeats?
Hello, I'd like to have a random number generator that, once it chooses a number, deletes it from the pool of possibilities (it's for a photo gallery that shuffles images from an array)...either that or it keeps repeating the function until it gets a number that hasn't been used.
Any help would be greatly appreciated! Thank you!
View Replies !
View Related
Call Random Function
okey.. so i want to run a function i made... or should i say one random one.
i have function f0() to f10().
i know there is nothing wrong with my functions, but i don't know how to run one random.. i tried this:
Code:
r = random(11);
_root.f+r();
i my eyes that would call _root.f0() to f10()....
but no... plz help..
hope u understand what i'm trying to get help with.
View Replies !
View Related
Probability And Random Function ?
Hi all,
I'm wondering if there is a way to define different probability in flash. For example I want a random number between 1 and 10 but I want to be able to change the probability of appearing of one or more numbers. For example I want 2 to be 20% more likely to appear than all the rest.
I'm sure it can be done with some twisted Math.Random() functions but isn't there a better way like a predefined function or parameter that I'm unaware of ?....
thanks...
Lia
View Replies !
View Related
|