Groups | Blog | Home
all groups > flash actionscript > september 2004 >

flash actionscript : Programming Opinion


samuelfuller
9/26/2004 10:14:56 PM
I have a series of images that are being dynamically loaded. I am using an
array to specify the path of each individual image. I want to make my program
cycle through the individual items of the array and load each image randomly
until every image is loaded. While this is going on, I am using a conditional
to detect if certain keyboard presses are invoked. The keyboard presses are
specific to each array item.
What are your opinions on how I should handle this keyboard event listener?

How should I go about coding the array of images to be in sync with each
specific keyboard press, and be able to detect when each image has been loaded?

Please include sample actionscript you would use.

Thanks,
Sam
ashish912
9/27/2004 9:25:57 AM
Not clear.
Wether you want to load images randomly or on key press.
samuelfuller
9/27/2004 5:19:22 PM
The images that will be loaded are a set list. However, I would like them to
be random when the movie loads them so it is always a different sequence when
the program runs. My biggest concern is how I will be able to sync the
keypress events with specific images.

Thanks,
Sam
VisionaryStudios
9/27/2004 5:30:58 PM
If I understand you correctly each image will have a different letter assigned
to it. So, if you want to load the proper letter with the proper image make it
a multidimensional array

imageArray[ [#letter,#image], [#letter,#image] , [#letter,#image] ]

imageArray[0][0] <-- would give you the letter of the first image
imageArray[0][1] <-- would give you the image of the first image
imageArray[1][0] <-- would give you the letter of the second image
imageArray[1][1] <-- would give you the image of the second image

and so on...
ashish912
9/28/2004 6:15:10 AM
I hope you can arrange them randomly by using array and random(array.length)
and array.splice option.
You could capture keycode Like (A-Z are 65-90)
So you can select an image from array using Key.getCode())-65.
samuelfuller
9/29/2004 2:50:08 AM
Thank you for your replies! And also thank you for giving me new ideas for the
software I am in the process of creating!
I looked into your suggestions, and have come to the conclusion that I will be
creating objects with simple strings relating to the images, and keyboard
commands. These will then be put into an array. I will then be able to
randomly cycle through the array, and directly reference the different object
variables from within a loop statement. I am in my initial phase of
development right now. I was curious as to the splice command you mentioned
array.splice. Could you elaborate on how this could be useful?

If you two users send me your email address directly, I will send you free
versions of my software after it is released.

Thank you,
Sam
VisionaryStudios
9/29/2004 3:07:49 AM
What is your email that I can send mine to?

You could, if you did not already figure it out yet, call a random element in the array by doing:

myArray[random(myArray.lenght)]

ashish912
9/29/2004 5:43:33 AM
Array .splice is used to cut the entry from array. It's used generally to
delete the entry once used so that it doesn't get repeated. I mean if you have
an Array [a,b,c,d,e] if you select an item randomly, it may pick an item again.
like first time it picks "a" second time "c" third time "a.


ashish912@yahoo.com

samuelfuller
9/29/2004 3:31:03 PM
My email is samuelspitnale@hotmail.com

I really appreciate the help you have provided and would like to reward you
with free versions of my software. It is training software related to adobe,
macromedia, and microsoft office. Once It is completed and I have my site up
and running I will give you free downloads of each.

I am so greatful that you have shown me the splice command because it will
help with my random array situation.

Thank you both!
AddThis Social Bookmark Button