flex - dropdown following moving calloutbutton -
flex actionscript question.
i have calloutbutton moving on screen. when open dropdown (by click) stays @ same position on screen (only arrow moving). not follow calloutbutton's position
i dropdown follow position of calloutbutton when has moved (as when 1 clicks on button again when has moved).
i have tried dispatch mouseevent.click. not work. tried open, close again dropdown actionscript sing closedropdown() , opendropdown(). no change.
thanks
sample code (call init() creationcomplete) :
creationcomplete="init();"> <fx:declarations> <!-- place non-visual elements (e.g., services, value objects) here --> </fx:declarations> <fx:script> <![cdata[ import flash.events.mouseevent; import mx.events.dropdownevent; private function init():void { var minutetimer:timer = new timer(1*1000); minutetimer.addeventlistener(timerevent.timer, updatecalloutposition); // starts timer ticking minutetimer.start(); } private function updatecalloutposition(event:event):void { mybutton.closedropdown(); mybutton.x = this.width * math.random(); mybutton.y = this.height * math.random(); // mybutton.opendropdown(); mybutton.dispatchevent(new mouseevent(mouseevent.click)); } protected function mybutton_clickhandler(event:mouseevent):void { if (mybutton.ispopup) { mybutton.closedropdown(); } else { mybutton.opendropdown(); } } ]]> </fx:script> <s:calloutbutton id="mybutton" click="mybutton_clickhandler(event)"> </s:calloutbutton>
i tried workaround openduration , closeduration not working dropdownlist if can achieved following code may you. hope following code may you.
<?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>
Comments
Post a Comment