0

I need to add two vars together to get an existing var name already declared.

var Tweet1:String;


//code called later in function
var num = 1;
output.text = Tweet+num; // This does not work
1
  • I have 20 tweets and each one is called Tweet1, Tweet2 etc... but I am getting the var dynamically so I want the "Tweet1" to be my final result. or Tweet2 etc.. Does this make sense? Commented Jan 21, 2014 at 15:17

1 Answer 1

1

Try next syntax: this["Tweet"+num]

Sign up to request clarification or add additional context in comments.

4 Comments

That didn't work. I tried this: output.text = "Tweet"+daNum; and I got the right text to display "Tweet1" but Tweet1 is already a string name so I need the actual Tweet1 content (example: Hello, I am a tweet) and not the string name "Tweet1"
@PapaDeBeau What exactly "didn't work"? What error message it gives?
Thanks. This was the error I got|| TypeError: Error #2007: Parameter text must be non-null. at flash.text::TextField/set text()
Wait.. I think the value of Tweet1 is not loaded yet, this is why. Hold on. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.