我正在尝试学习如何在mxml上使用actionscript来提高灵活性.我有这个简单的mxml块,我正在尝试转换为actionscript,但是我被困在了一半
<s:Rect id="theRect" x="0" y="50" width="15%" height="15%">
<s:fill>
<s:SolidColor color="black" alpha="0.9" />
</s:fill>
</s:Rect>
Run Code Online (Sandbox Code Playgroud)
我可以将Rect没有问题转换为
private var theRect:Rect = new Rect();
theRect.x = 0;
theRect.y = 50;
theRect.width = "15%";
theRect.height = "15%";
Run Code Online (Sandbox Code Playgroud)
然后我就陷入了困境.在尽可能少的代码行中添加SolidColor的最有效方法是什么.
所以我试过了
var url:String = String(this.loaderInfo.url);
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, '_self'); // second argument is target
} catch (e:Error) {
ErrorButton.label = "Please refresh page manually"
}
Run Code Online (Sandbox Code Playgroud)
和
var url:String = String(this.loaderInfo.loaderURL);
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, '_self'); // second argument is target
} catch (e:Error) {
ErrorButton.label = "Please refresh page manually"
}
Run Code Online (Sandbox Code Playgroud)
和FlexGlobals.topLevelApplication.url但它们都给出了相同的=(
但是http://127.0.0.1/w2/window.swf当我有网址时,我会把我送回去http://127.0.0.1/w2/window.php?action=read#1.我使用flash builder.那么我该怎么做才能获得真正的完整链接 - 而不是swf链接?
我需要检测通过AS3里面的flex mxml appication,这是我所在的浏览器 - FF,Chrome,IE等,只有名称和版本.怎么办这样的事情?

红色突出部分!我该如何删除它?渲染列表的代码如下:
<s:List id="ui_lstIndexList" width="175" height="600" fontFamily="TwinCen"
fontSize="24"
alternatingItemColors="[]" borderVisible="false" downColor="#7fceff"
change="showAlert(event)" contentBackgroundColor="#6fa8bc" color="#FFFFFF"
dataProvider="{indexArrayCollection}" selectionColor="#7fceff">
<s:itemRenderer>
<fx:Component>
<s:IconItemRenderer labelField="name" messageField="artist"/>
</fx:Component>
</s:itemRenderer>
</s:List>
Run Code Online (Sandbox Code Playgroud)
谢谢!!!
当用户点击删除按钮时,我会弹出一个警告.但是,在创建警报时,尽管没有用户输入,它仍会触发Yes函数.
显然,使用删除按钮这很糟糕.
protected function handleDelete(event:Event): void {
showAlert();
}
private function showAlert():void{
Alert.yesLabel = "Delete";
Alert.noLabel = "Cancel";
Alert.show("Are you sure you want to delete this?", "Confirm Delete", Alert.YES|Alert.CANCEL, this, delete(), null, Alert.CANCEL);
}
Run Code Online (Sandbox Code Playgroud)
不确定原因,但无论用户输入什么,都会在创建警报时触发delete().
警报是Flex默认警报,没有覆盖或任何内容.
采用以下AS3/MXML代码:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" xmlns="*"
backgroundColor="#000000" showStatusBar="false" width="400" height="400"
minWidth="0" minHeight="0">
<s:Rect width="50%" height="50%">
<s:fill>
<s:SolidColor color="#0000FF"/>
</s:fill>
</s:Rect>
</s:WindowedApplication>
Run Code Online (Sandbox Code Playgroud)
这主要是有效的.当我增加或减少程序的大小时,Rect的大小将缩放为WindowedApplication的宽度和高度的50%.但是随着我不断降低窗口的高度,缩小比例会停止几个像素,这个数字很小.这就像我可以让Rect沿着y轴一样小:

在达到这一点之后,即使我不断减小WindowedApplication的大小,也没有任何反应.在我再次开始增加窗口大小之前,Rect保持完全相同的高度.更重要的是,Rect的高度为12像素,这是一个非常随意的数字,它可以停止.
但是,如果我改变:
<s:Rect width="50%" height="50%">
Run Code Online (Sandbox Code Playgroud)
至:
<s:Rect width="{width / 2}" height="{height / 2}">
Run Code Online (Sandbox Code Playgroud)
这个问题神奇地消失了:

WindowedApplication的高度为5,Rect的高度约为"两个半".
为什么会有这样的区别?在前面的例子中,我尝试增加,然后再次减小尺寸几次,甚至缓慢,但它总是卡在同一个地方.谢谢!