Apache flex 移动按钮后的下拉列表
FlexActionScript问题 我有一个在屏幕上移动的按钮。 当我打开下拉列表时(通过单击),它会保持在屏幕上的相同位置(只有箭头在移动)。它不跟随按钮的位置 我想让这个下拉列表跟随Callout按钮移动时的位置(当按钮移动时再次单击按钮时也是如此) 我已尝试发送MouseEvent.CLICK。它不起作用。 还尝试打开,然后使用actionscript sing closeDropDown()和openDropDown()再次关闭下拉列表。没有变化 谢谢 示例代码(从creationComplete调用init()):Apache flex 移动按钮后的下拉列表,apache-flex,actionscript,drop-down-menu,adobe,callout,Apache Flex,Actionscript,Drop Down Menu,Adobe,Callout,FlexActionScript问题 我有一个在屏幕上移动的按钮。 当我打开下拉列表时(通过单击),它会保持在屏幕上的相同位置(只有箭头在移动)。它不跟随按钮的位置 我想让这个下拉列表跟随Callout按钮移动时的位置(当按钮移动时再次单击按钮时也是如此) 我已尝试发送MouseEvent.CLICK。它不起作用。 还尝试打开,然后使用actionscript sing closeDropDown()和openDropDown()再次关闭下拉列表。没有变化 谢谢 示例代码(从creationCo
creationComplete=“init();”>
我尝试了一些解决方法,但是openDuration和closeDuration对于DropDownList不起作用,如果可以实现的话,下面的代码可能会对您有所帮助。希望下面的代码可以帮助你
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="init()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:ArrayCollection id="ac">
<fx:String>AK</fx:String>
<fx:String>AL</fx:String>
<fx:String>AR</fx:String>
</s:ArrayCollection>
</fx:Declarations>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/halo";
s|DropDownList {
openDuration: 0;
closeDuration: 0;
}
</fx:Style>
<fx:Script>
<![CDATA[
import flash.events.MouseEvent;
import spark.components.supportClasses.DropDownListBase;
import spark.components.supportClasses.TextBase;
import spark.events.DropDownEvent;
import spark.skins.spark.DropDownListSkin;
import spark.utils.LabelUtil;
private var storeVisible:Boolean = false;
private function init():void {
var minuteTimer:Timer = new Timer(1*1000);
minuteTimer.addEventListener(TimerEvent.TIMER, updateCalloutPosition);
minuteTimer.start();
}
private function updateCalloutPosition(event:Event = null):void {
myButton.x = this.width * Math.random();
myButton.y = this.height * Math.random();
if(myButton.isDropDownOpen)
{
myButton.closeDropDown(false);
storeVisible = true;
}
}
private function updateComp():void
{
if(storeVisible)
{
myButton.openDropDown();
storeVisible = false;
}
}
]]>
</fx:Script>
<s:DropDownList id="myButton" selectedIndex="0" dataProvider="{ac}" updateComplete="updateComp()"/>
</s:Application>
AK
艾尔
应收账
@命名空间s“library://ns.adobe.com/flex/spark";
@名称空间mx“library://ns.adobe.com/flex/halo";
s |下拉列表{
开放时间:0;
关闭持续时间:0;
}
分享一些代码。我非常确定call out弹出窗口的位置基于CallOut按钮的位置。如果按钮正在移动,您还必须使用相同的公式移动弹出窗口。好的,我添加了一些代码。即使删除了单击处理程序,它也不会跟随按钮。当按钮移动时,代码中没有任何内容试图重新定位弹出窗口。我不确定如何直接访问弹出窗口,从Callout按钮API看不明显。您可能需要扩展组件,或者您可以尝试打开和关闭弹出窗口[有相应的方法]。您好,谢谢您的回复。弹出窗口是calloutbutton spark组件的一部分。它应该自动定位在组件的旁边。关于打开/关闭建议:myButton.closeDropDown和myButton.openDropDown打开和关闭弹出窗口。但正如你所见,它没有任何效果。扩展组件可能是一个解决方案,但我希望有一个更简单的解决方案。是的,Callout按钮自动定位在组件附近。这听起来像是在弹出窗口定位后移动组件,而弹出窗口本身没有重新定位。这是对您的问题的正确描述吗?
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="init()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:ArrayCollection id="ac">
<fx:String>AK</fx:String>
<fx:String>AL</fx:String>
<fx:String>AR</fx:String>
</s:ArrayCollection>
</fx:Declarations>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/halo";
s|DropDownList {
openDuration: 0;
closeDuration: 0;
}
</fx:Style>
<fx:Script>
<![CDATA[
import flash.events.MouseEvent;
import spark.components.supportClasses.DropDownListBase;
import spark.components.supportClasses.TextBase;
import spark.events.DropDownEvent;
import spark.skins.spark.DropDownListSkin;
import spark.utils.LabelUtil;
private var storeVisible:Boolean = false;
private function init():void {
var minuteTimer:Timer = new Timer(1*1000);
minuteTimer.addEventListener(TimerEvent.TIMER, updateCalloutPosition);
minuteTimer.start();
}
private function updateCalloutPosition(event:Event = null):void {
myButton.x = this.width * Math.random();
myButton.y = this.height * Math.random();
if(myButton.isDropDownOpen)
{
myButton.closeDropDown(false);
storeVisible = true;
}
}
private function updateComp():void
{
if(storeVisible)
{
myButton.openDropDown();
storeVisible = false;
}
}
]]>
</fx:Script>
<s:DropDownList id="myButton" selectedIndex="0" dataProvider="{ac}" updateComplete="updateComp()"/>
</s:Application>