????????????????????????ultrashock???????????http://www.ultrashock.com/tutorials/flashmx2004/databinding.php
?????????????????????????????,????!
????????:http://www.webstudio.com.cn/forum/showthread.php?p=86#post86
????...
????????????????????????????????????Flash???????????????????????????????????????????????ActionScript???????????????ActionScript?????????????AS????????????AS?????????????????????????????????????????????????????????????????????????????Flash??????????????????????????????
????????????
???????????????Flash???????????????????FlashMX????????????????????????????????——?????????????????????????????UI?user interface???????????????????????????????????????????AS??????XML???????????????“??”?????????????????????RAD???????????????????
????point-and-click?????????????????????????API???????????????????????????????????????????????????????Data Binding Classes?????Flash???????
??——????——???——???????????????????????????????????????????????????????????
????????????????????????????
??????
???????????????????????????????????????????????????????????????????????“????”??????????
???? ??????????
??????????? ???????????
?????
????????????????????????????????????????????CheckBox?????????????
????????????????????????????????????????
1? ??????????????????????????checkBox1?checkBox2 ?
2? ???????“??”???????checkBox1????????????????????????
3? ?? ??????“????”???
4? ??????????checkBox?selected?????????“selected?Boolean”???????“OK”;
5? ?????????????????????????????????????????“bound to”??????(??“???”????)?????“????”checkBox2?“????” selected?????????????
6? ???????????
????????????????????????????????????“??”?????????????????????????????????????????????????——???????????????????“selected”???????????????????????CheckBoxes.fla
??
?????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????“??”?????????????????
??????????????1????????????2????????????????????????????????????????????????????
1? ??????1?????????????????????????????? ???
2? ??????“checkBox2”?????????? ????????
3? ???????????????????????????????????????“field name”???“enabled”?“data type”???“Boolean”?
4? ???????????????????????????1?“selected”???????2?“enabled”?????????
??????????????XML??
??????????????????????XML?????????????????????????????XML?????????XML????????????XMLConnector???
???????????????????XML??????????????????????XML???????????????XML??????????XML?????
| ´úÂë: | | <menu>
<menu-title label="file">
<menu-item label="load" />
<menu-item label="save" />
<menu-item label="print" />
</menu-title>
<menu-title label="edit">
<menu-item label="cut" />
<menu-item label="copy" />
<menu-item label="paste" />
<menu-item label="sub-menu">
<menu-item label="nothing here" />
</menu-item>
</menu-title>
</menu>
| |
xmlMenu.swf????
??
?????????????????????XMLConnector????????????????????????XML???
1? ????????????????????Menu???XMLConnector????????????menuBar?xmlConnector?????XMLConnector?????????????????????????
2? ????????XMLConnector?????????????????????????????????
menu.xml?XML????????direction?????receive??????????XML???
3? ??????????????????????XMLConnector?????XML???????????XMLConnector?????????????????????????
4? ????????“results”????????????????[IMAGES]http://www.ultrashock.com/tutorials/flashmx2004/images-databinding/import_schema_button.gif[IMAGES] ??????XML?????????“menu.xml”????????????????????????????
?????????????XML??????Flash?????????????????Flash????????“true”??“1”??????Boolean? Number?????????????????????
5? ?? menuBar????????????????menuBar???????????????????
6? ?????????????????2??????
?????????????
7? ?????????????XML??????????????????
xmlConnector.trigger();
8? ??????
?????
??????????????????????????????????List???DataGrid???ComboBox???????Flash?????XML???????????????????????????????????????????????
????????????
selectIndex.swf???????
??
??????????XML ???
| ´úÂë: | | <chores title="House Work Rota">
<day label="monday">
<job description="dishes" person="john" time="15 mins" />
<job description="cooking" person="sam" time="1 hour" />
<job description="walking dog" person="david" time="30 mins" />
<job description="laying the table" person="peter" time="5 mins" />
<job description="slacking off" person="elisabeth" time="all day" />
</day>
<day label="tuesday">
<job description="dishes" person="david" time="25 mins" />
<job description="cooking" person="peter" time="1 hour" />
<job description="walking dog" person="sam" time="20 mins" />
<job description="laying the table" person="john" time="15 mins" />
<job description="slacking off" person="elisabeth" time="all day" />
</day>
<day label="wednesday">
<job description="dishes" person="sam" time="20 mins" />
<job description="cooking" person="david" time="1 hour" />
<job description="walking dog" person="peter" time="30 mins" />
<job description="laying the table" person="john" time="15 mins" />
<job description="slacking off" person="elisabeth" time="all day" />
</day>
<day label="thursday">
<job description="dishes" person="peter" time="3 hours" />
<job description="cooking" person="john" time="1 hour" />
<job description="walking dog" person="david" time="30 mins" />
<job description="laying the table" person="sam" time="10 mins" />
<job description="slacking off" person="elisabeth" time="all day" />
</day>
<day label="friday">
<job description="dishes" person="sam" time="20 mins" />
<job description="cooking" person="sam" time="1 hour" />
<job description="walking dog" person="peter" time="20 mins" />
<job description="laying the table" person="sam" time="5 mins" />
<job description="slacking off" person="elisabeth" time="all day" />
</day>
<day label="saturday">
<job description="dishes" person="john" time="1 hour" />
<job description="cooking" person="john" time="1 hour" />
<job description="walking dog" person="david" time="30 mins" />
<job description="clean car" person="sam" time="30 mins" />
<job description="laying the table" person="david" time="10 mins" />
<job description="slacking off" person="elisabeth" time="all day" />
</day>
<day label="sunday">
<job description="dishes" person="peter" time="20 mins" />
<job description="cooking" person="david" time="1 hour" />
<job description="walking dog" person="peter" time="20 mins" />
<job description="laying the table" person="john" time="5 mins" />
<job description="slacking off" person="elisabeth" time="all day" />
</day>
</chores>
| |
???????????
???????XML???????????XMLConnector???????????????????????????????????“chores2.xml”——???????results?????????????????????????????comboBox??????XML???——???????????????????????????comboBox?????????????????????????“???”????????????
??comboBox????????XML????
1???comboBox?????????
2??????????????????????
3??????????????????
4???“Bound To”????XMLConnector??????????????day:Array
??????????????DataGrid???XML????????????????????——???????????????????XML???Flash???XML?????????????????????“????”day????????“????”job??????????????????????????????day????N????job??????????????????XMLConnector?????DataGrid?????dataProvider????job?????
????????????job??????????XML?????????7???——????????N???????Flash???N??????????
1? ????XMLConnector????????
2? ???job???dataGrid???????——results.chores.day.[n].job?????????????Index for ‘day’?????????????????day???????????????????????????comboBox??????????????????????????????????????????comboBox?????selectedIndex??????????????????????——??Index for ‘day’?????????????????????????????“????”ComboBox?“????”selectedIndex:Number???
3? ????????
???
?????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????AS2?????????????????????????????????????????????????
?????????????
Boolean?????
????????????????????????????????????????????????????????——????????
Bool_formatter.swf??
Compose String???????
???????????????????????????????????????????????????????????????????????????????????”<>”?????????????????????????????XML???????????——?????????????????????????
Compose_formatter.swf??
Date????
????????????????“MM/DD/YYYY”??????“M”(??)?“D”?????“Y”?????“H”?????“N”?????“S”????????????????????????????????????????????????
Date_formatter.swf??
Number (??)
??????????????????????
Number_formatter.swf??
Rearrange Fields (??????)
????????????????????????????????????????????????????????????????????????”label=name;data=colour;otherField=yetAnotherField”??????????????????????????????????????????????????????????????????????????XML??????????????????????????????????????????
Rearrange_formatter.swf??
Custom Formatter????????
?????????????????????????????????????????????????????????????????????????????
| ´úÂë: | | // class used to convert numbers to sterling currency and back again
class SterlingFormatter {
// turns a number into a string
function format (data:Number) : String{
var currency:String;
var pounds:Number = Math.floor(data);
var pence:Number = Math.round((data - pounds)*100);
var poundsStr:String = String(pounds);
var penceStr:String;
if(pence<10){
penceStr = "0" + String(pence);
}else{
penceStr = String(pence);
}
currency = "£" + pounds + "." + penceStr;
return currency;
}
// removes sterling format and returns a number
function unformat (data:String) : Number {
var str:String = data.substr(1);
var num:Number = parseFloat(str);
return num;
}
}
| |
??????????????????????
Custom_formatter.swf??
????????
???????????mc????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????mc??????????????mc???“???”???????mc???????????mc?????????????????????????????????????????????????
1? ??????mc????????????????????????????
2? ?????????“??”?????????????“????”??mc????????
3? ???????????????????????????????????????????????mc??????????????????????????
4? ??????????????????????? _level?????target?
?????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????“??”??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??
?????MX2004??????????????????????????????API??????????????????????——????????????????????????????????
?????????????????????????????????????API??????????????????????????????????????????????????????????????????AS2???????????????
????????:http://www.webstudio.com.cn/forum/showthread.php?p=86#post86 |