# Am i doing this wronlgy?

**URL:** <https://forum.kirupa.com/t/am-i-doing-this-wronlgy/250222>\
**Category:** Uncategorized\
**Created:** [January 27, 2008, 5:44am UTC](https://forum.kirupa.com/t/am-i-doing-this-wronlgy/250222 "2008-01-27T05:44:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kneural](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@kneural](https://forum.kirupa.com/u/kneural)\
**Post date:** [January 27, 2008, 5:44am UTC](https://forum.kirupa.com/t/am-i-doing-this-wronlgy/250222/1 "2008-01-27T05:44:29Z")

</div>

Hi,

Ok, i have a MovieClip in my library with a function that uses variables declared just above it like so;

```auto

var myString:String = "this is a string";

function traceVal():void
{
    trace(myString);
}

traceVal(); // Returns "this is a string"

```

okay. this works after i drag and drop the mc from the library to the stage.

later on, i right clicked on the linkage properties of the mc and made it into a Class called “Tracer” with a base class of “flash.display.MovieClip”, and removed the traceVal(); caller,

back on stage, when i tried to make an instance of the Class and call a nested function in it. It was unable to return me the variables which was declared in the MovieClip

```auto

var my_tracer:Tracer = new Tracer();

addChild(my_tracer);

my_tracer.traceVal(); // Retruns "null"

```

am i doing this wrongly? can anyone help me?
