PDA

View Full Version : sending pop ups information into a main file


keseth
12-30-2009, 08:36 AM
Hello and Merry Xmas!:)

I am very new to flex and need help here.

I have a main flex file with different pop-up files (already imported into the main flex file). How do i transfer the data from these pop up files into the main file without the use of database. ?

In other words i want to store information entered from these pop ups files to display in the main file. Then a user would decide to submit these information into a database or reset this information.

Thank you.:D

aktell
12-30-2009, 07:42 PM
Only a couple of weeks ago I was trying this code I found on the net for some of my stuff.
I have to copy and paste it from my App. for you as it is not in its original state any longer but it should work! If not get back on that!. Hope it helps
Use this in your PopUp:

<mx:TitleWindow
xmlns:mx="http://www.adobe.com/2006/mxml">

<mx:Metadata>
[Event(name="SaveNote")]
</mx:Metadata>

<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;

private function close():void {
PopUpManager.removePopUp(this);
}

private function save():void {
this.dispatchEvent(new Event("SaveNote"));
}
]]>
</mx:Script>

<mx:HTTPService url="http://localhost/../custinfo.php"
id="createCustInfoTab"
method="POST"
resultFormat="e4x"/>

TextInput fields and a btn. which has this included save();

Next the main Application file:

<mx:Script>
<![CDATA[

// Import the ADDNote PopUp.
import com.modContent.popUps.*;

import mx.collections.ArrayCollection;
]]>
</mx:Script>

<mx:Script>
<![CDATA[

import mx.managers.PopUpManager;

[Bindable]
private var notes:ArrayCollection = new ArrayCollection();

private var addNoteScreen:AddNote;

private function init():void {

addNoteScreen = new AddNote();
addNoteScreen.addEventListener("SaveNote", saveNote);
}

private function addNote():void {

PopUpManager.addPopUp(addNoteScreen, this, true);
PopUpManager.centerPopUp(addNoteScreen);

addNoteScreen.firstName.text = "";
addNoteScreen.lastName.text = "";
addNoteScreen.email.text = "";
}

private function saveNote(e:Event):void {

var note:Note = new Note();

note.firstName = addNoteScreen.firstName.text;
note.lastName = addNoteScreen.lastName.text;
note.email = addNoteScreen.email.text;
notes.addItem(note);

PopUpManager.removePopUp(addNoteScreen);
}
]]>
</mx:Script>


<mx:DataGrid dataProvider="{notes}"
id="dg1">

<mx:columns>
<mx:DataGridColumn headerText="First Name" dataField="firstName"
width="140"/>

<mx:DataGridColumn headerText="Last Name" dataField="lastName"
width="140"/>

<mx:DataGridColumn headerText="E-mail" dataField="email"/>
</mx:columns>
</mx:DataGrid>

<mx:HTTPService url="http://localhost/../CustPpPrInfo.php"
id="request"
resultFormat="e4x"
method="POST">
<mx:request>
<firstName>{firstName.text}</firstName>
<lastName>{lastName.text}</lastName>
<email>{email.text}</email>
</mx:request>
</mx:HTTPService>

And here as well TextInput fields and btn etc.
<mx:Form
<mx:FormItem label="First Name">
<mx:TextInput text="{dg1.selectedItem.firstName}"
id="firstName"
color="#000000"/>
</mx:FormItem>
<mx:FormItem label="Last Name">
<mx:TextInput text="{dg1.selectedItem.lastName}"
id="lastName"/>
</mx:FormItem>
<mx:FormItem label="E-mail">
<mx:TextInput text="{dg1.selectedItem.email}"
id="email"/>
</mx:FormItem>
</mx:Form>

</mx:Canvas>