Nope.

You still don't have ID's set for the textInput and textField. An item
needs an id if you want to reference it somewhere else.

Also, you should keep all the functionality for a component inside the
component. The function that you call from the button in the
FormComp.mxml file should be inside the FormComp.mxml file.

Here are the files as they should look:

ContactForm.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical"
     xmlns:forms="forms.*" backgroundGradientAlphas="[1.0, 1.0]"
     backgroundGradientColors="[#06B8EC, #C1E6F1]">
     <forms:FormComp/>
</mx:Application>



FormComp.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"; width="400"
height="300">
     <mx:Script>
         <![CDATA[
             private function sendMyData():void
             {
                 var obj:Object = new Object();
                 obj.Name = Name.text;
                 obj.Email = thisIsTheEmailAddressIWant.text;
                 obj.Message = Message.text;
                 myContactService.send(obj);
             }
         ]]>
     </mx:Script>
     <mx:HTTPService id="myContactService"
          url="FormToEmail.php"
          method="POST"/>
     <mx:FormItem label="Name:">
         <mx:TextInput id="Name"/>
     </mx:FormItem>
     <mx:FormItem label="Email:">
         <mx:TextInput id="thisIsTheEmailAddressIWant"/>
     </mx:FormItem>
     <mx:FormItem label="Message:">
         <mx:TextArea id="Message"/>
     </mx:FormItem>
     <mx:FormItem>
         <mx:Button label="Contact Us" fontSize="16"
click="sendMyData()"/>
     </mx:FormItem>
</mx:Form>

Note that each input field has an id set so that they can be referenced
inside the function (I have changed the Email id to show this more
obviously). Also note that the FormComp.mxml is totally self contained.
It does not rely on anything else.

--- In [email protected], "brucewhealton" <[EMAIL PROTECTED]> wrote:
>
> We are close, hopefully.  I still get an error on the lines inside the
> sendMyData function.  It is giving me an error that says,
> Error: Access to undefined property Name,
> Error: Access to undefined property Email,
> Error: Access to undefined property Message,
>
> It should be noted that I have the component, named FormComponent in a
> subfolder form the source root, in a file called FormComponent.mxml,
> of course. That file just has the Form and the FormItem tags, with
> InputText fields with id of Name, Email, Message.
> I instantiate the Form component into the application called
ContactForm.
>
> So, I uploaded the project to the web on the server I use.  It seems
> like this would be the best way to see what I am missing or doing
> wrong.  So, please check it out here:
> http://fwweb.biz/ContactForm.zip
> thanks,
> Bruce
>
>
>
> --- In [email protected], "valdhor" stevedepp@ wrote:
> >
> > There are a few things wrong with your form...
> >
> > You have the id="Email" on the FormItem - it should be on the
TextInput.
> >
> > The name of your form component is ContactForms.mxml but you try to
> > instantiate it with <forms:ContactForm id="myContactForm"/> (Note
> > ContactForms and ContactForm is different).
> >
> > You cannot set properties of a variable inside a CDATA block. You
must
> > do it in a function (Which is inside the CDATA block). eg.
> >
> > private function sendMyData():void
> > {
> > var obj:Object = new Object();
> > obj.Name = Name.text;
> > obj.Email = Email.text;
> > obj.Message = Message.text;
> > myContactService.send(obj);
> > }
> >
> > and change the button mxml to
> >
> > <mx:Button label="Contact Us" fontSize="16" click="sendMyData()"/>
> >
>

Reply via email to