Skip to main content
Known Participant
December 20, 2007
Answered

variable in a movieclip name

  • December 20, 2007
  • 2 replies
  • 214 views
hello, being a beginner I still dont get the syntax rules of AS ... could anyone help, please?

1. I have a variable called "num" which has a different value (1 to 6) everytime the timeline of the scene repeats

num = Number(random(6)+1);

2.here I would like to use "num" value in a movieclip name ("container" number should be changing according to the "num" value)

somevariable = container 1 _mc.cont 1 _txt;

how can i use the "num" value inside the movieclip names (replacing 1 in the example above)?


This topic has been closed for replies.
Correct answer kglad
:

2 replies

kglad
Community Expert
Community Expert
December 20, 2007
then you don't have an object on stage, in the frame that contains that code, with an instance name you suggested.

to debug, use trace(num) to ensure you're getting a number that corresponds to an objects instance name.
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 20, 2007
:

gringitoAuthor
Known Participant
December 20, 2007
quote:

somevariable = this["container"+num+"_mc"]["cont"+num+"_txt"];


ouh! returns "undefined" ...
(I have tried to insert the "dot" mark between mc names but returns same error)