473,767 Members | 8,025 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Random arrays

2 New Member
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 3176
nomad
664 Recognized Expert Contributor
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
hollywoood69
2 New Member
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 New Member
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 New Member
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(pi cs[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
2505
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 spots on the webpage. with a delay timer on them, so they keep changing as the page is open. Not random each time the page is loaded. If anyone can help it would be greatly appreaciated, I have tried many of
4
2699
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
12079
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 numbers using asp.net? I know about the random namespace within .net, but I need a reference to some code that do the similar stated function above. Plus If you have any coding practice ideas for the above defined project please share them.
13
3620
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 repeat the values and that can be called from any class, as I have to call the random number generator from a few different classes. Here is my code: using System;
38
2321
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
3229
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 without success. for example if the number is 123 456 : i would like to have some random strings like theese : (12 * 10 000) + (345 * 10) + (6*1) or (123*1 000)+(4*100)+(5*10)+(6*1) etc...
14
4752
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
5693
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
2014
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 2d-arrays, sudoku1....sudoku5, and I want a random one to be chosen... how do I do that. I know I have to use class Random, but how do I make it in this case (i.e 2d arrays)?? also this is how u put values in a 2d array... int example2d= {
11
3023
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 of values. I get a random index value for each array so I can pull the data from them.
0
9575
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10014
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9960
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7384
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6656
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5280
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3931
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.