FORUMS: list search recent posts

Add a predefined variable to an array

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Lucas Kersken
Add a predefined variable to an array
on Jun 22, 2011 at 9:40:48 pm

What i am basicly trying to do is to change the colour of letters in a text after a certain time and i want to add the instant name of those letters to an array. I just don't know how to tell the array that the 1 and the 2 are variables.

var alphabet = new Array();
alphabet[0] = 1; \\this is an isntand name for a dynamic text
alphabet[1] = 2; \\same here

len=alphabet.length

for (var i = 1; i<=len; i++)
{
alphabet[i].textColor = 0x634634;
}


Return to posts index

Brodd Nesset
Re: Add a predefined variable to an array
on Jun 23, 2011 at 1:02:12 pm

Hi!
Instance names can't start with numbers. You should receive an error when attempting to do this. Use instance names like tf1, tf2 etc. By this 'limitation', the contents in an Array will self-sort into three possible main categories:

1 = a number of some sort

tf1 = an object of some sort, including display objects like MovieClips and TextFields

"1" = an alphanumeric string, including symbols for numbers like "1", which is not the same as the value of 1 in mathematical terms.

Do not call any instance true or false; these are reserved for Boolean operations - even if you don't get a warning.

Required there are two textfields on Stage with the instance names tf1 and tf2, I found this to work:

var tfArray:Array = [tf1, tf2];

for (var i:int = 0; i < tfArray.length; i++) {
tfArray[i].textColor = 0x00FF00;
}




Not everything that can be counted counts, and not everything that counts can be counted.



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]