Flex个人知识库(5)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/JAVAZHICHIZHE/article/details/83770949
1、关于DataGrid的自动刷新
当修改dataGrid数据时(即修改数据源dataProvider)要实现DataGrid的自动刷新有两部:
A、 将数据源设置为绑定,也即以关键字[Bindable]声明
B、 设置绑定以后,当你修改数据时,datagrid实例并不会显示新的数据,除非你手动的鼠标点击一下datagrid才会显示。有如下方法可以解决:
.invalidateList()刷新datagrid的每一行
.invalidateNow()在datagrid的属性(大小、位置等发生改变时),进行刷新。

2、 ComboBox中change事件与close事件的区别

如果用户更改了下拉列表的选项,ComboBox的selectedIndex与selectedItem都会随之改变。

change: 当comboBox内容因用户交互操作发生更改时,当selectedIndex或selectedItem属性更改时,以及如果comboBox控件可编辑,每次在框中击键时调用

close: 取消下拉列表时调度,如果用户选择某一下拉列表中的某个项目,在下拉列表外部店家,在显示下拉列表时单击下拉框或者在下拉框状态时按Esc

注意: 就我个人的使用来看发现当更改comboBox的selectedIndex与selectedItem时会出发change事件,而发现有网友博文中提到如下观点:

由编程改变selectedIndiex和selectedItem属性时触发的是valueCommit时间,而通过UI操作触发的是change和changing事件。
... ...

3、 自定义的一个Alert框
<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" width="100%" height="100%"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="300" minHeight="150" maxHeight="500" maxWidth="450"
styleName="CloudAlert" borderVisible="false">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>

<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";

.CloudAlert
{
background-image: Embed("/assets/images/alert/background_image.png", scaleGridTop="29", scaleGridBottom="113", scaleGridLeft="48", scaleGridRight="231");
background-size: "100%";
}
.CloudAlertCloseButton
{
upSkin:Embed(source='/assets/images/alert/closebutton_up_skin.png', scaleGridLeft=10, scaleGridRight=11, scaleGridTop=10,scaleGridBottom=11);
downSkin:Embed(source='/assets/images/alert/closebutton_down_skin.png', scaleGridLeft=10, scaleGridRight=11, scaleGridTop=10,scaleGridBottom=11);
overSkin:Embed(source='/assets/images/alert/closebutton_over_skin.png', scaleGridLeft=10, scaleGridRight=11, scaleGridTop=10,scaleGridBottom=11);
}
.CloudAlertTitle
{
font-size: 12;
font-weight: bold;
color: #333333;
}

.CloudAlertSubtitle
{
font-size: 14;
font-weight: bold;
color: #0b8ff4;
}

.AlternativeButton
{
up-skin: Embed("/assets/images/alert/up_skin.png", scaleGridTop="5", scaleGridBottom="13", scaleGridLeft="5", scaleGridRight="12");
over-skin: Embed("/assets/images/alert/over_skin.png", scaleGridTop="5", scaleGridBottom="13", scaleGridLeft="5", scaleGridRight="12");
down-skin: Embed("/assets/images/alert/down_skin.png", scaleGridTop="5", scaleGridBottom="13", scaleGridLeft="5", scaleGridRight="12");
disabled-skin: Embed("/assets/images/alert/disabled_skin.png", scaleGridTop="5", scaleGridBottom="13", scaleGridLeft="5", scaleGridRight="12");
font-weight: normal;
font-size: 11;
color: #333333;
roll-over-color: #333333;
text-roll-over-color: #333333;
text-selected-color: #000000;
padding-left: 5;
padding-right: 5;
padding-top: 3;

}
</fx:Style>

<fx:Script>
<![CDATA[
import assets.skins.AquaGlassButtonSkin;

import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
[Bindable]
private var titleTxt:String = "title";

[Bindable]
private var headerTxt:String = "head";

[Bindable]
private var mainTxt:String;

[Bindable]
private var alertIconPath:String;

private var flags:uint;

private var responseHandler:Function;

public static function showAlert(title:String, header:String, main:String, flags:uint = 0x4, responseHandler:Function = null):void
{
var customAlert:CloudAlert = new CloudAlert;

customAlert.titleTxt = title;
customAlert.headerTxt = header;
customAlert.mainTxt = main;
customAlert.responseHandler = responseHandler;
customAlert.flags = flags;
customAlert.alertIconPath = "assets/images/alert/icon_alert.png";

customAlert.create();
}

public static function showError(title:String, header:String, main:String, flags:uint = 0x4, responseHandler:Function = null):void
{
var customAlert:CloudAlert = new CloudAlert();

customAlert.titleTxt = title;
customAlert.headerTxt = header;
customAlert.mainTxt = main;
customAlert.responseHandler = responseHandler;
customAlert.flags = flags;
customAlert.alertIconPath = "assets/images/alert/icon_error.png";

customAlert.create();
}

private function create():void
{
if(this.responseHandler != null)
this.addEventListener(CloseEvent.CLOSE, responseHandler);

this.addEventListener(KeyboardEvent.KEY_UP, keyboardHandler);

PopUpManager.addPopUp(this, FlexGlobals.topLevelApplication as DisplayObject, true);

showButtons();

callLater(resizeComponent);
}

private function showButtons():void
{
if(this.flags & Alert.OK)
{
okButton.visible = true;
okButton.includeInLayout = true;
}

if(this.flags & Alert.YES)
{
yesButton.visible = true;
yesButton.includeInLayout = true;
}

if(this.flags & Alert.NO)
{
noButton.visible = true;
noButton.includeInLayout = true;
}

if(this.flags & Alert.CANCEL)
{
cancelButton.visible = true;
cancelButton.includeInLayout = true;
}

if(cancelButton.visible)
cancelButton.setFocus();
else if(noButton.visible)
noButton.setFocus();
else if(yesButton.visible)
yesButton.setFocus();
else if(okButton.visible)
okButton.setFocus();
}

private function resizeComponent():void
{
if(mainText.textHeight > mainText.minHeight)
{
var newHeight:int = height + mainText.textHeight - mainText.minHeight;
if(newHeight <= maxHeight && newHeight >= minHeight)
height = newHeight;
else
{
height = maxHeight;
width = maxWidth;
}
}

PopUpManager.centerPopUp(this);
}

private function close(mouseEvent:MouseEvent):void
{
var closeEvent:CloseEvent = new CloseEvent(CloseEvent.CLOSE);

if(mouseEvent.target == okButton)
closeEvent.detail = Alert.OK;
else if(mouseEvent.target == yesButton)
closeEvent.detail = Alert.YES;
else if(mouseEvent.target == noButton)
closeEvent.detail = Alert.NO;
else if(mouseEvent.target == cancelButton || mouseEvent.target == closeButton)
closeEvent.detail = Alert.CANCEL;

dispatchEvent(closeEvent);

if(this.responseHandler != null)
this.removeEventListener(CloseEvent.CLOSE, responseHandler);

this.removeEventListener(KeyboardEvent.KEY_UP, keyboardHandler);

PopUpManager.removePopUp(this);
}

private function keyboardHandler(keyboardEvent:KeyboardEvent):void
{
if(keyboardEvent.keyCode == 13)
{
keyboardEvent.target.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
}
]]>
</fx:Script>

<s:Label left="32" top="7" id="titleLabel"
text="{titleTxt}" styleName="CloudAlertTitle"/>


<mx:Button right="4" top="0" id="closeButton"
click="close(event)" styleName="CloudAlertCloseButton"/>


<mx:Image top="38" left="23" id="customAlertIcon" source="{alertIconPath}"/>


<mx:Label top="36" left="70" id="headerLabel"
text="{headerTxt}" styleName="CloudAlertSubtitle"/>

<mx:TextArea id="mainText"
top="58" left="70" right="30" bottom="76" minHeight="45" minWidth="200"
fontSize="12" borderAlpha="0" editable="false"
htmlText="{mainTxt}"/>

<s:HGroup left="0" verticalAlign="middle" horizontalAlign="center" right="0" bottom="46">

<s:Button id="okButton" height="18" label="确定" skinClass="assets.skins.AquaGlassButtonSkin"
click="close(event)"
visible="false" includeInLayout="false"/>

<s:Button id="yesButton" height="18" label="是" skinClass="assets.skins.AquaGlassButtonSkin"
click="close(event)"
visible="false" includeInLayout="false"/>

<s:Button id="noButton" height="18" label="否" skinClass="assets.skins.AquaGlassButtonSkin"
click="close(event)"
visible="false" includeInLayout="false"/>

<s:Button id="cancelButton" height="18" label="取消" skinClass="assets.skins.AquaGlassButtonSkin"
click="close(event)"
visible="false" includeInLayout="false"/>
</s:HGroup>
</s:BorderContainer>


4、 Flex画流程图
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
<mx:Canvas id="paper" x="30" y="24" width="719" height="600">
<mx:Canvas id="Total" x="10" y="254" width="108" height="78" borderStyle="inset">
<mx:Button x="0" y="43" label="关键词导出" width="103" height="28"/>
<mx:Text x="0" y="0" width="103" height="45" text="List PV:10000" fontSize="12"/>
</mx:Canvas>
<mx:Canvas id="LEV1_1" x="187" y="95" width="108" height="70" borderStyle="inset">
<mx:Button x="0" y="38" label="关键词导出" width="103" height="26"/>
<mx:Text x="0" y="0" width="103" height="39" text="List PV:10000" fontSize="12"/>
</mx:Canvas>
<mx:Canvas id="LEV1_2" x="187" y="315" width="108" height="77" borderStyle="inset">
<mx:Button x="0" y="45" label="关键词导出" width="103" height="26"/>
<mx:Text x="0" y="0" width="103" height="46" text="List PV:10000" fontSize="12"/>
</mx:Canvas>
<mx:Canvas id="LEV1_3" x="187" y="504" width="108" height="75" borderStyle="inset">
<mx:Button x="0" y="41" label="关键词导出" width="103" height="28"/>
<mx:Text x="0" y="0" width="103" height="42" text="List PV:10000" fontSize="12"/>
</mx:Canvas>
<mx:Canvas id="LEV1_1_1" x="374" y="10" width="108" height="70" borderStyle="inset">
<mx:Button x="0" y="38" label="关键词导出" width="103" height="26"/>
<mx:Text x="0" y="0" width="103" height="39" text="List PV:10000" fontSize="12"/>
</mx:Canvas>
<mx:Canvas id="LEV1_1_2" x="374" y="88" width="108" height="77" borderStyle="inset">
<mx:Button x="0" y="45" label="关键词导出" width="103" height="26"/>
<mx:Text x="0" y="0" width="103" height="46" text="List PV:10000" fontSize="12"/>
</mx:Canvas>
<mx:Canvas id="LEV1_1_3" x="374" y="173" width="108" height="75" borderStyle="inset">
<mx:Button x="0" y="41" label="关键词导出" width="103" height="28" click="export(LEV1_1_3_text.text)"/>
<mx:Text id="LEV1_1_3_text" x="0" y="0" width="103" height="42" text="List PV:10000" fontSize="12"/>
</mx:Canvas>
</mx:Canvas>

<mx:Script>
<![CDATA[
import mx.controls.Button;

import mx.containers.Canvas;

private function initApp():void{

paper.graphics.clear();
doDraw(Total, LEV1_1);
doDraw(Total, LEV1_2);
doDraw(Total, LEV1_3);
doDraw(LEV1_1, LEV1_1_1);
doDraw(LEV1_1, LEV1_1_2);
doDraw(LEV1_1, LEV1_1_3);
createAll();
}


private function createAll():void{
var canvas:Canvas = new Canvas();
canvas.x = 374;
canvas.y = 250;
canvas.setActualSize(108, 75);
canvas.setStyle("borderStyle", "inset");
var button:Button = new Button();
button.x = 0;
button.y = 41;
button.setActualSize(103,28);
var text:Text = new Text();
text.x = 0;
text.y = 0;
text.setActualSize(103,42);
button.label = "关键词导出";
text.text = "List PV:10000";
canvas.addChild(button);
canvas.addChild(text);
paper.addChild(canvas);
}


private function export(text:String):void{
ExternalInterface.call("exportQueryXLS", text);
}

private function doDraw(source:Sprite,target:Sprite):void
{
var radius:Number = 10;

var sourceCenter:Point = new Point(source.x + source.width,source.y + source.height/2);
var targetCenter:Point = new Point(target.x ,target.y + target.height/2);

var sin:Number = (sourceCenter.y - targetCenter.y)/(Math.sqrt(Math.pow(sourceCenter.x - targetCenter.x,2)+Math.pow(sourceCenter.y - targetCenter.y,2)));

var radian:Number = Math.asin(sin);
var degree:Number = radian*180/Math.PI;

if(source.x < target.x)
{
if(degree == 0 )
{
degree = 180;
}
if(degree > 0)
{
degree = 180 - degree;
}
if(degree < 0)
{
degree = 180 + degree * -1;
}
}

degree += 90;
radian = degree*Math.PI / 180;

// var offsetX:Number = radius * Math.cos(radian);
// var offsetY:Number = radius * Math.sin(radian);
var offsetX:Number = 0;
var offsetY:Number = 0;

var sourcePointA:Point = new Point(sourceCenter.x + offsetX, sourceCenter.y + offsetY);
var sourcePointB:Point = new Point(sourceCenter.x - offsetX, sourceCenter.y - offsetY);

var targetPointA:Point = new Point(targetCenter.x + offsetX, targetCenter.y + offsetY);
var targetPointB:Point = new Point(targetCenter.x - offsetX, targetCenter.y - offsetY);

// paper.graphics.clear();
paper.graphics.lineStyle(1,0x333300,100);
paper.graphics.moveTo(sourcePointA.x,sourcePointA.y);
paper.graphics.lineTo(targetPointA.x,targetPointA.y);
// paper.graphics.moveTo(sourcePointB.x,sourcePointB.y);
// paper.graphics.lineTo(targetPointB.x,targetPointB.y);
}

]]>
</mx:Script>


</mx:Application>
展开阅读全文

如何建立个人知识库知识库QA答疑帖

12-21

[img=https://img-bbs.csdn.net/upload/201612/21/1482315113_563580.gif][/img]rnrnrnhihi 你们好,我是密斯大白,知识库的管理员rn想开个贴统一解答大家关于知识库使用的各种问题。rn有问必答[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/13.gif][/img]rnrn[b]10秒了解知识库[/b]rnrn[quote]CSDN知识库是技术人的知识管理专家,适用于所有技术进阶的开发者。rnrnCSDN知识库覆盖了50+技术领域,包括教程、视频、代码、电子书,拥有超过10000+的体系化资源,一键生成即可拥有你的精华图谱和资源库,并可公开分享给他人,是技术开发者必备的资源管理工具和技术体系库,有助于形成个人技术体系库。[/quote]rnrn[color=#FF0000]rn[b]知识库Q&A[/b][/color]rnrn[b]CSDN知识库都有什么?[/b] [url=http://lib.csdn.net/home][color=#FF0000]点击查看[/color][/url]rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/112.gif][/img]官网知识库:包括图谱和结构化资源rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/112.gif][/img]个人知识库:用于建立你的技术图谱和技术资源rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/112.gif][/img]多类型资源:包括教程,视频,代码,电子书rnrn[b]如何使用官网知识库?[/b] rn官网知识库提供体系化学习的平台rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/112.gif][/img]通过点击图谱知识点浏览,访问更直观rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/112.gif][/img]通过快速入门,难点答疑,实践案例进行浏览rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/112.gif][/img]get 官网知识库,跟着图谱路径进行系统学习rnrn[b]如何使用个人知识库?[/b] rn在[url=http://lib.csdn.net/bases]知识库[/url]里选择我的知识库rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/112.gif][/img] Get 官网知识库模板,参考创建我的知识库rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/112.gif][/img] 自有一套知识体系,直接创建我的知识库rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/112.gif][/img] 分享给小伙伴,共享你的技术内容rnrn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/16.gif][/img][b]操作上有什么问题,可以回帖问我,有问必答[/b][img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/16.gif][/img]rnrnQ: 我已经创建个人图谱,但是没有找到对应的分类怎么办?rnrn1.请判断您的个人图谱是否属于子类(Java下的Spring子类)rn2.选择相邻的领域进行发布。rn3.在新建知识库版块留言给CSDN管理员(攒库地址xxx)或直接申请该领域特邀编辑,留言说明情况。rnrnrn 论坛

没有更多推荐了,返回首页