Skip to main content
Participant
May 17, 2009
Answered

amatur coding help

  • May 17, 2009
  • 3 replies
  • 690 views

Hello... Could some one please explane how I access variables in a frame on the stage with code from a frame within a movieclip?(basically passing variables from a stage frame to a movieclip frame)

Thanks -  Aro

This topic has been closed for replies.
Correct answer kglad

you need to use the correct path from one timeline to the other.

if you're trying to access variables on the main timeline (from anywhere that's in the displaylist), you can always use root to reference the main timeline.  you'll need to cast it as a movieclip so if you have var1 defined on the main timeline:

MovieClip(root).var1

will reference var1 from any displaylist object.

3 replies

Aro C. N.Author
Participant
May 17, 2009

Thanks for all the help I think I understand now. Im going on a trip today so ill have to test the code it later.

Thank - Aro

AttaBoy2
Inspiring
May 17, 2009

If you're having trouble wraping your mind around kglad's answer try this baby step.

1. make a new fla

2 make a movieclip on the stage.

3 select the MovieClip

4 in the properties tab give the MovieClip an instance name  make it testMC

5 add a blank frame at frame 15 making your timeline 15 frames long

6 insert a new layer above the one that has the movie clip and name it actions

7 with the actions layer selected insert a keyframe at frame 8

8 with frame 8 selected open the actions panel and write testMC.alpha = 1;

9 in the actions layer insert a keyframe on frame 15

10  with frame 15 selected open the actions panel and write testMC.alpha = 0.2;

then test movie

AttaBoy2
Inspiring
May 17, 2009

Sorry my instance only explains how to access the MC from a frame in the main timeline.  If you take my example 1 step further and from a given frame on the main timeline write testMC.gotoAndPlay(frame# or label) that would get you to a ftame on the testMC timeline.  To go from a frame on the testMC timeline I think you can refer to the main timeline as parent so parent.gotoAndPlay(frame)  Or would it be this.parent.parent  I'll have to do further testing :-)   I was just rereading kglads comments of course this is AS3 it's ok to use root to reference the main timeline.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 17, 2009

you need to use the correct path from one timeline to the other.

if you're trying to access variables on the main timeline (from anywhere that's in the displaylist), you can always use root to reference the main timeline.  you'll need to cast it as a movieclip so if you have var1 defined on the main timeline:

MovieClip(root).var1

will reference var1 from any displaylist object.