# AS3 Question: Accessing a main timeline variable from a class?

**URL:** <https://forum.kirupa.com/t/as3-question-accessing-a-main-timeline-variable-from-a-class/309575>\
**Category:** flash\
**Created:** [May 19, 2010, 1:03am UTC](https://forum.kirupa.com/t/as3-question-accessing-a-main-timeline-variable-from-a-class/309575 "2010-05-19T01:03:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![noisavni](https://avatars.discourse-cdn.com/v4/letter/n/b487fb/32.png) [@noisavni](https://forum.kirupa.com/u/noisavni)\
**Post date:** [May 19, 2010, 1:03am UTC](https://forum.kirupa.com/t/as3-question-accessing-a-main-timeline-variable-from-a-class/309575/1 "2010-05-19T01:03:20Z")

</div>

First Post! I like what you’ve done with the place.

```
                     I'm was getting good with as2 but recently made the mind switch from, I'll learn as3 tomorrow to as3 is awesome. The problem for me is that I don't understand the scope for classes. I know I can trace a variable on the main time line when the var is declared in the class. But how do you access a main time line var from a class?

```

Here’s an example - main time line Monkey.fla

```auto
var cagedMonkies:int = 10;
var monkeyTransport:MovieClip = new CarTrunk();

```

Here’s the second part - CarTrunk.as

```auto
package {
       import flash.display.MovieClip;
    public class CarTrunk extends MovieClip {
      public function CarTrunk() {
        trace(cagedMonkies);
             }
    }
}

```

What would I need to change or do to make code like this work?

```
                                          **Thankful People:**
```
