- 浏览: 589658 次
- 性别:
- 来自: 武汉
文章分类
最新评论
-
liuhuo:
总算找到一个可用的了,非常感谢楼主!其他的都不靠谱啊
Flex与Javascript相互调用例子(附源码) -
Array_06:
你好,请问,一个今年7月拿大学毕业证,应届生,大专学历,做Ja ...
为什么程序员得到的报酬与他们的生产力不成正比 -
778856:
sam_kee 写道晕了哦,我想知道快捷键本来默认就是没有快捷 ...
利用eclipse(MyEclipse)快速生成set、get方法的方法 -
hhsc00:
你真对不起老鸟这个称号……
坑爹的360(不吐不快) -
white_crucifix:
somewhater 写道我还以为去360工作去了呢。。。。。 ...
坑爹的360(不吐不快)
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>
发表评论
-
减少SWF文件大小方法——FLEX 3实用技巧
2011-02-23 18:15 1826目前的Flash使用已经非常普及,而在应用的Fla ... -
高效率的超大规模Flex开发
2010-06-09 09:14 1406Adobe Flex开发与传统的Web开发有很多不同之处。 ... -
Flex与Javascript相互调用例子(附源码)
2010-01-18 17:48 3115代码为本人亲测,部分解释内容为网站搜集而来。源码在附件中。 ... -
Flex 最佳做法 - 开发做法
2009-10-22 19:18 1802处理资源 Flex 应用程序通常会并入一组文件, 包括图像、 ... -
发一个本人初学Flex时整的一个Flex整合Web应用的小视频
2009-04-16 14:39 2251主要是防止时间久不弄了,把操作步骤给忘记了!
相关推荐
综上所述,"基于S32KDS平台SDK3.0编写的flexcan组件can fd测试例程"涵盖了FlexCAN模块的配置、初始化、数据传输、错误处理等多个方面,是学习和评估S32K微控制器在CAN FD通信能力上的理想实践。通过运行和分析这个...
Adobe Flex是一种基于MXML...通过深入研究这个压缩包中的源码,初学者不仅可以了解Flex的基本概念,还能掌握实际应用中的编程技巧。同时,这也有助于理解富互联网应用程序的开发流程,为今后的Flex项目打下坚实的基础。
《学习openCV书》中的所有例程代码,方便大家学习
ti官方的MSP430例程代码,对初学者很有用。MSP430单片机称之为混合信号处理器,是由于其针对实际应用需求,将多个不同功能的模拟电路、数字电路模块和微处理器集成在一个芯片上,以提供"单片机"解决方案。该系列...
通过研究这些经典应例程代码,开发者可以学习到如何有效利用瑞萨MCU的特性,提高代码效率,解决实际问题,并且避免常见错误,从而提升开发速度和产品质量。同时,这些代码也可以作为模板,为新的项目提供基础和灵感...
"STM32L4x系列官方软件例程代码(超全、代码)"是一个宝贵的资源,包含了官方提供的各种示例代码,帮助开发者理解和应用STM32L4x的各个外设功能。 这些示例代码通常按照功能模块进行分类,例如: 1. ADC(模拟数字...
【实验06】1位数码管显示方式2.zip源码arduino例程源码GL9例程源代码【实验06】1位数码管显示方式2.zip源码arduino例程源码GL9例程源代码【实验06】1位数码管显示方式2.zip源码arduino例程源码GL9例程源代码【实验06...
在学习芯片代码时,你需要掌握以下几个核心概念: 1. **微控制器基础**:了解微控制器的基本架构,包括CPU、内存、输入/输出接口等。理解它们如何协同工作来执行程序。 2. **汇编语言**:虽然高级语言在很多情况下...
本开发参考例程代码集合涵盖了多个关键功能模块的实现,帮助开发者快速理解和上手STM32F103C8T6的编程。 1. **ADC(模拟数字转换器)**:STM32F103C8T6内建多个ADC通道,用于将模拟信号转换为数字值。例程中会展示...
"黑金FPGA开发板例程代码"是一个针对黑金品牌的FPGA开发板提供的Verilog语言编程示例和配套文档。这个资源对于学习和实践FPGA设计,特别是使用Verilog语言的初学者或是专业人士来说非常有价值。下面我们将深入探讨这...
【LPC210X例程代码】是一个与微控制器相关的资源包,主要针对NXP公司的LPC210X系列芯片。这个系列是基于ARM7TDMI内核的超低功耗微控制器,广泛应用于嵌入式系统设计。本例程集是力天电子为配合其LPC210X视频教程而...
**msp430学习LT-1B学习板原理图及例程代码** 本文将深入探讨“msp430学习LT-1B学习板”的相关知识,包括其硬件设计原理图和配套的例程代码,帮助读者更好地理解和使用这款学习工具。 **一、msp430简介** msp430是...
例程15-数码管.zip源码arduino例程代码元器件资料源码下载例程15-数码管.zip源码arduino例程代码元器件资料源码下载例程15-数码管.zip源码arduino例程代码元器件资料源码下载例程15-数码管.zip源码arduino例程代码元...
这个压缩包包含了255个欧母龙PLC的例程代码,为学习者和工程师提供了丰富的参考资料。 PLC例程代码是用于控制PLC运行的程序,由梯形图、指令表、结构文本等编程语言编写。这些例程涵盖了各种常见的工业应用,如电机...
[113]VC编写的一个WinSocket及串口通信的例程代码.zip上位机开发VC串口学习资料源码下载[113]VC编写的一个WinSocket及串口通信的例程代码.zip上位机开发VC串口学习资料源码下载[113]VC编写的一个WinSocket及串口通信...
例程5-交通灯.zip源码arduino例程代码元器件资料源码下载例程5-交通灯.zip源码arduino例程代码元器件资料源码下载例程5-交通灯.zip源码arduino例程代码元器件资料源码下载例程5-交通灯.zip源码arduino例程代码元器件...
例程2-LED 闪烁.zip源码arduino例程代码元器件资料源码下载例程2-LED 闪烁.zip源码arduino例程代码元器件资料源码下载例程2-LED 闪烁.zip源码arduino例程代码元器件资料源码下载例程2-LED 闪烁.zip源码arduino例程...
例程4-广告灯.zip源码arduino例程代码元器件资料源码下载例程4-广告灯.zip源码arduino例程代码元器件资料源码下载例程4-广告灯.zip源码arduino例程代码元器件资料源码下载例程4-广告灯.zip源码arduino例程代码元器件...
例程6-按键控制.zip源码arduino例程代码元器件资料源码下载例程6-按键控制.zip源码arduino例程代码元器件资料源码下载例程6-按键控制.zip源码arduino例程代码元器件资料源码下载例程6-按键控制.zip源码arduino例程...
例程7-抢答器.zip源码arduino例程代码元器件资料源码下载例程7-抢答器.zip源码arduino例程代码元器件资料源码下载例程7-抢答器.zip源码arduino例程代码元器件资料源码下载例程7-抢答器.zip源码arduino例程代码元器件...