First forget what I said about the result handler because I thought you
should receive the data from the service while in reality you want to send
it!

Now back to the code in the CDATA block. It must be clear that the CDATA
block is not a function!! It is like writing code for a class but without
the class block delimiters, I mean without "public class ClassName {" and
the closing "}".

So this code is illegal in a CDATA block (more specifically the second
line):

var obj:Object = new Object();
obj.Name = Name.text;

The second line must live in a function. In your case put the code in the
click event handler of the send button:

private function sendButtonClickHandler(event:MouseEvent):void
{
  var obj:Object = new Object();
  obj.Name = Name.text;
  myContactService.send(obj);
}



On Thu, Oct 16, 2008 at 7:49 AM, brucewhealton
<[EMAIL PROTECTED]>wrote:

>   Hi, I was wondering if you could expand on this... more specifically.
> I'm not quite following you.
> I was given a framework regarding how to do this, from an instructor
> on the Lynda.com library of online training. He gave me the basic
> framework for what needs to happen. I know I am missing something.
>
> I'm really frustrated that I still cannot get this very basic thing
> working. Can someone show how specifically this would be done,
> please. Let's say we have just one field, a Text Input field in a
> FormItem tag and then a Button tag, with a click event handler, that
> calls the php form processor called FormToEmail.php
> This is what I know, that the php form processor wants a _POST[] array
> variable. So, I have,
>
> <mx:HTTPService id="myContactService"
> url="FormToEmail.php"
> method="POST"/>
>
> Then in a CDATA block, I setup an Object. My instructor said that
> this would be used to send the data as expected by the form processor,
> which in this case is, FormToEmail.php
> So, I have:
> var obj:Object = new Object();
> obj.Name = Name.text;
>
> If the form had just one Form Item, for simplicity in demonstrating
> this, we could assume Name is the id of that FormItem.
>
> Can someone please in detail explain or demonstrate what would be
> done, specifically. If you know of a place where this is explained on
> the web, please let me know. Clearly, I'm missing something here but
> I am not following what that is.
> thanks,
> Bruce
>
> --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, "Haykel
> BEN JEMIA" <[EMAIL PROTECTED]>
> wrote:
> >
> > Most of the code in the CDATA block will be inserted in a class during
> > compilation so you can write whatever is allowed in a class block
> > (declarations and function definitions). The assignments are hence not
> > allowed there, they must live in a function.
> > In your case, you should do the assignments in the result handler of the
> > HTTPService anyway.
> >
> > Hope this helps!
> >
> >
> > On Wed, Oct 15, 2008 at 6:22 AM, brucewhealton
> > <[EMAIL PROTECTED]>wrote:
>
> >
> > > Hello all,
> > > Flex is not liking the way I setup the Object in a CDATA block
> > > in a Form Component.
> > > I have a Form component in a forms subfolder/subdirectory of
> > > the src directory/folder. I have an application in the src folder
> > > called FormRequest.mxml and in the forms folder I setup a Form
> > > Component that I called ContactForm.mxml
> > > My form processor will take variable value pairs and email them
> > > to me. In HTML, I use a form tag and then <input name="name"
> > > type="text"/>
> > > So, I have in the Form component (which is in the file
> > > ContactForms.mxml in the forms subfolder) an HTTPService as such:
> > >
> > > <mx:HTTPService id="myContactService"
> > > url="FormToEmail.php"
> > > method="POST"/>
> > >
> > > Then I have
> > >
> > > <mx:FormItem label="Name:">
> > > <mx:TextInput id="Name" width="195"/>
> > > </mx:FormItem>
> > > <mx:FormItem id="Email" label="Email:" fontSize="16">
> > > <mx:TextInput width="195"/>
> > > </mx:FormItem>
> > > <mx:FormItem label="Your Message:" fontSize="16">
> > > <mx:TextArea id="Message" height="100" width="195"/>
> > > </mx:FormItem>
> > > <mx:FormItem>
> > > <mx:Button label="Contact Us" fontSize="16"
> > > click="myContactService.send(obj)"/>
> > > </mx:FormItem>
> > >
> > > In the CDATA AS block, I have this:
> > > var obj:Object = new Object();
> > > obj.Name = Name.text;
> > > obj.Email = Email.text;
> > > obj.Message = Message.text;
> > >
> > > It doesn't like this, as it gives me an error message on the 2nd, 3rd
> > > and 4th lines saying that obj is an undefined property. Am I missing
> > > public or private in front of the var? Sometimes I get confused when
> > > that is left off the code.
> > >
> > > Somehow, I've got to get the Name, Email and Message, that the user
> > > types into the Form Items, connected to the obj Object. Then I have
> > > to give it to the FormToEmail.php form processor that takes _POST
> > > ['inputtextvariable']
> > > It looks for variables of that form in the _POST variable. In HTML
> > > the data comes from the name attribute of the INPUT tag.
> > >
> > > Should all of this be in the ContactForm.mxml component? This is
> > > called from FormRequest.mxml inside a Panel, I have this:
> > > <mx:Panel title="Contact Us">
> > > <forms:ContactForm id="myContactForm"/>
> > > </mx:Panel>
> > >
> > > Does this sound right? I mean other than the fact that the Form
> > > component is not liking obj, saying it is undefined. I tried hitting
> > > ctrl-space to see if it would add an import for the Object class but
> > > it must not be needed.
> > > Can anyone explain this more clearly, how to get information from a
> > > flex Form tag, representing a Form class, into a _POST[] array
> > > variable that the php FormToEmail.php form processor will email to me?
> > > Thanks,
> > > Bruce
> > >
>
>  
>



-- 
Haykel Ben Jemia

Allmas
Web & RIA Development
http://www.allmas-tn.com

Reply via email to