background image

18

XUpdate Tutorial: Update the Timesheet (Flash Professional Only)

Update the timesheet

1.

Begin with the file you created in the “XML Tutorial: Timesheet (Flash Professional Only)”

2.

Drag an XUpdateResolver component to the Stage, and in the Property inspector enter the 
instance name 

timeInfo_rs

.

3.

Click the Schema tab in the Component inspector, and select the 

deltaPacket

 component 

property within the Schema Tree pane.

4.

Change the DeltaPacket component’s encoder setting to DataSetDeltaToXUpdateDelta. 

This encoder converts data within the DeltaPacket into XPath statements that are supplied to 
the XUpdateResolver component, but it needs additional information from you to do its job.

5.

Double-click the 

encoder options

 property. When prompted for a value for the 

rowNodeKey

 

property, type 

datapacket/row[@id='?id']

.

This property identifies which node within the XML file will be treated as a record within the 
data set. It also defines which element or attribute combination makes the row node unique, as 
well as the schema field within the DataSet component that will represent it. See 
“DataSetDeltaToXUpdateDelta encoder” in the “Data Integration” chapter of 

Using Flash

 

(in Flash, select Help > Using Flash).

In the sample XML file, the 

id

 attribute of the datapacket/row node is the unique identifier, 

and it will be mapped to the DataSet component’s ID schema field. This is defined with the 
following expression:

datapacket/row[@id=’?id’]

6.

In the Component inspector, click the Bindings tab. Add a binding from the XUpdateResolver 
component’s 

deltaPacket

 property to the DataSet component’s 

deltaPacket

 property. This 

binding will copy the DeltaPacket component to the XUpdateResolver component so that it 
can be manipulated before it is sent to the server. 

Note: 

The data is copied after the DataSet component’s 

applyUpdates()

 method is called.

7.

Drag a TextArea component to the Stage, and in the Property inspector enter the instance name 

deltaText

. Select the component, and then in the Component inspector, click the Bindings tab. 

Add a binding from the TextArea component’s 

text

 property to the XUpdateResolver 

component’s 

xupdatePacket

 property. The update packet contains the modified version of the 

DeltaPacket that will be sent to the server.

8.

Drag a Button component onto the Stage, and in the Property inspector enter the instance 
name 

btn_show

. In the Component inspector, click the Parameters tab and change the label to 

Show Updates.

9.

With the button selected, open the Actions panel (F9) and enter the following code: 

on (click) {

_parent.timeInfo_ds.applyUpdates();

}

10.

Test the application (Control > Test Movie). Load the data and make a change to one or more 
fields in multiple records.

Содержание FLASH MX 2004-DATA

Страница 1: ...Data Tutorials...

Страница 2: ...his guide then you do so at your own risk Macromedia provides these links only as a convenience and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for...

Страница 3: ...to a public web service 5 Create a user interface and bind the components with the web service 7 XML Tutorial Timesheet Flash Professional Only 11 Create the user interface 12 Edit the data 16 XUpdate...

Страница 4: ...4 Contents...

Страница 5: ...blic web services directly from within any client side application For more information see About data connectivity and security in Flash Player in the Data Integration chapter in Using Flash in Flash...

Страница 6: ...service has one method called getTipByProduct This method accepts a single parameter called product The parameter is a string that tells the web service what Macromedia product you want to see a tip f...

Страница 7: ...omponents panel select UI components ComboBox Drag a ComboBox component to the Stage In the Property inspector enter the instance name products_cb 2 In the Components panel select UI components Button...

Страница 8: ...s Now add a binding for the WebService connector component from the Macromedia Tip service to ComboBox component that allows the user to choose a product and return a tip about the product 7 Select th...

Страница 9: ...will bind the results parameter in the web service connector to the TextArea component on the Stage 9 In the Component inspector click the Add Binding button again In the Add Binding dialog box selec...

Страница 10: ...the items in the ComboBox instance to the contents of the array products_cb dataProvider Flash Dreamweaver Note If necessary you can use the setStyle method to change the color of the Label instance t...

Страница 11: ...use of a public web service in this tutorial does not imply that you should use one for real world applications In fact Macromedia does not recommend using public web services directly from within any...

Страница 12: ...nce name timeInfo_ds 5 On the Stage select the XMLConnector component In the Component inspector click the Schema tab Select the results XML property then click the Import a Schema from a Sample XML F...

Страница 13: ...ld and change it to Date This tells the DataBinding component to try to work with this value as a date For more information on data binding and data types see Schema data types in the Data binding sec...

Страница 14: ...hema field and change it to Number so that it is not limited to integer values 15 In the Component inspector click the Bindings tab and create a binding between the row array and the DataSet component...

Страница 15: ...operty inspector enter the instance name timeInfo_grd 24 In the Component inspector click the Bindings tab Create a binding between the DataGrid component s dataProvider property and the DataSet compo...

Страница 16: ...dify the application so that you can edit data through the DataGrid component 1 On the Stage select the DataGrid component Then click the Parameters tab in the Component inspector 2 Set the editable p...

Страница 17: ...ions but will work in the Flash authoring environment or Flash Player Note The use of a public web service in this tutorial in no way implies that you should use one for real world applications In fac...

Страница 18: ...ute of the datapacket row node is the unique identifier and it will be mapped to the DataSet component s ID schema field This is defined with the following expression datapacket row id id 6 In the Com...

Страница 19: ...ketInfo parameter of the XUpdateResolver component to true using the Component inspector Note Additional information is added to the update packet This information can be used by the server to uniquel...

Страница 20: ...20 XUpdate Tutorial Update the Timesheet Flash Professional Only...

Отзывы: