# Access of possibly undefined flash.display:DisplayObject

**URL:** <https://forum.kirupa.com/t/access-of-possibly-undefined-flash-display-displayobject/309141>\
**Category:** Uncategorized\
**Created:** [May 7, 2010, 9:37pm UTC](https://forum.kirupa.com/t/access-of-possibly-undefined-flash-display-displayobject/309141 "2010-05-07T21:37:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mattster](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mattster](https://forum.kirupa.com/u/Mattster)\
**Post date:** [May 7, 2010, 9:37pm UTC](https://forum.kirupa.com/t/access-of-possibly-undefined-flash-display-displayobject/309141/1 "2010-05-07T21:37:26Z")

</div>

I am currently working on a shooting game, its also a trial for me to use Classes and Packages.

My set up is the stage holds the player, the script then adds 2 movieclips, enemy holder and a bullet holder. The bullet is then added to the bullet holder.

Here is what I have:

```auto
package Code{
    import flash.display.MovieClip;
    import flash.events.*;
    public class bullet1 extends MovieClip {
        public var core:Object;
        public var Bullets:Array = new Array();
        private var velocity:Number;
        private var speedx:Number;
        private var speedy:Number;
        public function bullet1(xpos:Number, ypos:Number) {
            core=MovieClip(root);
            var degreesToRadians:Number = Math.PI/180;
            var radiansToDegrees:Number = 180/Math.PI;
            var currentRotation:Number;
            x = xpos;
            y = ypos;
            addEventListener(Event.ENTER_FRAME,Tick);
            velocity=15;
        }
        public function Tick(e:Event) {
            var degreesToRadians:Number = Math.PI/180;
            var radiansToDegrees:Number = 180/Math.PI;
[COLOR=Red] x+=Math.cos((root.player.rotation)*degreesToRadians);
            y+=Math.sin((root.player.rotation)*degreesToRadians);[/COLOR]
        }
    }
}

```

I am trying to find the rotation of the player who is on the stage from inside my class…

[COLOR=Red] x+=Math.cos((root.player.rotation)\*degreesToRadians);  
y+=Math.sin((root.player.rotation)\*degreesToRadians);

[COLOR=Black]It always gives me:  
[/COLOR][/COLOR]

```auto
1119: Access of possibly undefined property player through a reference with static type flash.display:DisplayObject.

```

How can I find the player, or any other instance?
