Skip to main content
pinkstonms
Participant
May 17, 2013
Question

I am getting a 1056 error in my custom class file and cannot figure out why... Help

  • May 17, 2013
  • 1 reply
  • 479 views

Here is the error I am getting:

ReferenceError: Error #1056: Cannot create property button1 on com.sample.PWClass.PClass.

Here is my code:

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
        } 
    } 

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
May 17, 2013

If this is not your document class, since button1 is not created within the class, there is nothing provided to reference it as an external object.  You need to pass in a reference to it.

pinkstonms
Participant
May 17, 2013

Thanks Ned but I am sorry do not follow you. This is my first try at a custom class file. Actually the first time I have ever coded anything outside the FLA timeline.

pinkstonms
Participant
May 17, 2013

Figured it out Ned I needed to click on the Stage option "Automatically declare a stage instance", Thanks for your help.