# Where to declare and set variables for an extended class

**URL:** <https://forum.kirupa.com/t/where-to-declare-and-set-variables-for-an-extended-class/331550>\
**Category:** flash\
**Created:** [August 26, 2013, 6:00pm UTC](https://forum.kirupa.com/t/where-to-declare-and-set-variables-for-an-extended-class/331550 "2013-08-26T18:00:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Lees](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@David\_Lees](https://forum.kirupa.com/u/David_Lees)\
**Post date:** [August 26, 2013, 6:00pm UTC](https://forum.kirupa.com/t/where-to-declare-and-set-variables-for-an-extended-class/331550/1 "2013-08-26T18:00:53Z")

</div>

I have a class that looks like this.

```auto

    public class Man extends MovieClip
    {
        var typeOfPerson:String;
        public function Man()
        {
            trace("In Man class:- ",typeOfPerson); //null
        }
    }

```

and another class like this

```auto
    public class Wally extends Man
    {
        public function Wally()
        {
            typeOfPerson = "Nice guy, bit of a wally";
            trace("In Wally class:-", typeOfPerson); //Nice guy, bit of a wally
        }

    }

```

I want to access the typeOfPerson variable from the Man class. When I view the output of the trace statements, the trace from the man class is displayed first. It is null, which makes sense because I haven’t given it’s value in the Wally class at that stage. How do I access typeOfPerson from the Man class? If what I am asking for is not possible and I am going about this completely the wrong way. What is the correct way to do this?

Thanks.
