Pages: [1]
  Print  
Author Topic: TypeError: Error #1034: Type Coercion failed  (Read 907 times)
rolandlg
Gaia Novice
*
Posts: 1


« on: May 16, 2011, 05:00:19 AM »

hello everyone im having some trouble meaking a php contact form  the error that returns me is this :

TypeError: Error #1034: Type Coercion failed: cannot convert fl.controls::Button@2e35f0b1 to flash.display.MovieClip.
   at flash.display::Sprite/constructChildren()
   at flash.display::Sprite()
   at flash.display::MovieClip()
   at com.gaiaframework.templates::AbstractBase()
   at com.gaiaframework.templates::AbstractPage()
   at com.FGaiaLT.pages::FormPage()

i would appreciate your help really im just a nob.
i dont know if somethins is wrong i just get the code from a tuto on internet and tried to adapt it but with no good resul, so if someone can check it or give me another direction, i just need to make a contact form with a combobox and a status mesage of your message has been sent or something like that and thats it.
this is my code:

package com.FGaiaLT.pages
{
   import com.gaiaframework.templates.AbstractPage;
   import com.gaiaframework.events.*;
   import com.gaiaframework.debug.*;
   import com.gaiaframework.api.*;
   import flash.display.*;
   import flash.events.*;
   import com.greensock.TweenMax;
   import flash.text.TextField;
   import flash.net.URLVariables;
   import flash.net.URLRequest;
   import flash.net.URLLoader;
   import flash.net.URLRequestMethod;
   import flash.net.URLLoaderDataFormat;
   
   public class FormPage extends AbstractPage
   {   

      public var status_txt:TextField;
      public var name_txt:TextField;
      public var name2_txt:TextField;
      public var email_txt:TextField;
      public var tel_txt:TextField;
      public var msg_txt:TextField;
      public var processing_mc:MovieClip;
      public var submit_btn:MovieClip;
      public var cList:MovieClip;
            
      public function FormPage()
      {
         super();
         alpha = 0;
         
         // hide processing CM
         processing_mc.visible = false;
         // custom function we create to populate the comboBox list
         addCToList ();
         
         // Add event listener for submit button click
         submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);
      }
      override public function transitionIn():void
      {
         super.transitionIn();
         TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
      }
      override public function transitionOut():void
      {
         super.transitionOut();
         TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
      }
         
      private function addCToList ():void
      {
         cList.addItem( { label: "Publicidad en Facebook" } );   
         cList.addItem( { label: "Publicidad en Google" } );   
         cList.addItem( { label: "Publicidad via Correo electronico" } );   
         cList.addItem( { label: "Volantes o Trifoliares" } );
         cList.addItem( { label: "Referencia de un Amigo o Familiar" } );
         cList.addItem( { label: "Paso frente a nuestras instalaciones" } );
         cList.addItem( { label: "Otro" } );
      }
      
      // handler for the PHP script completion and return of status
      private function completeHandler(event:Event):void
      {
         // remove processing clip
         processing_mc.visible = false;
         name_txt.text = "";
         name2_txt.text = "";
         name_txt.text = "";
         tel_txt.text = "";
         msg_txt.text = "";
         
         // Load the response from php here
         status_txt.text = event.target.data.return_msg;
      }
      // function ValidateAndSend
      private function ValidateAndSend (event:MouseEvent):void
      {
         
         // validate fields
         if(!name_txt.length)
         {
            status_txt.text = "Porfavor ingrese su nombre";
         }
         else if(!name2_txt.length)
         {
            status_txt.text = "Porfavor ingrese el nombre de su pequeño";
         }
         else if (!email_txt.length)
         {
            status_txt.text = "Porfavor ingrese su correo";
         }
         else if (!msg_txt.length)
         {
            status_txt.text = "Porfavor ingrese el mensaje";
         }
         else
         {

            // build variable name for the URL Variables loader
            var variables:URLVariables = new URLVariables;
   
            // Build the varSend variable
   
            var varSend:URLRequest = new URLRequest("form_parse.php");
   
            varSend.method = URLRequestMethod.POST;
            varSend.data = variables;
            
            // Build the varLoader variable
   
            var varLoader:URLLoader = new URLLoader;
            varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
            varLoader.addEventListener(Event.COMPLETE, completeHandler);
         
            // All is good, send the data now to PHP
            processing_mc.visible = true;
      
            // ready the variables in our form for sending
            variables.userName = name_txt.text;
            variables.userName2 = name2_txt.text;
            variables.userTel = tel_txt.text;      
            variables.userEmail = email_txt.text;      
            variables.userMsg = msg_txt.text;
            variables.userCList = cList.value;
            
            // Send the data to PHP now
            varLoader.load(varSend);
            
         
         // close else condition for error handling
         }
      // close validate and send function   
      }

   }
}
Logged
steven
Gaia Author
Administrator
Gaia Evangelist
*****
Posts: 3871


gaiaframework
WWW
« Reply #1 on: May 16, 2011, 11:04:41 AM »

This has nothing to do with Gaia. Non-Gaia questions should be asked on Flashcoders. The error tells you everything you need to know. Do a google search for the error to figure it out.
Logged

Steven Sacks | Gaia Author
Please support Gaia by donating to the project!  Smiley
Mickey
Gaia Novice
*
Posts: 8


« Reply #2 on: July 05, 2011, 10:17:45 AM »

U need to make sure you are declaring the variables in the correct way, for example the msg_txt should be    
   
public var msg_txt:TextArea;

the submit btn should be:

public var submit_btn: Button;

the name txt should be:

public var name_txt:TextInput;

and so on...

Logged
Pages: [1]
  Print  
 
Jump to:  

TinyPortal v1.0 beta 4 © Bloc