# Need help with a custom class file

**URL:** https://forum.kirupa.com/t/need-help-with-a-custom-class-file/331105
**Category:** flash
**Created:** [May 17, 2013, 4:29pm UTC](https://forum.kirupa.com/t/need-help-with-a-custom-class-file/331105 "2013-05-17T16:29:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![avaughn](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@avaughn](https://forum.kirupa.com/u/avaughn)
#### Post date: [May 17, 2013, 4:29pm UTC](https://forum.kirupa.com/t/need-help-with-a-custom-class-file/331105/1 "2013-05-17T16:29:38Z")

</div>

I have created a custom class file that is returning the following error message: \*  
ReferenceError: Error #1056: Cannot create property button1 on com.sample.PWClass.PClass.Z Here is my code

```php
package com.sample.PWClass { 

    import flash.display.MovieClip;  
    import flash.events.MouseEvent;  
    import flash.text.TextField;  

    public class PClass extends MovieClip {  
        private var totalChar=8;// number of chars in the password  
        private var xcom:String="abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ";  
        private var xcomnum:String="0123456789";  
        private var l_length=xcom.length;  
        private var n_length=xcomnum.length;  
        private var new_password:String=new String();// set the inital variable  

        public function PClass() {  
            button1.addEventListener(MouseEvent.CLICK,onClickHandler);  
        }  
        private function onClickHandler(evt:MouseEvent):void {  
            mark.text = newPassword();  
            trace(mark.text);  
        }  
        private function newPassword() {  
            new_password=new String();  
            for (var i=0; i < totalChar; i++) {// loop and create password  
                var a=xcom.charAt(Math.floor(Math.random() * l_length));  
                var b=xcomnum.charAt(Math.floor(Math.random() * n_length));  
                var char=Math.floor(Math.random() * totalChar) % 2 == 0?a:b;  
                new_password+= char;  
            }  
            return new_password;  
        }  
    }  
}  

```

-
