Skip to main content
Inspiring
July 2, 2007
Answered

getting a value from a nested m.c.

  • July 2, 2007
  • 3 replies
  • 324 views
if I have a movie clip
mc1
with mc2 nested in mc1.
mc2 has a variable called varNum=2;

why can't I from the root get the value varNum using ..
.
trace(mc1.mc2.varNum);


thanks to any responders.
This topic has been closed for replies.
Correct answer kglad
you can if varNum is defined when you're trying to access it.

a typical issue would be:

1. varNum is defined on frame 1 of mc2
2. mc2 is on frame 1 of mc1
3 mc1 is on frame 1 of the _root timeline
4. you try and access varNum (with the correct path) in frame 1 of the _root timeline and fail because the code in frame 1 of the _root timeline executes before the code in frame 1 of mc2. so, varNum appears to be undefined.

3 replies

kglad
Community Expert
Community Expert
July 3, 2007
you're welcome.
Inspiring
July 2, 2007
Thanks Kglad,
The issue I was having with the example I had created was indeed as you pointed out to do with timing.... however, for my actual problem I was getting the variable value using an onRelease, so wasn't a timing issue, but infact an incorrectly spelt instnace name... school boy error... far too tired. Sorry for wasting your time, and thanks for the response.
J
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
July 2, 2007
you can if varNum is defined when you're trying to access it.

a typical issue would be:

1. varNum is defined on frame 1 of mc2
2. mc2 is on frame 1 of mc1
3 mc1 is on frame 1 of the _root timeline
4. you try and access varNum (with the correct path) in frame 1 of the _root timeline and fail because the code in frame 1 of the _root timeline executes before the code in frame 1 of mc2. so, varNum appears to be undefined.