Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-10-2008, 08:16 PM   PM User | #1
ricmetal
New Coder

 
Join Date: Nov 2008
Posts: 34
Thanks: 1
Thanked 0 Times in 0 Posts
ricmetal is an unknown quantity at this point
var dynamic

hey
i cant seem to get this working:

i want to trace "dang!"
AS2

Code:
imgNumb = 1;
newi = imgNumb.toString();
_root.myData.image1 = "dang!";
imageName = ["_root.myData.image" + newi];
trace(imageName);
all i get is "_root.myData.image1"

any ideas?

Last edited by ricmetal; 12-10-2008 at 08:47 PM..
ricmetal is offline   Reply With Quote
Old 12-10-2008, 08:49 PM   PM User | #2
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
Code:
imageName = [_root.myData.image + newi];
Well quotes turn that into a string, and not into a reference to an item. Does this work?
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 12-10-2008, 08:56 PM   PM User | #3
ricmetal
New Coder

 
Join Date: Nov 2008
Posts: 34
Thanks: 1
Thanked 0 Times in 0 Posts
ricmetal is an unknown quantity at this point
it might, i just found out that tracing _root.myData.image1 yields undefined.
*what?*
any idea why this happens?
it's the only script i have on the fla
ricmetal is offline   Reply With Quote
Old 12-10-2008, 08:58 PM   PM User | #4
ricmetal
New Coder

 
Join Date: Nov 2008
Posts: 34
Thanks: 1
Thanked 0 Times in 0 Posts
ricmetal is an unknown quantity at this point
duh, there no myData
...
ricmetal is offline   Reply With Quote
Old 12-10-2008, 09:01 PM   PM User | #5
ricmetal
New Coder

 
Join Date: Nov 2008
Posts: 34
Thanks: 1
Thanked 0 Times in 0 Posts
ricmetal is an unknown quantity at this point
Quote:
Originally Posted by jeremywilken View Post
Code:
imageName = [_root.myData.image + newi];
Well quotes turn that into a string, and not into a reference to an item. Does this work?
no, that doesn't work
ricmetal is offline   Reply With Quote
Old 12-10-2008, 09:08 PM   PM User | #6
ricmetal
New Coder

 
Join Date: Nov 2008
Posts: 34
Thanks: 1
Thanked 0 Times in 0 Posts
ricmetal is an unknown quantity at this point
got it
Code:
imgNumb = 1;
newi = imgNumb.toString();
_root.myData.image1 = "dang!";
imageName = eval("_root.myData.image" + newi);
trace(imageName);

Last edited by ricmetal; 12-10-2008 at 09:44 PM..
ricmetal is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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 +1. The time now is 06:09 PM.


Advertisement
Log in to turn off these ads.