Help With Randomizing
I did this a long time ago, but seemed to have lost the script.
What I'm trying to do is create a flash movie, that upon load, it will show a random image or movie clip, then have the movie scroll through a series of 7 or 8 other images or clips.
So each time a viewer comes to the site, it will be a random first image/clip they see, then it will scroll through the others in approx. 5 second intervals, fading in and out, etc...
Could anyone give me a hand!?
thanks!
FlashKit > Flash Help > Flash ActionScript
Posted on: 09-29-2006, 11:21 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Randomizing MC
hi guyz
wanna justa know, how to bloody Žell randomize running of some MC during playing the whole presentation.
(randomize= MC starts running 5 times in 5 minutes, alwayz after some randomized period of time, but never sooner than in 20 seconds)
object of randomizing: background flashes
thanx & cheers
Randomizing
Im trying to make a new Flash header for a website and I would like to make the header a grid and have random boxes in the grid light up quickly. Here is an example of the effect http://65.61.153.140/screenshots/2500/2592-ih.html
I was hoping there would be an easy way to create that grid, but Im starting to think Im goning to have to draw it.
Thanks
Randomizing
Is there a script I can put on a button that will make it take me to a different, random movie clip every time I click it?
Also, how do I arrange the clips? Can I put them right above each other in different layers, or do I have to spread them out through the timeline.
Help With Randomizing
I did this a long time ago, but seemed to have lost the script.
What I'm trying to do is create a flash movie, that upon load, it will show a random image or movie clip, then have the movie scroll through a series of 7 or 8 other images or clips.
So each time a viewer comes to the site, it will be a random first image/clip they see, then it will scroll through the others in approx. 5 second intervals, fading in and out, etc...
Could anyone give me a hand!?
thanks!
Randomizing FLV
Hi,
I'm using the following code to load an FLV into my flash movie. Does anyone know how to adjust the code to randomly load one of three FLVs? (video_1.flv, video_2.flv, video_3.flv)
Code:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);
ns.play("video_1.flv")
Cheers!
Randomizing
hi
i have a game and i have money that you collect. so far i have gotten it so that it increases your score when you hit it but i can not make the money jump to a random place.
here is the compressed swf file
Car Game #01.zip
here is the code i added to the car (this is the only code i used)
ActionScript Code:
onClipEvent (load) {
_root.score = 0;
speed = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE)) {
speed = 0;
}
if (Key.isDown(Key.UP)) {
speed += 1;
}
if (Key.isDown(Key.DOWN)) {
speed -= 1;
}
if (Math.abs(speed)>12) {
speed *= .7;
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 15;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 15;
}
if (Key.isDown(Key.SHIFT)) {
speed *= .7;
}
if (_root.moneybag1.hitTest(_x+x, _y+y, true)) {
_root.score += 10;
}
if (_root.coins1.hitTest(_x+x, _y+y, true)) {
_root.score += 5;
}
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}
please help
Thank You
Randomizing
How can i make to make this
If it would be
Strenth:
Inteligent:
Dexterity:
Luck:
Each category should have a dynamic text right?
So on each one i should put this? Math.floor(Math.random() ?
Correct me if im wrong!
Help With Randomizing
I need some help with the math.random function. I want to be able to randomly play 1 of 3 movieclips each time a user watches my movie.
I'm not that great with actionscript so here's what I attempted to do (if there is an easier or better way, PLEASE HELP!):
I created a movieclip containing the 3 clips I want to choose from and put a label at the beginning of each of these clips (they're videos, pretty long). In the first 3 frames I put gotoandplay actions to each of the labels. I put this movieclip on the stage and gave it an instance name of "spot". On my actions layer I put the following actionscript:
ads = 3;
spot.gotoandplay(math.random()*ads);
My understanding was that it would randomly choose a number...either 1, 2, or 3...which would play that frame in my "spot" movieclip. Every time I play it however, it only plays the first clip...never the other two. Where did I go wrong?
Randomizing...
Hey all, my 1st post here....
How do I randomize the _currentframe in a movie clip duplicated by yet another randomizer. Heres what ive got:
set("clipNum", 0);
set("randNum", Math.random()*100);
if (randNum<20) {
randNum = 20;
}
while (clipNum<randNum) {
duplicateMovieClip("original", "new"+clipNum, clipNum);
setProperty("new"+clipNum, _x, Math.random()*500);
setProperty("new"+clipNum, _y, Math.random()*500);
set("size",Math.random()*70);
setProperty("new"+clipNum, _xscale, size);
setProperty("new"+clipNum, _yscale, size);
setProperty("new"+clipNum, _alpha, Math.random()*100);
clipNum=clipNum+1
}
I want to add something to make the new clips start playing in different spots...all Ive managed thusfar is to lock up flash... (I didnt know _currentframe was read-only)
Is there some way to use a variable in a path name?
Randomizing An ARRAY?
Hey gang,
Problem:
I have an array which I want to 'jumble'. Does actionscript have anything built in for this or do I need to make some long drawn out jumble process?
thanks!
Randomizing Animation
I am sort of new to flash, but I wanna know how to like randomize graphics that appear on the screen. I want something to appear in a random spot on the stage and then fade out and I want that to happen repeatedly at random times. Can anyone help me with this?
Randomizing Images
i have a flash movie embedded in an html page. is it possible for the flash movie to randomly choose a different image to display, based on a refresh of the page? if so, how do I do it!!? thank you....
Randomizing Frame In MC
I've set up a movie clip with a timeline consisting of five frames, each with a separate image on it. I've given it the instance name mapMC.
I have a button on my main timeline with the following coding:
on (release) {
begin = random(5) + 1;
_root.mapMC.gotoAndStop (begin);
}
The idea is for the user to be able to click on the button and be taken to a random image in the clip. My only problem is sometimes the random selection is the same as the current frame, so it looks like nothing happens when the button is clicked. Can anyone help me modify my coding so the current frame # will be excluded from each new random selection?
I'm also curious if anyone knows the coding to simply make the button cycle through the five frames in order. I've experimented with the increment syntax but haven't figured out how to get the playhead to go from frame 5 back to frame 1 after it increments fully.
Thanks in advance,
Jeremy
Help Randomizing An Array
Here is my code. My problem is that the script forgets some of the elements in the array.
Code:
deck = new Array("c1","c2","c3","c4","c5","c6","c7","c8","c9","c10","c11","c12","c13","c14","c15","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12","f13","f14","f15","s1","s2","s3","s4","s5","s6","s7","s8","s9","s10","s11","s12","s13","s14","s15","st1","st2","st3","st4","st5","st6","st7","st8","st9","st10","st11","st12","st13","st14","st15","id1","id2","ra1","ra2","jk1","jk2","jm1","jm2","dj1","dj2","ls1","ls2","sm1","sm2","bh1","bh2");
trace(deck);
caa = deck.length;
ca = deck.length;
trace(caa);
trace(ca);
new_deck = new Array();
for (x = 0; x <= caa; x++) {
trace(x);
i = random(ca);
i = i+1;
trace(i);
new_deck[x] = deck[i];
for (t = i; t < ca; t++) {
deck[t] = deck[t+1];
blah = deck.pop();
}
}
trace(new_deck);
stop();
Randomizing _x And _y With Multiple MC--- Please Help
for (i=2; i<=100;i++) {
square.duplicateMovieClip("square" +i+"_mc",i);
square_.x= i*Math.random();
square_.y= i/Math.random();
}
this is the code on my main timeline frame one. I have a MC called square just for testing, and it is being duplicated 100 x, but i am having serious trouble figuring out how to make them randomly pop up on the screen. and also if anyone can tell me, if i assign a tween inside my MC, when I duplicate, the tween will be duplicated too right>?
Please help,
tony
Randomizing Scenes
I have made a quiz which has 2 different types of question. In the first scene 5 randomly picked abcd style questions, and then the scond scene picks my 5 random gap fill questions. What i'd like to to is ranomize the 2 scenes to make the question types a bit more random!!
Any ideas?! Its all a bit random!
Randomizing Array
I have array with 30 elemnts (one dimensional array).
And i want to randomize it so that this elements don't go in order like in their default state. Can someone post some script how to do it?
Randomizing Distance
hi! i'm going nuts trying to figure this out, so maybe someone else happens to know...i have a dynamic number of buttons/links that i want scattered about the page. Since the # is dynamic, i thought i would just place them at randomly generated points. so i have a function that generates a random x and a random y, then i loop through all the buttons that have already been placed in the MC, and get the x and y from each and calculate the distance between the random and the existing. If the random point is within a certain distance from any of the currently existing buttons, it reruns the function and starts the point over. So, this all works fine except that once every 10 or 15 times you run the movie, there will be two links that are reall really close - some overlapping, some just butted up against one another. so, i traced all kinds of stuff, and the function isn't actually failing, it just says that the distance is, say 120, when it really appears to not be that at all. each button is an mc, and the contents of it are centered around the crosshairs, and they're not big - just the word of the section...so unless i'm missing something I don't think it's an issue of where the x and y actually are for each button. the function runs and goes through the loops correctly and errors out when the distance isn't big enough, but every once in a while will come up with a distance that just can't be correct.
here's my function:
Code:
_global.getRandomXY = function(subsectionButton) {
randomX=random(300);
randomY=random(200);
if (randomX <= 40) {
randomX = randomX + 30;
}
if (randomY <= 15) {
randomY = randomY + 15;
}
checkDistance=0;
oldX='';
oldY='';
timeline = SubsectionMovie_mc;
for (buttons in timeline) {
if (typeof timeline[buttons] == "movieclip") {
if(timeline[buttons] != subsectionButton) {
oldX = timeline[buttons]._x;
oldY = timeline[buttons]._y;
newX = (oldX)-(randomX)
newY = (oldY)-(randomY)
distance = Math.sqrt((newX*newX)+(newY*newY))
if (distance <= 75) {
checkDistance = 1;
}
}
}
}
if (checkDistance == 0) {
subsectionButton._x = randomX;
subsectionButton._y = randomY;
}
else {
getRandomXY(subsectionButton);
}
}
subsectionButton is the current button I'm trying to place, and the random(300) and (200) is just because i want a constrained area where the links are, and the following lines (adding 40 to x, etc) are just because if it picks anything less than about 30 or so, it's too far to the left or top.
anyway, that's about it - anyone have any ideas?
thanks in advance!
Flash 3 Or 4 Randomizing Help
I need help trying to figure out how to have a random swf load stay there for 6-10 seconds then have a random swf from the same directory load. i have 7 swf's in tht directory numbered from 1-7.swf
flash 3 didnt use expressions so is there a way to make a random movie load without using expressions? and im not sure if its allowed to do variables. but if there is a way to do it on 4 and not on 3 let me have tht solutions as my last goto solution.
im not 100% sure on the player loaded on this box but i was told its 3 which limits my functionality.
please help
thanks
vic
GotoAndPlay -- Randomizing
How can I randomize gotoAndPlay, so it will either go to frame 2, 5, or 7?
I know how to make it randomly choose between 2-6, but what about specific frames that are not next to eachother?
Thanks!
Randomizing Question
Ok, im working on a flash project for school that it set up like a game show, and want to have questions randomly generated...
Here is the code that i have worked up for the questions so far
stop();
//
q1 = new Object();
q1.question = "What is 3+5?";
q1.correctAnswer = "8";
q1.answer1 = "6";
q1.answer2 = "7";
q1.answer3 = "4";
//
_level0.question.text = q1.question;
_level0.answer2.text = q1.correctAnswer;
_level0.answer1.text = q1.answer1;
_level0.answer3.text = q1.answer2;
_level0.answer4.text = q1.answer3;
//
for (var i = 1; i < 5; ++i) {
this["btn" + i].id = i;
this["btn" + i].onRelease = function() {
if (q1.correctAnswer == _level0["answer" + this.id].text) {
trace("correct");
} else {
trace("incorrect");
}
};
}
Now what will be the best way to have questions randomly generated? Also note for other questions i will use
q2 = new Object();
q2.question = "What is 10+8?";
q2.correctAnswer = "18";
q2.answer1 = "13";
q2.answer2 = "17";
q2.answer3 = "19";
etc...
Thanks!
Help With Randomizing Sounds
I want to randomize sounds on a button so that the onRelease sounds are different.
Here is my code so far:
Quote:
Punch.onPress = function() {
x = Math.random(4)
if (x = 1){
mySound1 = new Sound();
mySound1.attachSound("Action");
mySound1.start();
Punch.onRelease = function() {
mySound2 = new Sound();
mySound2.attachSound("Exc1");
mySound2.start();
};
};
if (x = 2){
Punch.onPress = function() {
mySound1 = new Sound();
mySound1.attachSound("Action");
mySound1.start();
Punch.onRelease = function() {
mySound2 = new Sound();
mySound2.attachSound("Exc2");
mySound2.start();
};
};
if (x = 3){
Punch.onPress = function() {
mySound1 = new Sound();
mySound1.attachSound("Action");
mySound1.start();
Punch.onRelease = function() {
mySound2 = new Sound();
mySound2.attachSound("Exc3");
mySound2.start();
};
};
};
};
};
However, when I do a publish preview, all it does is go do the first onRelease sound (Exc1) then the seconds onRelease sound (Exc2). Am I using the correct usage of the random function and if so, why isn't 'x' getting re-randomized?
Thanks in advance.
[edit]: Am I in the correct forum?
Randomizing Of A Number?
Okay, I must be a total idiot, because I can't even figure out how to randomize a number. Here's my code:
Code:
var loserNum:Number = random(3);
if (loserNum = 0)
{
gotoAndPlay ("Scene 18", 1);
}
if (loserNum = 1)
{
gotoAndPlay ("Scene 20", 1);
}
if (loserNum = 2)
{
gotoAndPlay ("Scene 22", 1);
}
The problem is, it keeps playing scene 20 everytime, like loserNum equals 1 everytime no matter what. What am I doing wrong?
Randomizing Variables...?
I've got a line of dynamic text that contains a number (varTotal)which is imported from a .txt file. I wish to produce a random number between 0 and the imported number and write it to a line of dynamic text (randomNumber)
Is it possible to do this using something like:
Code:
randomNumber.text = Number(random(varTotal))+1;
or is this type of function not possible...
Randomizing Madness
I have been racking my brain on this one for awhile, so any help is most appreciated.
Right now I have variables that are equal to a certain number.
var1 = 1
var2 = 2
var3 = 3
var4 = 4
var5 = 5
I want each one to be equal to a random number (in this case 1-5), but they can't have the same number. So an example would be:
var1 = 3
var2 = 1
var3 = 5
var4 = 4
var5 = 2
I have the random part down:
aRandomNumber = Math.ceil(Math.random()*5);
Randomizing An Mc (MX04)
I figured out my main problem, and would like to take a crack at my minor issue beofre asking for help. Please delete (I know we used to be able to delete ourselves, but I couldn't find it.)
Randomizing Images
I have a some script that basically takes 7 photos and rotates them in and out. I would like to change the script slightly so that instead of going in order, the file randomly chooses the photos to rotate in and out. I'm using Flash MX and the actionscript I'm using is:
pic_arr = ["allan1.jpg", "seth1.jpg", "sri2.jpg", "cindy3.jpg", "dale1.jpg", "chandra2.jpg", "ken1.jpg"];
// specify pic locations, alpha increment each frame, and
// number of frames to keep current picture displayed before
// transitioning to the next one
blank_mc.attachMovie("slideshow", "uuShow", 1, {
_x:0, _y:0, _visible:false, fps:12, nFrames:110, alphaIncr:10,
slides_arric_arr, slideDepth:50, repeat:true});
// tell blank_mc to listen for events broadcast by uuShow
blank_mc.uuShow.addListener(blank_mc);
blank_mc.onSlideLoaded = function(i) {
(new Color(this._parent["dot"+i+"_mc"])).setRGB(color_arr[i]);
//trace('slide '+ i + ' loaded');
};
blank_mc.onAllSlidesLoaded = function() {
this.uuShow._visible = true;
this.uuShow.beginTransitions();
};
blank_mc.onShowOver = function() {
//set repeat:false in uuShow for this to be called
//trace('slideshow is over');
};
Randomizing Beginning?
How do you randomize an image shown at the beginning of the Flash?
For example, the Armani Collezioni page:
http://www.armani.com/index.jsp?site...n&audio=acceso
Every time you refresh, a random image shows up in the background. Is there a specific actionscript for this?
Thank you for your help
Randomizing An Array
I'm trying to find a way to take an array of 30 numbers, randomize them and pull out the first 20.
The problem that comes up, is that if you have 30 numbers, mix them up, then count charicters, you have both single digit and double digit numbers.
At first I thought that I would just change my single digit numbers to double digit (01, 02, 03 etc) but flash didn't like that. My next thought was to count commas and go one less. I'm not sure how to do or write this. substring, looped 20 times to find the commas?
Here's what I have so far.
PHP Code:
//mix up question numbers
MixUpMyNumbers = function () {
return Math.random(2);
};
//30 question in the xml doc. They are ID numbered;
xmlQuestionNumberArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30];
xmlQuestionNumberArray.sort(MixUpMyNumbers);
trace(xmlQuestionNumberArray);
//following is not working
//I'd like it to pick out the first 20 numbers and build a new array
//substring: count in 20 commas, -1 (for the comma that will be at the end)
var myExtraction:String = new String(xmlQuestionNumberArray);
var questionNumbersExtracted:String = myExtraction.substring(0, 60);
trace(questionNumbersExtracted);
textBoxB.text = questionNumbersExtracted;
Thanks
Randomizing Varibles
how would i randomize,
on(release){
randomize
do something 1
do something 2
do something 3
}
so it would randomly do either something 1 2 or 3
Randomizing MC Coordinates?
Guys/Gals,
I'm tasked with doing a screen saver for our company. I have our logo in a mc and have tweened an alpha fade so that it fades in, waits and then slowly fades out.
What I would like to do is actionscript the mc so that it randomizes it's x and y coordinates using the available screen resolution (realestate).
I've not scripted since MX, but I'm sure that this shouldn't be too difficult of a task.
I've looked through the forums here now for a couple of hours and find lots of information about randomizing, but nothing really about randomizing coordinates discerned from the current users resolution to control mc's.
Can anyone provide any advice?
Thank you.
Randomizing Question...
This is an intence randomizing question...
I have a list of 5 words and I want flash to randomly select one.
(That's the easy part.)
Once this word has been selected and displayed, I want flash to choose another word, but this time instead of choosing one out of the 5, I want flash to choose one out of the remaining 4.
This seems possible, but I think there are some if-then statements involved...
Can anyone help?
Randomizing Functions In AS3
I'm just beginning to learn AS 3. I want to randomly choose between 2 functions and just don't know the syntax. (not sure I can even do this-- can I call another function from a function?????????) Anyone? Anyone?
Code:
package classes{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class fullrain extends Sprite {
public function fullrain() {
this.addEventListener(MouseEvent.ROLL_OVER, randomize);
//this.addEventListener(MouseEvent.ROLL_OUT, left);
}
private function randomize(Event:MouseEvent):void {
var randNum:Number = (Math.ceil(Math.random() *2));
//trace (randNum)
if (randNum==1) {this.left};
if (randNum==2) {this.right};
}
private function left(Event:MouseEvent):void {
this.x-=20;
}
private function right(Event:MouseEvent):void{
this.x+=22;
}}
}
Randomizing An Array
Hello,
I was just wondering how to go about randomly shuffling an array.. I tried googling it but only found some pretty advanced code with prototypes which I didn't even remotely understand. If anybody could help me out with an example, or a tutorial somewhere I'd really appreciate it!
Thanks in advance!
Randomizing Quiz
i want to make a quiz where you choose through sets of questions to be tested on.
each set would have about 6 questions, with about 7 sets.
what i want is to be able to use im guessing checkboxes to select what sets i want.
then randomizing the questions i selected. then after each question i would get wrong or right with a button to continue on.
im guessing ill be utilizing variables for this but have no clue where to start. all i have right now is the script for the actual questions
XML Quiz Randomizing
Hi,
I am currently developing an quiz that pulls an "item" from XML and places it into flash randomly. I have several items and I need each item to show up once without repeating. Basically to answer questions in this quiz, the user clicks on one of 5 buttons and then the next "item" pops up into the box.
Any ideas would be helpful
Here is the actionscript code I have so far:
ActionScript Code:
_global.numQuestions = 0;
_global.numCorrect = 0;
//instructions_mc.gotoAndPlay("instructions_finish");
loader.autoLoad = false;
loader.contentPath = "aifv_1.jpg";
pBar.source = loader;
// loading does not start until load() is invoked
loader.load();
itemdata = new XML();
itemdata.ignoreWhite = true;
// loads the local file indentifiers.xml into the object and parses it
itemdata.load("aifv_1.xml");
//Create a Object to store the information
//Two Dimensional Array that grabs the identifiers from the XML and places it into the variables
//category and words
function init() {
var temp = [];
var words = new Array();
var temp = itemdata.firstChild.childNodes;
_global.identifier;
for (var i = 0; i<temp.length; ++i) {
var tempList = temp[i].firstChild.childNodes;
_global.category = temp[i].attributes.category;
for (var j = 0; j<tempList.length; ++j) {
var word = tempList[j].firstChild.nodeValue;
}
}
myRandomNumber = int(Math.random()*temp.length);
myVar = temp[myRandomNumber].firstChild.childNodes;
_global.identifier = temp[myRandomNumber].attributes.category;
//trace(_global.identifier);
}
//--Checks to see if the XML has loaded
function myOnLoad() {
score = _global.numCorrect;
score2 = _global.numQuestions;
init();
}
itemdata.onLoad = myOnLoad;
stop();
~DP
Randomizing An XML Array
Hello all,
I'm having problems with the script below. Basically, it loads and parses an external XML file. I have it set to just step through the file but I'd like it to randomly display the images referenced by the XML. The script works like this, but I can't seem to figure out how to get the XMl into an array and then have the function read it correctly. It seems to me that the call:
picture.loadMovie(image[p], 1);
with p being changed somehow to a call to myArray should work, but it doesn't. What am I doing wrong?
////this creates the load XML function and counts the children to an array
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
////basic XML data stuff
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
//////////////////file loader
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function autoImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
setInterval(autoImage, 10000);
/////Array shuffle
Array.prototype.Shuffle = function() {
for (var j=this.length-1; j>0; j--) {
var pick = random(j);
var tmp = this[pick];
this[pick] = this[j];
this[j] = tmp;
}
};
///so the XML needs to loaded into the array somehow. Here's the array with a bunch of numbers instead of the XML info.
myArray=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
myArray.Shuffle();
Randomizing XML Slideshow?
Hi,
I am using this tutorial as a base template - http://www.kirupa.com/developer/mx20..._slideshow.htm
Is there a way I can integrate a Math.random function into this so it will pick the items randomly instead of in order?
Help With Randomizing List
What would be the best way to randomize a custom course list I have created entered into a list box? The data is being added using :
Code:
// Adds 7 items, with data values, to the list
listBox.addItem("ID", "<b>title of class</b><br>Description of class.<i>credits</i>");
listBox.addItem("ID1", "<b>title of class</b><br>Description of class.<i>credits</i>");
listBox.addItem("ID2", "<b>title of class</b><br>Description of class.<i>credits</i>");
listBox.addItem("ID3", "<b>title of class</b><br>Description of class.<i>credits</i>");
listBox.addItem("ID4", "<b>title of class</b><br>Description of class.<i>credits</i>");
listBox.addItem("ID5", "<b>title of class</b><br>Description of class.<i>credits</i>");
listBox.addItem("ID6", "<b>title of class</b><br>Description of class.<i>credits</i>");
Animation Randomizing On Me?
hey guys.
continuing on from an .onMotionFinshed() question I had asked earlier, I tried using that for a new idea. it is three blocks coming one from the top of the screen one after the other. i'm trying to get them to flow quickly and not have them start motioning the second the one before it completes.
The problem: the blocks should come down in sequence (1, 2, 3). Instead, they go 1, 3. Or, they go 1, 2. Or, they just go 1.
Have a look at the .SWF: here
The code:
ActionScript Code:
import mx.transitions.Tween;import mx.transitions.easing.*;top = mx.transitions.easing.Strong.easeOut;var begin = -100;var end = 20;var time = 1.0;topFinal = new mx.transitions.Tween(blue01_mc, "_y", top, begin, end, time, true); topFinal.onMotionChanged = function():Void { topFinal.broadcastMessage("onPercentageComplete", topFinal.time / topFinal.duration); } topFinal.onPercentageComplete = function(progress:Number):Void { var percent:Number = Math.round(progress * 100); if(percent == 20) { trace(percent); var middle = new mx.transitions.Tween(blue02_mc, "_y", top, begin, 107, 1.0, true); } else if(percent == 80) { trace(percent); var bottom = new mx.transitions.Tween(blue03_mc, "_y", top, begin, 167, 1.0, true); } }
thanks, guys.
EDIT: I think it has something to do with the time for when each tween starts.
[F6] Randomizing Trouble
Im making a simple match card game, the cards are fine its just the initial randomization thats the problem, i tried many different ways until i hit this one, its the closest ive gotton but it still doesnt work
Code:
Card = new Array(_root.CardBlue1, _root.CardBlue2, _root.CardRed1, _root.CardRed2, _root.CardGreen1, _root.CardGreen2, _root.CardYellow1, _root.CardYellow2);
shuffle = random(7);
_x.Card[shuffle] = 50;
_y.Card[shuffle] = 40;
trace(Card.splice(shuffle));
shuffle = random(6);
_x.Card[shuffle] = 250;
_y.Card[shuffle] = 40;
trace(Card.splice(shuffle));
shuffle = random(5);
_x.Card[shuffle] = 450;
_y.Card[shuffle] = 40;
trace(Card.splice(shuffle));
shuffle = random(4);
_x.Card[shuffle] = 650;
_y.Card[shuffle] = 40;
trace(Card.splice(shuffle));
shuffle = random(3);
_x.Card[shuffle] = 50;
_y.Card[shuffle] = 250;
trace(Card.splice(shuffle));
shuffle = random(2);
_x.Card[shuffle] = 250;
_y.Card[shuffle] = 250;
trace(Card.splice(shuffle));
shuffle = random(1);
_x.Card[shuffle] = 450;
_y.Card[shuffle] = 250;
trace(Card.splice(shuffle));
shuffle = random(0);
_x.Card[shuffle] = 650;
_y.Card[shuffle] = 250;
trace(Card.splice(shuffle));
i just keep getting outputs like these:
Code:
_level0.CardGreen2,_level0.CardYellow1,_level0.CardYellow2
_level0.CardRed1,_level0.CardRed2,_level0.CardGreen1
_level0.CardBlue1,_level0.CardBlue2
and i dont know what that means
this is my first programming attemptby the way
Randomizing An XML Array
Hello all,
I'm having problems with the script below. Basically, it loads and parses an external XML file. I have it set to just step through the file but I'd like it to randomly display the images referenced by the XML. The script works like this, but I can't seem to figure out how to get the XMl into an array and then have the function read it correctly. It seems to me that the call:
picture.loadMovie(image[p], 1);
with p being changed somehow to a call to myArray should work, but it doesn't. What am I doing wrong?
////this creates the load XML function and counts the children to an array
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
////basic XML data stuff
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
//////////////////file loader
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function autoImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
setInterval(autoImage, 10000);
/////Array shuffle
Array.prototype.Shuffle = function() {
for (var j=this.length-1; j>0; j--) {
var pick = random(j);
var tmp = this[pick];
this[pick] = this[j];
this[j] = tmp;
}
};
///so the XML needs to loaded into the array somehow. Here's the array with a bunch of numbers instead of the XML info.
myArray=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
myArray.Shuffle();
Randomizing In Flash 9
This script works perfect in flash 6 but when i export it in 9 it never stop looping the randomized letters effect and doesn't come to the correct name...
largodemo = 6;
myString = _parent.namer;
temp1 = "";
for (n=0; n<largodemo; n++) {
temp1 += chr(random(42)+48);
}
temp2 = this.myString.substr(0, i);
this.eltexto = temp2+temp1.substring(i, largodemo);
i++;
if (i<=largodemo) {
gotoAndPlay(1);
} else {
stop();
}
how can this be altered to work in flash 9 ... I am stuck any help would be greatly appreciated.
Randomizing In Flash?
I wanted to see if it was possible to load in a random swf from a lot of four swfs? So that each time i reload the home page a different image may appear? The script I am using now loads that swf into a target mc but doesnt randomize them its always the 0.swf that loads check it out. thanks!
+J
-} script {-
footers = 4;
directory = "/footer";
loadMovie (directory add Math.ceil(Math.random(0)*footer) add ".swf", "homeimage");
I am stumped I have searched every tutorial page and all they have is random number generators. This script is from flashkit.
+peace
Randomizing Load Movie
I want to randomly load a new .swf into level 1 of a flash file.
I will have all the swfs in the same area on the server....but I want to randomly load 1 of 17 different flash files off the server with each page refresh.
I know how to randomly generate movie clips within a flash file -- but how do I call up random external files?
Any suggestions would be appreciated.
Thanks
Randomizing Quiz Questions -- Help
I'm working on an interactive lesson that has 20 questions at the end. I've been asked to make these question pop up in random order. Each question is 1 frame long, how can I have flash display them in random order while making sure all 20 have been displayed? I'm developing in Flash 5 but need to back this compatible with Flash 4 since I'm not sure what the end users have installed. I was going to do this with arrays (got it working) but found out Flash 4 does not support arrays.
Any help would be much appreciated!
Thanks.
Randomizing Elements Within An Array
I have an array setup as follows :
myArray=new Array("1","2","3","4","5","6","7","8","9","10","11 ","12","13","14","15");
I'm looking for a way to completely randomize the elements within the array so the order is never the same twice, any insight ?
Thanks !
Randomizing And Checking Input. HELP
I am going to make a memory game in which players have to memorise the arrows (up, down, left, right) coming out one by one and then input the answer in the correct order. I am a beginner in writing flash game and using action script. Here are my problems:
1. How to randomise the arrows and let them coming out from the left to the right (same y position) with a certain speed?
2. How to check the player's input with the randomised arrows?
Thank you very much.
|