Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-13-2012, 09:15 PM   #11
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default

Well this creates one array, with string name, but i need dynamic names...

Hell, i'll try to express in code, here it is:
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(subMenu1); trace(subMenu2);
I want this loop code to create actual arrays named subMenu1 and subMenu2, but when i trace them - i get an error, coz it doesn't seem to actually create them

I'm pretty mcuh sure that there should be one or two words of code that would change the situation, but i don't know them!(

Last edited by failure666; 07-13-2012 at 09:18 PM.
failure666 is offline   Reply With Quote
Old 07-13-2012, 09:47 PM   #12
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 1,898
Default

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);

Your dynamic menu names are accessible as properties of this.
You are more or less using the Object class to create these dynamic properties.
This is certainly not a "best practice" for complex systems, or an efficient coding strategy for reasons you're gradually discovering.
[afz]snickelfitz is offline   Reply With Quote
Old 07-14-2012, 05:55 AM   #13
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default

[afz]snickelfitz
But this doesn't work at all...
Got this error, and no trace:
Quote:
TypeError: Error #1010: A term is undefined and has no properties. at Untitled_fla::MainTimeline/frame1()
Quote:
This is certainly not a "best practice" for complex systems, or an efficient coding strategy for reasons you're gradually discovering.
Why not, if it's done once?
I mean, complex systems usually have much more problematic places, like adding animations for each element, or multiple addChilds, which is much more hard to deal with, ain't it?
It's simply definition code..

Last edited by failure666; 07-14-2012 at 06:10 AM.
failure666 is offline   Reply With Quote
Old 07-15-2012, 04:32 PM   #14
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default

Still open question...h e l p !
failure666 is offline   Reply With Quote
Old 07-16-2012, 07:59 AM   #15
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default

Sorry to repeast myself, but i can't move on with my idea without that knowledge.
Code below doesn't work, i need something that would work and would create responsive to the actions array...
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 07:13 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, 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.