473,320 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Random arrays

Hi I have an assignment to create a random array to store pictures. Each time that you click on one of the buttons in the header a new picture will appear. I know how to set up an array, and i also know how to setup up a random array. From what i understand an array is for data, so how do i store a picture in it. I don't know if this is making any sense, but my instructor isn't helping much either. Just a push in the right direction could help out a bunch. thanks
Apr 8 '08 #1
4 3153
nomad
664 Expert 512MB
Hi I have an assignment to create a random array to store pictures. Each time that you click on one of the buttons in the header a new picture will appear. I know how to set up an array, and i also know how to setup up a random array. From what i understand an array is for data, so how do i store a picture in it. I don't know if this is making any sense, but my instructor isn't helping much either. Just a push in the right direction could help out a bunch. thanks
what version of actionscript are you using?
nomad
Apr 10 '08 #2
what version of actionscript are you using?
nomad

I am using actionscript 2.0 for now. My nex set of classes i will be using as3
Apr 10 '08 #3
Cainnech
132 100+
I have a similar problem.

I want to load movies randomly. I made the script, but it doesn't seem to work.

This is what I have:

Expand|Select|Wrap|Line Numbers
  1. moviename = ["imovie1", "imovie2", "imovie3", "imovie4"]; 
  2.  
  3. function randomise() {
  4. _root.ilogo.play();
  5. i = moviename.length; 
  6. k = Math.floor(Math.random()*i); 
  7. moviename[k].play();
  8. trace(moviename[k]);
  9. }
  10.  
A short explanation. All my movies are external FLV but I recall them in different movies on my main timeline. So for every FLV I have a separate movie. (the reason why I do so is because I added different cue points to the different FLV's, but that's not of any importance in this thread).

So I made an array with the instances of the different movies.
Then I randomly pick a number.

By using moviename[k] I'm displaying value k out of array moviename.

However it doesn't seem to work.

I put the trace in to check if he is actually getting the value out of the array and that is the case. So I can see him randomly picking a number but when I try to play it, he won't do it.

So the problem lies in the line: moviename[k].play();

However when I put an instance name in place of moviename[k] it does play it. Probably I'm forgetting something but I don't know what. If someone can help me, please do!

I'm using AS 2.0
May 3 '08 #4
axis
12
hollywoood69:
Don't store pictures in the array, just store a reference to pictures. e.g
var pics:Array = ["pic1.jpg", "pic2.jpg", ...];
//btn is the btn you click on
btn.onPress = function()
{
//mc is the movieclip that holds your pictures
mc.loadMovie(pics[Math.random() * pics.length]);
}
_______
Cainnech:
remove inverted commas, i.e:
moviename = [imovie1, imovie2, imovie3, imovie4];
May 20 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Virus | last post by:
Ok well what I am trying to do is have 1.) the background color to change randomly with 5 different colors.(change on page load) 2,) 10 different quotes randomly fadeing in and out in random...
4
by: Jack | last post by:
I have two files: sort_comparison.c++ my_sort.h sort_comparison.c++ calls this code in my_sort.h: void my_sort::fillArray(int arr,int n) { // const int random_number_range=1000000;
16
by: Leon | last post by:
I need a program that generate 5 non-duplicates random number between 1-10 as string values store in an array. Do anybody know of any good books or websites that explain how to generator random...
13
by: Roy Gourgi | last post by:
Hi, How do I invoke the random number generator that was suggested by a few people. Ideally, what I would like to do is to instantiate the random no. generator with a seed value that does not...
38
by: One Handed Man \( OHM - Terry Burns \) | last post by:
I have a basic question thats been niggling me, but I never found time to look at it before. If I have an enumeration such as this Fiend Enum TravelDirection North South East
12
by: Pascal | last post by:
hello and soory for my english here is the query :"how to split a string in a random way" I try my first shot in vb 2005 express and would like to split a number in several pieces in a random way...
14
by: avanti | last post by:
Hi, I need to generate random alphanumeric password strings for the users in my application using Javascript. Are there any links that will have pointers on the same? Thanks, Avanti
8
by: Aspidus | last post by:
Hi, I wrote a function that generates a ulong I use it 3 times, one after the other, but it generates always the same numbers. At the end i get always 3 equal arrays. Any idea?
10
by: Sheza7 | last post by:
Hi, I am a beginner in JAVA language... I am making a simple sudoku game (in notepad -I have to use only notepad). I have my sudoku tables stored in 2d arrays e.g sudoku1. Lets say I have 5...
11
TTCEric
by: TTCEric | last post by:
This will be original. I promise. I cannot get the random number generator to work. I tried seeding with Date.Now.Milliseconds, it still results in the same values. What I have are arrays...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.