Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 658801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:58:25+00:00 2026-05-13T22:58:25+00:00

How do I load library objects by string list using Flash and AS3? I

  • 0

How do I load library objects by string list using Flash and AS3?
I need to understand string lists, arrays, and sprites better.

WHAT I WANT TO DO
Load enemies to stage using a string list “Orange ball, red ball, green ball etc”

EXPLANATION
The tutorials I’ve been given are too basic, or they are incomplete
examples that don’t explain the classes being used.

Trace statements are not showing me how I’m accessing the name or class of an object.
I need examples. Non-packaged classes preferred. Thanks.

WHAT I GOT WORKING “I knew I’d mix up the class and name”
SYMBOL PROPERTIES
name is they’re not name specific, I call mine noname”
class is Pyramid

//Creates 10 enemies and trace statement
import flash.display.Sprite;
var sprites:Array = new Array();
for(var i:Number=0;i<10;i++){
    //var test:Sprite = new Sprite();
    var test:Pyramid = new Pyramid();
        sprites.push(test);
    addChild(test);
    test.name = "littlebox_"+ i
    trace(test.name)
    with(test){

        x=i*25;

       }
}

/////////////////////////////////////////////////////////////////////// 

/*debu's example*/
//Creates 10 enemies 
var enemyArray:Array = new Array(); 

for (var i:int = 0; i < 10; i++) 
{ 
   var noname:Pyramid = new Pyramid(); 
   noname.x = i*10; //this will just assign some different x and y value depending on i. 
   noname.y = i*11; 
   enemyArray.push(noname); //put the enemy into the array 
   addChild(noname); //puts it on the stage 
}

///////////////////////////////////////////////////////////////////////

//centered and trace statement
var sprite:Sprite;
var noname:Pyramid = new Pyramid; 
//var noname:Pyramid2 = new Pyramid2; 
sprite = new Sprite();
sprite.name = "Pyramid" + 1;
addChild( noname);
noname.x = stage.stageWidth/3;
noname.y = stage.stageHeight/3;
trace( getChildByName( "Pyramid" + 1 ) ); // [object Sprite]

alt text http://www.ashcraftband.com/myspace/videodnd/so___.jpg

PREVIOUS MODIFIED

var enemyList:Object = new Object();
        //var enemy:Sprite = new Sprite();
var enemy:BadGuy = new BadGuy();
enemy.name = "BadGuy";
enemyList [enemy.name] = enemy;

//var enemyList:Object = new Object();  
//for (var i:int = 0; i < 10; i++) {
        //var enemy:Sprite = new Sprite(); 
//var enemy:BadGuy = new BadGuy(); 
//enemy.name = "BadGuy" + i;  
//enemyList [enemy.name] = enemy;  
//}  

//for (var i:String in enemyList){  
//var enemy:Sprite = enemyList[i]  
//do something to enemy sprite  
//}

PLEASE POST MORE ARRAY STUFF

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:58:25+00:00Added an answer on May 13, 2026 at 10:58 pm

    What I’d do in that situation is just use an ordinary Array. Declare it like this:

    var enemyArray:Array = new Array();
    

    Then it’s ready to accept objects. Then create a for loop, much like you’ve done, to add as many enemies as you want to the Array and give them some positional info, and also to add them to the Stage:

    //Creates 10 enemies
    for (var i:int = 0; i < 10; i++)
    {
       var enemy:Sprite = new Sprite();
       enemy.x = i*10; //this will just assign some different x and y value depending on i.
       enemy.y = i*11;
       enemyArray.push(enemy); //put the enemy into the array
       addChild(enemy); //puts it on the stage
    }
    

    This will put 10 enemy objects (which you will need to define, I assume you know how to link a new class to an object in the Flash IDE’s library?) on the stage. From here you have the array populated with those enemies, and you can cycle through it to move them around, do collision detection on them, kill them off and remove them from the stage, etc.

    The way you did it seems to put them into an Object according to their names, which is equally do-able I guess. I can’t see why you would necessarily need to access them by name, in which case the Array way simplifies it somewhat.

    Note also that this isn’t loading enemies to stage using a string list, as that isn’t really necessary – unless you were first putting the file locations of a bunch of images on your HD (to use as game sprites) in an array as Strings; then subsequently for-looping through that to load them to stage.

    I hope this helps, let me know if you have any further questions, or if this isn’t the answer you were looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 376k
  • Answers 376k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I haven't used it, but there's a sourceforge project Vector… May 14, 2026 at 8:35 pm
  • Editorial Team
    Editorial Team added an answer You can't directly archive a UIImage - UIImage doesn't implement… May 14, 2026 at 8:35 pm
  • Editorial Team
    Editorial Team added an answer http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/i18n/jquery-ui-i18n.min.js EDIT: It work's only google.load is omitted and standard… May 14, 2026 at 8:35 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.