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 8930543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:54:56+00:00 2026-06-15T08:54:56+00:00

I have my code setup so that I have a movieclip in my library

  • 0

I have my code setup so that I have a movieclip in my library with a class called “block” being duplicated multiple times and added into an array like this:

function makeblock(e:Event){
newblock=new block;
newblock.x=10;
newblock.y=10;
addChild(newblock);
myarray[counter] = newblock; //adds a newblock object into array
counter += 1;
}

Then I have a loop with a currently primitive way of handling my problem:

    stage.addEventListener(Event.ENTER_FRAME, gameloop);
    function gameloop(evt:Event):void {
        if (moveright==true){
            myarray[0].x += 5;
            myarray[1].x += 5;
            myarray[2].x += 5
              -(and so on)-

My question is how can I change x,y values every frame for new objects duplicated into the array, along with the previous ones that were added. Of course with a more elegant way than writing it out myself… array[0].x += 5, array[1], array[2], array[3] etc.

Ideally I would like this to go up to 500 or more array objects for one array so obviously I don’t want to be writing it out individually haha, I also need it to be consistent with performance so using a for loop or something to loop through the whole array and move each x += 5 wouldn’t work would it? Anyway, if anyone has any ideas that’d be great!

  • 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-06-15T08:54:56+00:00Added an answer on June 15, 2026 at 8:54 am

    If you have to move 100 objects, you have to move them. No alternatives.

    But what you can really do to save performance, is optimize the solution itself. A few cents from me:

    • Of course the loop has to be applied in your case, managing 100+ assignments line by line is definitely not the right way to go. Although you gain nothing performance wise with just using a loop.

    • Try grouping the objects. As I see above, you seem to be moving all those objects with similar increment. Group them all into larger movieclips (or Sprites) & move that instead.

    • Learn Blitting & caching methods to save a lot on performance, Or you would sooner or later hit on the road where your logic cannot be twisted anymore & performance will be a pain.

    • Also, in extent of the previous step, do consider using Sprite Sheets if you have multiple states of the same object.

    Finally, I would also like to caution you to not waste time on micro optimizations & thinking about them.

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

Sidebar

Related Questions

I have some setup code in my functions.php file that sets permalinks and adds
I am trying to setup a few fixes in some code that have caught
We have a setup where most code, before being promoted to full production, is
For example sake, I'll use some dummy code. I have some jQuery setup that
I have a setup that looks like this. class Checker { // member data
I have several methods that execute the same setup code and then some cleanup
I have a pause screen that is being added when you click the pause
I have code that in the connection setup selects the database using mysql_select_db(). $link
Using timeit , I have a setup code block which sets up a data
I have a piece of code that setup a ListModel based on content of

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.