hello guys... I'm new here...
I got some problem with my action script code.
I'm trying to connect the flash file to MySQL database. All syntax seems good and I think the algorithm is fine too. but, when I run the .fla file and i press the button, i got some error message like this : "TypeError: Error #1009: Cannot access a property or method of a null object reference. at teachreg_fla::MainTimeline/cek_field()"

here is my action script code:

daftar.addEventListener(MouseEvent.CLICK, cek_field);

function cek_field (e:MouseEvent):void{

//designing error text format
    var alert:TextFormat = new TextFormat();
    alert.color = 0xff0000; //red font

    //checking the email input
    var i:int=1;
    while (i<email.length && email.text.charAt(i)!="@"){
        i++;
    }

    //checking all the input data
    if (nama.length == 0){
        error_message.text="ERROR! PLEASE REFILL YOUR FULL NAME";
        error_message.setTextFormat(alert);
        field_name.setTextFormat(alert);
    } else if (email.length == 0 || i==email.length){
        error_message.text="ERROR! WRONG EMAIL INPUTTED";
        error_message.setTextFormat(alert);
        field_email.setTextFormat(alert);
    } else if (passw !=re_passw){
        error_message.text="ERROR! PASSWORD DON'T MATCH";
        error_message.setTextFormat(alert);
        field_repassw.setTextFormat(alert);
    } else if (passw.length<6){
        error_message.text="ERROR! PASSWORD MUST AT LEAST CONTAIN 6 CHARACTER";
        error_message.setTextFormat(alert);
        field_passw.setTextFormat(alert);
    } else if (nip.length != 18){
        error_message.text="ERROR! WRONG NIP INPUTTED";
        error_message.setTextFormat(alert);
        field_nip.setTextFormat(alert);
    } //if all input are true
    else {
        //connecting to database
        var varSend:URLRequest = new URLRequest("examwarrior.php");
        varSend.method = URLRequestMethod.POST;

        var variables:URLVariables = new URLVariables();
            variables.teacher_id = "T0000000";
            variables.nama = nama.text;
            variables.email = email.text;
            variables.passw = passw.text;
            variables.network_id = "NS0000000";
            variables.nip = nip.text;

        varSend.data = variables;
        gotoAndStop(2);
    }
}

and this is my php code..

<?php
    $connect = mysql_connect("localhost", "database_name", "password") or die(mysql_error());
    mysql_select_db("antimatter", $connect) or die(mysql_error());
    $query = 'SELECT * FROM teach_info';
    $result = mysql_query($query);
?>

so,, can you help me?? need some help here....

just guessing...

try and make another var as a function and save cek_field in it.

now see if the program runs when you parse,
daftar.addEventListener(MouseEvent.CLICK, new_var);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.