ActionScript 2.0 :: Putting Data Into An Array Via XML And Then Selecting At Random An Image String To Load In A Pic At Random
Feb 11, 2009
I've been putting data into an array via XML, and then selecting at random an image string to load in a pic at random. But whilst doing this, I wanted to remove the String from the Array that I have just used, so I don't get repetition of the same image in the output. I initially thought that pop would remove the string I had just used - But of course it Removes the last value in the Array instead, which doesn't really help.
Ok - so how about randomizing the data once inside the Array, after it has been pulled in from XML!? That way I can load in the 'last' image, and then pop it out! Keeping a randomized selection of images each time 'it' is loaded
I want a movieclip consisting of a dynamic text box that, from the time it's loaded onto the stage, loads a randomly selected text string from an array, and continues to loop until the clip is removed from the stage. I also want the text strings to appear in the text box for random intervals between 500 and 3000 milliseconds.
While I've found tutorials here and elsewhere on loading one element from an array, usually triggered by a button, I don't know how to combine/alter it with the other elements.So I want this movieclip on the stage randomly flashing phrases from an array, some for a barely perceptible time, and others for a readable time.
I know this should be easy, but I can't seem to make it work. All I want is for the variable currentPage to select randomly from an array so that every time the page loads, it displays a different currentPage. This is what I have so far:
var myImages:Array = new Array("outsource_mc","solutions_mc","staff_mc"); var randomImages:Array = []; var randomCount:Number = 1; var r:Number; for (var i = 0; i<randomCount; i++) {
I have this to load a random image from my array. But how can I keep track so that a new random pic wont be the same as one allready shown, until all pics in the array has been shown once?
im playing with the load random movie (but loading a random xml file instead) based on the wonderful tutorial from front page and was wondering whether anyone can show me the work around/upgrade to AS2 for this bit of script since im publishing to Flash 8 /AS2 and it doesnt work:
So what I have here is a button that will take away a random number from a variable (in this case being money) this is nothing more than a learning experience and I just wish to broaden my horizons on flash AS.
Actionscript Code: on (release) { money -= random(200); }on (release) {gotoAndPlay (2);} While this code works just fine the only problem i have with it is that it will select a number from (0-200). Is there a way I can set this up to select a random number BETWEEN 2 numbers? EX: (150-200)
I have an app I'm creating with Flash CS5.5 with 42 different short stories in it. It has 2 scenes. Scene 1 is the opening and contents menu to access the stories. Scene 2 contains the 42 stories.In scene one, I have a button that I want to be able to pick a random story so it would need to pick a random frame between 1 and 42 in scene 2. I have seen some code in here that will pick a random frame when you open the program, but I don't know how to tie it to a button or pick a random frame in another scene.
I am loading 8 images into 8 movie clips using a random number generator. it is working but it loads in the same images in places. I need the 8 images to be different. They are being loaded from a mySQL database using php. Does anyone have any tips?
I'm using this actionscript code.
var mcLoader2:MovieClipLoader = new MovieClipLoader(); //set up a Listener var mclistener2:Object = new Object(); //associate the Listener with the MCL
i have a collection of movie clips (mc0, mc1, mc2...etc etc),and when motion is detected on a webcam, one of these clips is shown on the stage. however, for some reason only mc0, mc1 and mc2 are being displayed, and i cannot get mc3, mc4 or any more to be chosen.
Code:import flash.filters.*// Assumes a Video object named "myVideoObject" is on the Stageactive_cam = Camera.get();filterList = [ /* 0 */ "multiply", /* 1 */ "multiply", /* 2 */ "multiply", /* 3 */ "multiply", /* 4 */ "multiply" ];positionList = [ /* 0 */ {_x: 512, _y:
I have 15 empty placeholder on my stage, named "empty01" - "empty15". I have 15 mcs in my library, with linkage identifiers "01" - "15".
[CODE]...
I would prefer for 'empty01' to load a random mc. Can anyone advise how I could achieve this? I have tried to create an array containing the 15 library mcs (not sure if this is correct):
I can't get my head around arrays.Ok so basic I know it can be displayed as blah then you can retrive with trace(blah[X]); or in a text box.I can't be bothered with the var blah:Array = []ect.. I want to stay simple.I want to load a random vaule from an array but I want to keep the code simple so I can come back to it and instantly understand and make changes.
I'm trying to use an array adapted from AS2 script to load random swfs called "koan_1.swf" or "koan_2.swf" etc into a "koan_loader_mc" on the stage. Each "koan_#.swf" has code in its last frame to both advance the "shuffle" array in the action script in the first frame of the stage and to load the next koan swf. The code below -- almost -- works, but....?
Frame on main stage:
// creates function called at the end of koan_#.swfs function shuffle(a:Array) { for (var ivar = a.length-1; ivar>=0; ivar--) {
I don't think I'm as familiar with arrays as I need to be to complete the following project - I've read about 60 posts and no one seems to be doing exactly what I am. Here's what I need to do: From a main swf (home.swf), I need to load 7 consecutive swfs in random order, (movie01.swf, movie02.swf, etc) from an array, into level 1. I need all seven to play without repeating, then repeat them in the same order in a loop.
But I ALSO need the user to be able to navigate through the swfs by using next or previous buttons (or by selecting individually 1-7, but that may be asking too much from my limited knowledge).Here is the code I'm using to generate a random ordered array:
I have 4 groups of movieclips all with different names.
Example:
Group1 contains dog_mc, cat_mc and bird_mc Group2 contains shoe_mc, hat_mc and pants_mc etc...
What I am trying to do is load a random group initially (either 1-4), then I want to play that group of movieclips. Once that group is completed playing all its movieclips, I want to move on to the next group and play all those movieclips. When all groups and movieclips have completed, I want to loop back to the start.
I'm looking to help a friend with his site and basically, I need a good tutorial on how I could create a character with a voice bubble that, when you click on a button, displays a random quote. Also, I know this might not be the right forum to ask this in, but would this be easier to do in Dreamweaver if I just place the item of the character and have it load up a random voice bubble image? If so, are there any good tutorials for that?
Based on the kirupa xml gallery I am loading a random image opposed to starting with the first image in the xml file. It works fine, but I have not been able to figure out how to get the accompanying caption to load with the specific image.
Code: function loadImage() { if (loaded == filesize) {
[code]...
I know it has to do with this: "description[0];" I'm just not sure what to change the '0' too....?
I used the fade class to build a fade in-out image gallery. It s quite easy and it works fine. But then they asked me to load the images randomly and thats when the thing got complicated.[code]...
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..
A background music looping in the back, that starts with the opening of the swf and never stops. I think I achieved that with this bit of code :import flash.media.Sound;
Finally I need to jump from frame to frame randomly to play various animations. For example :Project starts, background music starts playing, we hear random sounds played one after the other, while some animations can be seen on screen, playing in a random order.
I have a picture on the stage covered by 12 squares (sq1, sq2, sq3.......sq12) When the movie opens I want the squares to move down, but i want a random sequence ( 3, 9, 2, 12...........8). I already made de function for the movement: