Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Dinamičko kreiranje varijabli?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Flash
View previous topic :: View next topic  
Author Message
Danko



Joined: 16 Sep 2004
Posts: 124
Location: Zagreb

PostPosted: 19.09.2005 14:52    Post subject: Dinamičko kreiranje varijabli? Add user to your forum ignore list Reply with quote

Da li netko zna da li i kako se može ovo raditi u Flashu:

Zavrtit petlju od 1 do 100 i u njoj dinamički generirat niz varijabli i njihovih vrijednosti, ovako:

var1 = 1;
var2 = 2;
var3 = 3;
...

Naime, problem je što ne prolazi:

Code:
eval("_root."+myKey) = myValue;

.. jer lijeva strana jednakosti mora biti property.
Ovo prolazi, ali ne radi kako treba:

Code:
_root[myKey] = myValue;


Ono što sam uspio napraviti je strpati vrijednosti u polje, tipa:

Code:
element[myVar] = myValue;


Međutim polje mi je nepraktično, htio bih varijable u _root-u.

_________________
dankokozar.com | Adjungo | UnityHR | eDriven
Back to top
View user's profile Send private message Visit poster's website
Danko



Joined: 16 Sep 2004
Posts: 124
Location: Zagreb

PostPosted: 19.09.2005 15:16    Post subject: Add user to your forum ignore list Reply with quote

Riješeno.

Ovo zapravo radi (greška mi je bila negdje drugdje u kodu):

Code:
// setting
for (i=1; i<=100; i++) {
   var myKey:String = "var"+i;
   var myValue:String = i;
   _root[myKey] = myValue;
}
// reading
for (i=1; i<=100; i++) {
   trace("var"+i);
}

_________________
dankokozar.com | Adjungo | UnityHR | eDriven
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Flash All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group