PDA

View Full Version : Importing Array Values into a Dynamic Textbox within a MC


Andy_Fran
12-04-2003, 09:10 PM
Hi everyone,

I have a bit of a prob but i dont know if im just messing up my addressing.

I have followed one of the scoll button tutorials to create a dynamic text box with a scroller up and down. This works great with any text that i input to it.

However, i need to insert values from an array into it in a list form. I have done so using this code which is attached to the movie clip:

onClipEvent (load){
for (i=0; i<44; i++){

fulllisting = _root.slangArray[i] + " translates to " + _root.engArray[i] + <BR>;

}
}


This only produces the last entry in the array so im assuming that it is ignoring the break and just overwriting the previous one. I have tried putting the break in quotes like Javascript but no joy.

Any ideas?

Andy

CyanBlue
12-05-2003, 03:15 AM
Howdy and Welcome... ;)

I am not sure if I get you right or not, but if what you are trying to do is to append the data into the textfield, try this then...fulllisting += _root.slangArray[i] + " translates to " + _root.engArray[i] + <BR>;

Andy_Fran
12-05-2003, 09:59 AM
Thanks a lot, that really helped me..

I have one more question though.

I am using the Math.random() to create a random number between 1 and 44 and assigning it to a variable. I then want to round it to the nearest whole number. Ive tried using Math.round but it dosent seem to like it when i use a variable instead of a number. What can I do ??

Code:

var i = Math.random()*44+1;
Math.round(i)

randomquote = slangArray[i]
trace (i)


thanks,

Andy

CyanBlue
12-05-2003, 10:09 AM
Howdy... ;)

I'll answer your question, but please do some searching before you post the question... I think this question has been answered 'literally' hundread times and I am sure I've answered at least 1/10 of it... Also, it would be a good idea to create a new thread if the question does not go with the original question... That helps other people when they do searching... ;)

Try this code and see what is the highest and lowest number you get... ;)for (i = 1 ; i < 1000 ; i++)
{
x = Math.round(Math.ceil(Math.random() * 44));
trace(x);
}

Andy_Fran
12-05-2003, 10:48 PM
Thanks once again for replying to my post.

I admit that i didnt adequately search for the answer to that question. I was a little flustered at the time and will be sure to search for any other queries before i post in the future.

Apologies.

Andy

CyanBlue
12-06-2003, 10:51 AM
Hey, come on... I wasn't yelling at you... :)
I knew that you were new, so I was just giving you a friendly advice... That's all... No apologie required... :)

Andy_Fran
12-06-2003, 06:57 PM
Hey man,

No worries, i know what its like when ppl dont search for stuff before asking thats all. Didnt wanna be tarnished with that brush!

Thanks again!

CyanBlue
12-06-2003, 07:12 PM
Thank YOU... ;)