PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Contact form - Error #1006: value is not a function.
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Contact form - Error #1006: value is not a function.

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    2

    Contact form - Error #1006: value is not a function.

    Hello,
    I'm fairly new to Flash and AS3. I recently started working on a contact form and keep receiving the following output error when testing the movie (clicking the send button).

    Any thoughts or suggestions...?
    -Jason


    TypeError: Error #1006: value is not a function.
    at Contact_fla::MainTimeline/SubmitFunction()



    AS3:


    Actionscript Code:
    /*To Define The Main Varibles*/
    var urlLoader:URLLoader = new URLLoader();
    var imgLoader:Loader = new Loader();
    var loadFunction:URLLoader=new URLLoader  ;

    /*XML Request*/
    function XMLFunction(XMLPath:String):void {
        urlLoader.load(new URLRequest(XMLPath));
        urlLoader.addEventListener(Event.COMPLETE, onSuccess);
    }
    //The Name of the XML File
    XMLFunction("ContactXML.xml");

    /*XML - Flash Actions*/
    //We'll define "info, title and image" varibles to use them in XML File.
    function onSuccess(e:Event):void {
        var xml:XML=new XML(e.target.data);
        contactInfo.htmlText=xml.info;//We use HTML to show any type of texts
        contactInfo.autoSize=TextFieldAutoSize.LEFT;//AutoSize-Left
        contactTitle.htmlText=xml.title;
        contactTitle.autoSize=TextFieldAutoSize.LEFT;
        imgLoader.load(new URLRequest(xml.@image));
        imageMc.addChild(imgLoader);
    }
    /*Focus In - Focus Out*/
    /*An object dispatches a FocusEvent object when the user changes the focus
    from one object in the display list to another.*/


    //Name Text Actions
    nameText.text="NAME";
    nameText.addEventListener(FocusEvent.FOCUS_IN, focusInName);
    nameText.addEventListener(FocusEvent.FOCUS_OUT, focusOutName);

    function focusInName(evt:Event) {
        if (nameText.text=="NAME") {
            nameText.text="";
        }
    }

    function focusOutName(evt:Event) {
        if (nameText.text=="") {
            nameText.text="NAME";
        }
    }

    //E-Mail Text Actions
    emailText.text="E-MAIL";

    emailText.addEventListener(FocusEvent.FOCUS_IN, focusInEmail);
    emailText.addEventListener(FocusEvent.FOCUS_OUT, focusOutEmail);

    function focusInEmail(evt:Event) {
        if (emailText.text=="E-MAIL") {
            emailText.text="";
        }
    }

    function focusOutEmail(evt:Event) {
        if (emailText.text=="") {
            emailText.text="E-MAIL";
        }
    }

    //Subject Functions
    subjectText.text="SUBJECT";

    subjectText.addEventListener(FocusEvent.FOCUS_IN, focusInSubject);
    subjectText.addEventListener(FocusEvent.FOCUS_OUT, focusOutSubject);

    function focusInSubject(evt:Event) {
        if (subjectText.text=="SUBJECT") {
            subjectText.text="";
        }
    }

    function focusOutSubject(evt:Event) {
        if (subjectText.text=="") {
            subjectText.text="SUBJECT";
        }
    }

    //Message Functions
    messageText.text="MESSAGE";

    messageText.addEventListener(FocusEvent.FOCUS_IN, focusInMessage);
    messageText.addEventListener(FocusEvent.FOCUS_OUT, focusOutMessage);

    function focusInMessage(evt:Event) {
        if (messageText.text=="MESSAGE") {
            messageText.text="";
        }
    }

    function focusOutMessage(evt:Event) {
        if (messageText.text=="") {
            messageText.text="MESSAGE";
        }
    }
    /*/PHP - Flash Actions/*/

    //Make a PHP Script Request to Post to the server

    var urlRequest:URLRequest=new URLRequest("ContactPHP.php"); //The Name of the PHP Script
    urlRequest.method=URLRequestMethod.POST;

    //Send Button
    sendBtn.addEventListener(MouseEvent.CLICK, SubmitFunction);

    /*Text Field Validation*/
    function SubmitFunction(e:MouseEvent):void {
        if (nameText.text == "NAME" || emailText.text == "E-MAIL" ||
        subjectText.text == "SUBJECT" || messageText.text == "MESSAGE" ) {
            resultText.text="PLEASE FILL OUT ALL REQUIRED FIELDS";

        } else if ( !emailValidate(emailText.text) ) {
            resultText.text="VALID E-MAIL ADDRESS.";//If E-Mail field is empty the e-mail will not be sent.
        } else {
            resultText.text="SENDING...";//If everything is correct the message'll be sent.

            var dataEmail:String = "name=" + nameText.text
               + "&email=" + emailText.text
               + "&subject=" + subjectText.text
               + "&message=" + messageText.text;
    function emailValidate(s:String):Boolean {
        var p:RegExp=/(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
        var r:Object=p.exec(s);
        if (r==null) {
            return false;
        }
        return true;
    }
    /*URL Actions*/

    var URLvariables:URLVariables=new URLVariables(dataEmail);

    URLvariables.dataFormat=URLLoaderDataFormat.TEXT;
    urlRequest.data=URLvariables;
    loadFunction.load(urlRequest);
    loadFunction.addEventListener(Event.COMPLETE, responseFunction );
        }
    }

    /*Status of the E-Mail*/

    function responseFunction(e:Event):void {
        var loader:URLLoader=URLLoader(e.target);
        var emailStatus=new URLVariables(loader.data).success;
        //If E-Mail is sent successfully, the visitor'll see this message.
        if (emailStatus=="yes") {
            resultText.text="THANK YOU! YOUR MESSAGE WAS SENT SUCCESSFULLY.";
            //If E-Mail can not be sent, the visitor'll see this message.
        } else {
            resultText.text="AN ERROR OCCURED!";
        }
    }

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    var urlLoader:URLLoader = new URLLoader();
    var imgLoader:Loader = new Loader();
    var loadFunction:URLLoader=new URLLoader();
    function XMLFunction(XMLPath:String):void {
    	urlLoader.load(new URLRequest(XMLPath));
    	urlLoader.addEventListener(Event.COMPLETE, onSuccess);
    }
    XMLFunction("ContactXML.xml");
    function onSuccess(e:Event):void {
    	var xml:XML=new XML(e.target.data);
    	contactInfo.htmlText=xml.info;
    	//We use HTML to show any type of texts    
    	contactInfo.autoSize=TextFieldAutoSize.LEFT;
    	//AutoSize-Left    
    	contactTitle.htmlText=xml.title;
    	contactTitle.autoSize=TextFieldAutoSize.LEFT;
    	imgLoader.load(new URLRequest(xml.@image));
    	imageMc.addChild(imgLoader);
    }
    nameText.text="NAME";
    nameText.addEventListener(FocusEvent.FOCUS_IN, focusInName);
    nameText.addEventListener(FocusEvent.FOCUS_OUT, focusOutName);
    function focusInName(evt:Event) {
    	if (nameText.text=="NAME") {
    		nameText.text="";
    	}
    }
    function focusOutName(evt:Event) {
    	if (nameText.text=="") {
    		nameText.text="NAME";
    	}
    }
    emailText.text="E-MAIL";
    emailText.addEventListener(FocusEvent.FOCUS_IN, focusInEmail);
    emailText.addEventListener(FocusEvent.FOCUS_OUT, focusOutEmail);
    function focusInEmail(evt:Event) {
    	if (emailText.text=="E-MAIL") {
    		emailText.text="";
    	}
    }
    function focusOutEmail(evt:Event) {
    	if (emailText.text=="") {
    		emailText.text="E-MAIL";
    	}
    }
    subjectText.text="SUBJECT";
    subjectText.addEventListener(FocusEvent.FOCUS_IN, focusInSubject);
    subjectText.addEventListener(FocusEvent.FOCUS_OUT, focusOutSubject);
    function focusInSubject(evt:Event) {
    	if (subjectText.text=="SUBJECT") {
    		subjectText.text="";
    	}
    }
    function focusOutSubject(evt:Event) {
    	if (subjectText.text=="") {
    		subjectText.text="SUBJECT";
    	}
    }
    messageText.text="MESSAGE";
    messageText.addEventListener(FocusEvent.FOCUS_IN, focusInMessage);
    messageText.addEventListener(FocusEvent.FOCUS_OUT, focusOutMessage);
    function focusInMessage(evt:Event) {
    	if (messageText.text=="MESSAGE") {
    		messageText.text="";
    	}
    }
    function focusOutMessage(evt:Event) {
    	if (messageText.text=="") {
    		messageText.text="MESSAGE";
    	}
    }
    var urlRequest:URLRequest=new URLRequest("ContactPHP.php");//The Name of the PHP Script
    urlRequest.method=URLRequestMethod.POST;
    
    sendBtn.addEventListener(MouseEvent.CLICK, SubmitFunction);
    
    function SubmitFunction(e:MouseEvent):void {
    	if (nameText.text=="NAME"||emailText.text=="E-MAIL"||subjectText.text=="SUBJECT"||messageText.text=="MESSAGE") {
    		resultText.text="PLEASE FILL OUT ALL REQUIRED FIELDS";
    	} else if ( !emailValidate(emailText.text) ) {
    		resultText.text="VALID E-MAIL ADDRESS.";
    		//If E-Mail field is empty the e-mail will not be sent.    
    	} else {
    		resultText.text="SENDING...";
    		//If everything is correct the message'll be sent.        
    		var dataEmail:String="name="+nameText.text+"&email="+emailText.text+"&subject="+subjectText.text+"&message="+messageText.text;
    
    		/*URL Actions*/
    		var URLvariables:URLVariables=new URLVariables(dataEmail);
    		URLvariables.dataFormat=URLLoaderDataFormat.TEXT;
    		urlRequest.data=URLvariables;
    		loadFunction.load(urlRequest);
    		loadFunction.addEventListener(Event.COMPLETE, responseFunction );
    	}
    }
    function emailValidate(s:String):Boolean {
    	var p:RegExp=/(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
    	var r:Object=p.exec(s);
    	if (r==null) {
    		return false;
    	}
    	return true;
    }
    function responseFunction(e:Event):void {
    	var loader:URLLoader=URLLoader(e.target);
    	var emailStatus=new URLVariables(loader.data).success;
    	//If E-Mail is sent successfully, the visitor'll see this message. 
    	if (emailStatus=="yes") {
    		resultText.text="THANK YOU! YOUR MESSAGE WAS SENT SUCCESSFULLY.";
    		//If E-Mail can not be sent, the visitor'll see this message.    
    	} else {
    		resultText.text="AN ERROR OCCURED!";
    	}
    }

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    2
    Thanks so much!
    -Jason

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center