# Class instantiation problem

**URL:** <https://forum.kirupa.com/t/class-instantiation-problem/243729>\
**Category:** flash\
**Created:** [November 9, 2007, 11:13pm UTC](https://forum.kirupa.com/t/class-instantiation-problem/243729 "2007-11-09T23:13:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick\_Banghart](https://avatars.discourse-cdn.com/v4/letter/r/4491bb/32.png) [@Rick\_Banghart](https://forum.kirupa.com/u/Rick_Banghart)\
**Post date:** [November 9, 2007, 11:13pm UTC](https://forum.kirupa.com/t/class-instantiation-problem/243729/1 "2007-11-09T23:13:17Z")

</div>

I have a class:

> package {  
> public class newClass {  
> public var value1:int = 10;  
> function newClass() {  
> trace(“constructing”);  
> }  
> public function someMethod():String {  
> return “hello”;  
> }  
> }  
> }  
> It is saved as newClass.as in the directory with my .fla

In frame 1 actions layer I have:

> import newClass;  
> var myTest:newClass = new newClass();  
> trace(myTest.value1);  
> When I run this I get the expected output of “10”.

I also have a document class:

> package {  
> import flash.utils.Timer;  
> import flash.events.TimerEvent;  
> import flash.events.Event;  
> import flash.events.MouseEvent;  
> import flash.events.IOErrorEvent;  
> import flash.display.DisplayObjectContainer;  
> import flash.display.Bitmap;  
> import flash.display.BitmapData;  
> import flash.net.URLLoader;  
> import flash.net.URLRequest;  
> import flash.net.URLRequestMethod;  
> import flash.net.URLVariables;  
> import flash.display.MovieClip;  
> import flash.display.Sprite;  
> import flash.external.ExternalInterface;  
> import flash.text.TextField;  
> import flash.text.TextFieldType;  
> import newClass;  
> public class vidSlide extends MovieClip {  
> var instance:newClass = new newClass();  
> trace(instance.value1);  
> private var videoPath:String = “[http://my.url.com/video.flv](http://my.url.com/video.flv)”;  
> public function vidSlide() {  
> player.source = videoPath;  
> player.skinBackgroundColor = 0x666666;  
> player.skinBackgroundAlpha = 0.5;

```
    }
}// end vidSlide class

```

}

When I run this with the trace(instance.value1) I get “1120: Access of undefined property instance” error. If I comment out the trace it runs fine and the output shows the trace in the class constructor (indicating to me that the “var instance:newClass = new newClass();” is doing what it should).

What am I missing? Any comments appreciated.
