Skip navigation
Leo8o8
Currently Being Moderated

Importing movieclips from library with arrayable instance names how???

Jun 6, 2012 6:59 AM

Tags: #help #flash #frame #actionscript #actionscript_2 #game #clip #2.0 #movie_clip #dinamyc

The title says everything...

 

Here is the example:

 

 

centerx = 275;
centery = 200;
plussx = 26;
plussy = 15;
layern = 1;
terrainn = 1;
placer = 0;
 
GRASS = new Array();
 
while (layern != 2){
    _root.attachMovie("terrainG", "GRASS[terrainn]", layern); //<<<<< How can I do something like that?
    GRASS[terrainn]._x = centerx+plussx*placer;
    GRASS[terrainn]._y = centery+plussy*placer;
    terrainn++;
    layern++;
    placer++;
}
 
Replies
  • Currently Being Moderated
    Jun 7, 2012 4:59 AM   in reply to Leo8o8

    You probably want to use something like...

     

    GRASS[placer] = _root.attachMovie("terrainG", "terrainn"+placer, layern);

     

    using the placer variable instead of the terrainn, since arrays start at index 0 instead of 1.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 7, 2012 8:45 AM   in reply to Leo8o8

    AS2 does not have an integer class, so if you want to convert a string to a number you can use the Number(string) approach so long as the characters are numeric.  Using parseInt can work but only when the numeric characters are in the front of the string.  If you have some other mix of alphanumeric characters, then you would need to go thru the string and revise it to only have the numeric elements.  For this you could loop thru the string and test each character in it to see if it is a number... if not, do not include it in the string destined to be the numeric result.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 7, 2012 9:54 AM   in reply to Leo8o8

    You could make use of the isNaN() function as one option.  While looping you would use something like...

     

         ... if(!isNaN(currentCharacter)) {

                  // include it because it is numeric

             }

     

    You could also have a string with the numeric characters in it ( as in "0123456789") and use the indexOf method of the String class to check for the numeric characters.  While looping you would use something like...

     

     

         ... if(numericString.indexOf(currentCharacter) > -1) {

                  // include it because it is numeric

             }

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 7, 2012 11:58 AM   in reply to Leo8o8

    use the String.charAt(index) method to pick each character one at a time.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points