Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-18-2012, 06:29 AM   #1
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default create new arrays inside loop

Is there any way to create new array instances inside loops, that would be responsive for commands / functions?

ActionScript Code:
for(var i:int = 1; i <= 2; i ++) {     var subMenuBASE:Array = this["subMenu" + i] as Array;     this[subMenuBASE] = new Array();     this.subMenu[i] = "hello";     this.subMenu[i].push("world"); } trace(this.subMenu1); trace(this.subMenu2);

This way i get an error
Quote:
TypeError: Error #1010: A term is undefined and has no properties. at Untitled_fla::MainTimeline/frame1()
Any ideas?
Please, i'm stuck for days on this, have no luck with google / as3 manual either...
failure666 is offline   Reply With Quote
Old 07-18-2012, 11:28 AM   #2
-:)lauri
Senior Member
 
Join Date: Aug 2008
Location: Helsinki, Finland
Posts: 1,184
Default

var subMenuBASE:Array = new Array();

for(var i:int = 1; i <= 2; i ++) {
subMenuBASE[i] = new Array();
subMenuBASE[i].push("hello");
subMenuBASE[i].push("world");
}

//will create 2d array:

[[,],
["hello", "world"],
["hello", "world"]]
-:)lauri is offline   Reply With Quote
Old 07-18-2012, 11:55 AM   #3
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default

I need to create new array named "subMenu" + i, inside this loop.
failure666 is offline   Reply With Quote
Old 07-18-2012, 11:59 AM   #4
-:)lauri
Senior Member
 
Join Date: Aug 2008
Location: Helsinki, Finland
Posts: 1,184
Default

ActionScript Code:
this["subMenu" + i] = new Array();
-:)lauri is offline   Reply With Quote
Old 07-18-2012, 12:15 PM   #5
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default

-lauri
FINALLY IT WORKS!!!!!!!!!
thx GOD!
ActionScript Code:
for(var i:int = 1; i <= 2; i ++) {     this["subMenu" + i] = new Array();     this["subMenu" + i].push(0,1,2,3,4,5,6,7,8,9); } trace(this.subMenu1); trace(this.subMenu2);

I just haven't know the right syntax!
Thank you SO MUCH!!!!!!
failure666 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:50 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.