开发者

dynamically populating textfields in Flashbuilder

I'm trying to wrap my brain around getting data into my project in a way that I can use. I want to use MySQL & PHP my Flashbuilder app and I'm not populating a datagrid so.

For simplicities sake, in my database table I have 3 columns "ID, Title & Content".

I want to use this to populate the different states in my flashbuilder project.

Normally in a web page I could say in the sql statement SELECT * FROM table WHERE ID = 1 to get the firs开发者_运维知识库t row of info and I could put my Title and Content where I want them on my page

I can change the query to SELECT * FROM table WHERE ID = 2 to populate page 2 to get it's title and content.

In flashbuilder it all on the same page and I'm not understanding how to populate a singular text field for a title or content area with a single field from the database.

It seems all the examples on the web are basically for datagrids.

Can someone please help me out?


I'll try to help.

You have the database table (ID, Title, Content).

Go ahead and create a web service in PHP that will ping the database and retrieve the data. I don't know much about PHP, so can't help with specifics. If possible, I recommend using something like AMFPHP or ZendAMF to transfer data back and forth between Flex and PHP.

In Flex, you can retrieve the data using RemoteObject, WebService, or HTTPService. You'll get the data back somehow. For the purposes of this sample, I'll assume you're using a form of AMF and have an array of value objects.

Each object contains an ID, title, and content property, representing a single row in your database table.

Now, what do you do with that array? It would be odd to try to display a collection of data in a single text input. Let's pretend you want to create a form to edit the first item:

    <Form>
<formItem label="title">
 <textInput id="titleInput" text="{resultsFromPHP[0].title}" />
</formitem>
<formItem label="content">
 <textInput id="contentInput" text="{resultsFromPHP[0].content}" />
</formitem>
<formItem >
 <button label="Process Input" click="processInput()" />
</formitem>
</form>

So, you have a form that allows for inputs, and has a button. Just write the click handler:

protected function processInput():void{
 resultsFromPHP[0].content = contentInput.text
 resultsFromPHP[0].title = titleInput.text
 // call other PHP Service to update data
}

Does that help?

This was psuedo code I wrote in the browser and will most likely need tweaking to compile.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜