毕业论文 论文提纲 论文写作 公文范例 教育论文 教育学论文 师范教育 学术论文     论文指导*
                     
 
   
   
   
   
           
 

当前位置:课件115学培吧(kj115.com)→flash网侠教程(助你成为顶尖课件高手)→系列文章

 
 
标题:学习Flex几个值得研究的例程代码
 
展示台

文章来源 作者:admin 密码:admin 整理:湖北金鹰

◇网侠教程栏目简介
    提供FLASH侠客教程和网页制作侠客教程,高手进阶教程。
    浏览过这些资源的还浏览过经典教程图文教程游戏开发教程等相关资源。

---------------

湖北金鹰课件吧

论文相关服务
 

 

1.动态创建 DataGrid 列。这个例子是根据XML中的节点值来创建DataGrid中的列,并且还包含了一些对列的属性得设置。
<xml version="1.0" encoding="utf-8">
<!-- This example uses the dataProvider to build the dataGrid columns dynamically -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
creationComplete="initApp()">
<mx:Script><![CDATA[
import mx.controls.dataGridClasses.DataGridColumn;
import mx.controls.DataGrid;
import mx.collections.XMLListCollection;
import mx.controls.Alert;
[Bindable]
private var _xlcCatalog:XMLListCollection; //the dataProvider for the DG
//run by creationComplete
public function initApp():void
{
_xlcCatalog = new XMLListCollection(xmlCatalog.prodUCt); //wrap the XML product nodes in an XMLListCollection
buildDG(); //creates the dataGrid
}//initApp
private function buildDG():void
{
var aColumnDef:Array = getColumnDefArray(); //returns a noraml array of objects that specify DtaGridColumn properties
var oColumnDef:Object;
var dg:DataGrid = new DataGrid; //instantiate a new DataGrid
var dgc:DataGridColumn;
var aColumnsNew:Array = dg.columns
var iTotalDGWidth:int = 0;
for (var i:int=0;i<aColumnDef.length;i++) { //loop over the column definition array
oColumnDef = aColumnDef[i];
dgc = new DataGridColumn(); //instantiate a new DataGridColumn
dgc.dataField = oColumnDef.dataField; //start setting the
properties from the column def array
dgc.width = oColumnDef.width;
iTotalDGWidth += dgc.width; //add up the column widths
dgc.editable = oColumnDef.editable;
dgc.sortable = oColumnDef.sortable
dgc.visible = oColumnDef.visible;
dgc.WordWrap = oColumnDef.wordWrap;
aColumnsNew.push(dgc) //push the new dataGridColumn onto the array

dg.columns = aColumnsNew; //assign the array back to the dtaGrid
dg.editable = true;
dg.width = iTotalDGWidth;
dg.dataProvider = _xlcCatalog; //set the dataProvider
this.addChild(dg); //add the dataGrid to the application
}//buildDG
//uses the first product node to define the columns
private function getColumnDefArray():Array

//Alert.show("colcount:" + xmlCatalog.toXMLString());
var aColumns:Array = new Array();
var node0:XML = xmlCatalog.product[0]; //get the first "product" node
var xlColumns:XMLList = node0.children(); //get its child nodes (columns) as an XMLList
var xmlColumn:XML
var oColumnDef:Object;
for (var i:int=0;i<xlColumns.length();i++) { //loop over the xmlList
xmlColumn = xlColumns[i];
oColumnDef = new Object();
oColumnDef.dataField = xmlColumn.localName(); //make the dataField be the node name
switch (oColumnDef.dataField) { //conditional column
property logic
case "name":
oColumnDef.width = 80;
oColumnDef.sortable = false;
oColumnDef.visible = true;
oColumnDef.editable = false;
oColumnDef.wordWrap = false;
break;
case "description":
oColumnDef.width = 200;
oColumnDef.sortable = false;
oColumnDef.visible = true;
oColumnDef.editable = false;
oColumnDef.wordWrap = true;
break;
case "price":
oColumnDef.width = 40;
oColumnDef.sortable = true;
oColumnDef.visible = true;
oColumnDef.editable = true;
oColumnDef.wordWrap = false;
break;
case "image":
oColumnDef.width = 100;
oColumnDef.sortable = false;
oColumnDef.visible = false;
oColumnDef.editable = false;
oColumnDef.wordWrap = false;
break;
default:
oColumnDef.width = 50;
oColumnDef.sortable = true;
oColumnDef.visible = true;
oColumnDef.editable = false;
oColumnDef.wordWrap = false;
break;
}
aColumns.push(oColumnDef);

return aColumns; //return the array
}//getColumnDefArray
]]></mx:Script>
<mx:XML id="xmlCatalog">
<catalog>
<product productId="1">
<name>Nokia 6010</name>
<description>Easy to use without sacrificing style, the Nokia 6010 phone offers functional voice communication supported by text messaging, multimedia messaging, mobile internet, games and more</description>
<price>99.99</price>
<image>assets/pic/Nokia_6010.gif</image>
<series>6000</series>
<triband>false</triband>
<camera>false</camera>
<video>false</video>
<highlight1>MMS</highlight1>
<highlight2>Large color display</highlight2>
</product>
<product productId="2">
<name>Nokia 3100 Blue</name>
<description>Light up the night with a glow-in-the-dark cover - when it's charged with light you can easily find your phone in the dark. When you get a call, the Nokia 3100 phone Flashes in tune with your ringing tone. And when you snap on a Nokia xpress-on gaming cover*, you'll get luminescent light effects in time to the gaming action.</description>
<price>139</price>
<image>assets/pic/Nokia_3100_blue.gif</image>
<series>3000</series>
<triband>true</triband>
<camera>false</camera>
<video>false</video>
<highlight1>Glow-in-the-dark</highlight1>
<highlight2>Flashing lights</highlight2>
</product>
<product productId="3">
<name>Nokia 3100 Pink</name>
<description>Light up the night with a glow-in-the-dark cover - when it's charged with light you can easily find your phone in the dark. When you get a call, the Nokia 3100 phone flashes in tune with your ringing tone. And when you snap on a Nokia Xpress-on gaming cover*, you'll get luminescent light effects in time to the gaming action.</description>
<price>139</price>
<image>assets/pic/Nokia_3100_pink.gif</image>
<series>3000</series>
<triband>true</triband>
<camera>false</camera>
<video>false</video>
<highlight1>Glow-in-the-dark</highlight1>
<highlight2>Flashing lights</highlight2>
</product>
<product productId="4">
<name>Nokia 3120</name>
<description>Designed for both business and pleasure, the elegant Nokia 3120 phone offers a pleasing mix of features. Enclosed within its chic, compact body, you will discover the benefits of tri-band compatibility, a color screen, MMS, XHtml browsing, cheerful screensavers, and much more.</description>
<price>159.99</price>
<image>assets/pic/Nokia_3120.gif</image>
<series>3000</series>
<triband>true</triband>
<camera>false</camera>
<video>false</video>
<highlight1>Multimedia messaging</highlight1>
<highlight2>Animated screensavers</highlight2>
</product>
<product productId="5">
<name>Nokia 3220</name>
<description>The Nokia 3220 phone is a fresh new cut on some familiar ideas - animate your MMS messages with cute characters, see the music with lights that flash in time with your ringing tone, download wallpapers and screensavers with matching color schemes for the interface.</description>
<price>159.99</price>
<image>assets/pic/Nokia_3220.gif</image>
<series>3000</series>
<triband>false</triband>
<camera>true</camera>
<video>false</video>
<highlight1>MIDI tones</highlight1>
<highlight2>Cut-out covers</highlight2>
</product>
</catalog>
</mx:XML>
</mx:Application>
2.在 Tree 中查找节点。在对话框中输入要查找的节点的值。
<xml version="1.0" encoding="utf-8">
<!-- Searchable Tree control example. uses e4x expression to find a node with matching id attribute-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()">
<mx:Script><![CDATA[
[Bindable]
public var _xmlData:XML;

public function initApp():void
{
_xmlData = <element eid="hello">
<element eid="world">
<element eid="123"/>
<element eid="graham"/>
<element eid="weldon">
<element eid="Office">
<element eid="thing"/>
<element eid="boat"/>
<element eid="chair"/>
</element>
<element eid="person"/>
</element>
</element>
</element> ;
trace("test")
}//initapp
//starts at the given node, walks up the tree opening nodes as it goes
private function expandParents(xmlNode:XML):void
{
while (xmlNode.parent() != null) {
xmlNode = xmlNode.parent();
myTree.expandItem(xmlNode,true, false);
}
}//expandParents
//uses e4x to find a node, then calls expand parents to make it visible,
//then selects it
private function findNodeById(sId:String):void

var xmllistDescendants:XMLList = _xmlData.descendants().(@eid == sId);
expandParents(xmllistDescendants[0]);
myTree.selectedItem = xmllistDescendants[0];
}//findNodeById
]]></mx:Script>
<mx:Panel title="Tree Control Example" height="75%" width="75%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:HBox>
<mx:TextInput id="tiId" text="boat" />
<mx:Button label="Find" click="findNodeById(tiId.text)" />
</mx:HBox>
<mx:Tree id="myTree" width="50%" height="100%" labelField="@eid"
showRoot="false" dataProvider="{_xmlData}" />
</mx:Panel>
</mx:Application>
3.动态显示/隐藏 DataGrid 的列。在List中选中一个就会显示相应的 DataGrid 的列。
<xml version="1.0" encoding="utf-8">
<mx:Application xmlns:mx=">http://www.adobe.com/2006/mxml" layout="horizontal" horizontalAlign="left"
creationComplete="initApp()">
<mx:Script><![CDATA[
import mx.controls.dataGridClasses.DataGridColumn;
//import mx.controls.DataGrid;
import mx.collections.XMLListCollection;
[Bindable]
private var _xlcCatalog:XMLListCollection; //the dataProvider for the DG
//run by creationComplete
public function initApp():void
{
_xlcCatalog = new XMLListCollection(xmlCatalog.product); //wrap the XML product nodes in an XMLListCollection
lstColumns.selectedItems = new Array(dgHideShow.columns[0]); //set the column list dataProvider to the DataGridColumns
}//initApp
private function hideShowColumns():void {
var aColumns:Array = dgHideShow.columns;
var aSelectedColumns:Array = lstColumns.selectedItems;
var dgc:DataGridColumn;
var sDataField:String;
var sDataFieldCur:String;
var bFound:Boolean
for (var i:int=0;i<aColumns.length;i++) {
bFound = false
dgc = aColumns[i];
sDataField = dgc.dataField;
for (var j:int=0;j<aSelectedColumns.length;j++) {
sDataFieldCur = aSelectedColumns[j].dataField;
if (sDataFieldCur == sDataField) {
bFound = true;
break;
}
}//for (var j:
if (bFound) {
dgc.visible = true;
}
else {
dgc.visible = false;
}
}// for (var i:
}//
]]></mx:Script>
<mx:VBox>
<mx:Label text="Multi-Select" />
<mx:Label text="Columns" />
<mx:List id="lstColumns" dataProvider="{dgHideShow.columns}"
labelField="dataField"
allowMultipleSelection="true"
click="hideShowColumns()" />
</mx:VBox>
<mx:DataGrid id="dgHideShow" dataProvider="{_xlcCatalog}" rowCount="6" >
<mx:columns>
<mx:Array>
<mx:DataGridColumn headerText="Product" dataField="name" visible="true" />
<mx:DataGridColumn headerText="Description" dataField="description" visible="false" />
<mx:DataGridColumn headerText="Price" dataField="price" visible="false" />
<mx:DataGridColumn headerText="Series" dataField="series" visible="false" />
<mx:DataGridColumn headerText="Tri-Band" dataField="triband" visible="false" />
<mx:DataGridColumn headerText="Camera" dataField="camera" visible="false" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
<mx:XML id="xmlCatalog">
<catalog>
<product productId="1">
<name>Nokia 6010</name>
<description>Easy to use without sacrificing style, the Nokia 6010 phone offers functional voice communication supported by text messaging, multimedia messaging, mobile internet, games and more</description>
<price>99.99</price>
<image>assets/pic/Nokia_6010.gif</image>
<series>6000</series>
<triband>false</triband>
<camera>false</camera>
<video>false</video>
<highlight1>MMS</highlight1>
<highlight2>Large color display</highlight2>
</product>
<product productId="2">
<name>Nokia 3100 Blue</name>
<description>Light up the night with a glow-in-the-dark cover - when it's charged with light you can easily find your phone in the dark. When you get a call, the Nokia 3100 phone flashes in tune with your ringing tone. And when you snap on a Nokia Xpress-on gaming cover*, you'll get luminescent light effects in time to the gaming action.</description>
<price>139</price>
<image>assets/pic/Nokia_3100_blue.gif</image>
<series>3000</series>
<triband>true</triband>
<camera>false</camera>
<video>false</video>
<highlight1>Glow-in-the-dark</highlight1>
<highlight2>Flashing lights</highlight2>
</product>
<product productId="3">
<name>Nokia 3100 Pink</name>
<description>Light up the night with a glow-in-the-dark cover - when it's charged with light you can easily find your phone in the dark. When you get a call, the Nokia 3100 phone flashes in tune with your ringing tone. And when you snap on a Nokia Xpress-on gaming cover*, you'll get luminescent light effects in time to the gaming action.</description>
<price>139</price>
<image>assets/pic/Nokia_3100_pink.gif</image>
<series>3000</series>
<triband>true</triband>
<camera>false</camera>
<video>false</video>
<highlight1>Glow-in-the-dark</highlight1>
<highlight2>Flashing lights</highlight2>
</product>
<product productId="4">
<name>Nokia 3120</name>
<description>Designed for both business and pleasure, the elegant Nokia 3120 phone offers a pleasing mix of features. Enclosed within its chic, compact body, you will discover the benefits of tri-band compatibility, a color screen, MMS, XHTML browsing, cheerful screensavers, and much more.</description>
<price>159.99</price>
<image>assets/pic/Nokia_3120.gif</image>
<series>3000</series>
<triband>true</triband>
<camera>false</camera>
<video>false</video>
<highlight1>Multimedia messaging</highlight1>
<highlight2>Animated screensavers</highlight2>
</product>
<product productId="5">
<name>Nokia 3220</name>
<description>The Nokia 3220 phone is a fresh new cut on some familiar ideas - animate your MMS messages with cute characters, see the music with lights that flash in time with your ringing tone, download wallpapers and screensavers with matching color schemes for the interface.</description>
<price>159.99</price>
<image>assets/pic/Nokia_3220.gif</image>
<series>3000</series>
<triband>false</triband>
<camera>true</camera>
<video>false</video>
<highlight1>MIDI tones</highlight1>
<highlight2>Cut-out covers</highlight2>
</product>
</catalog>
</mx:XML>
</mx:Application>

 

 
课件115学培吧(湖北金鹰)欢迎您!永久免费服务网址:http://www.kj115.com
   
 

学员众多的FLASH课件学习基地,成万免费FLASH课件制作教程在线学习,还有免费内容课件教程、视频教程、课件技巧、课件探讨、课件欣赏、课件展示、实用教程、课件界面、课件脚本、课件游戏、课件下载、课件封面、课文内容图片、课文人物图片库、课件素材、图片素材、声音素材、动物素材、背景图片、背景资料、背景边框、课件顶栏图片素材、Dreamweaver教程、Dreamweaver网页课件教程、软件下载。承接学习和培训,承接课件订制,课件修改等所有课件相关服务。
本站主要业务:┃flash课件制作视频教程培训┃承接全国竞赛flash课件┃论文代写代发┃代办课件国家级获奖证书┃
联系:QQ:444860709 手机:13339817386


 
 

业务办理
鄂ICP备08005724号