Flash AS3 for loop query

Posted by jimbo on Stack Overflow See other posts from Stack Overflow or by jimbo
Published on 2010-01-21T16:31:12Z Indexed on 2010/04/23 21:43 UTC
Read the original article Hit count: 208

Filed under:
|
|

I was hoping for a way that I could save on code by creating a loop for a few lines of code. Let me explain a little, with-out loop:

icon1.button.iconLoad.load(new URLRequest("icons/icon1.jpg"));
icon2.button.iconLoad.load(new URLRequest("icons/icon2.jpg"));
icon3.button.iconLoad.load(new URLRequest("icons/icon3.jpg"));
icon4.button.iconLoad.load(new URLRequest("icons/icon4.jpg"));

etc... But with a loop could I have something like:

for (var i:uint = 0; i < 4; i++) {  
    icon+i+.button.iconLoad.load(new URLRequest("icons/icon"+i+"jpg"));
}

Any ideas welcome...

© Stack Overflow or respective owner

Related posts about flash

Related posts about as3