开发者

I want to get the values from slider in mxml and use it in as,thereby changing the layout

开发者 https://www.devze.com 2023-03-01 15:20 出处:网络
(I am using flex builder) I have main mxml,this calls an AS file, layout is shown.That is working good.But I cant 开发者_Go百科get the values from the slider dynamically into actionscript i.e, if the

(I am using flex builder) I have main mxml,this calls an AS file, layout is shown.That is working good.But I cant 开发者_Go百科get the values from the slider dynamically into actionscript i.e, if the slide the slider the need to get these values in actionscript so that I can change the layout based on the values. I am using flexlib so that i can use lock region while dragging.

How do I get that. mxml file is devud.mxml and As file is Devud.as

<fx:Script>
<![CDATA[

import Devud;
private var my:Devud;

private function init():void{
 my = new Devud();
 Canvas.addChild(my.getUIComponent());}
</fx:Script>

<flexlib:HSlider id="slider" width="100%" height="50" 
                     thumbCount="2" tickColor="0X000000"
                     lockRegionsWhileDragging="true" allowTrackClick="true" maintainProjectionCenter="true"
                     change="dateChange();"
                     thumbSkin="mx.skins.spark.SliderThumbSkin"
                     trackSkin="mx.skins.spark.SliderTrackSkin"
                     trackHighlightSkin="mx.skins.spark.SliderTrackHighlightSkin" />

Thankyou,


You should be able to access the value of the slider in ActionScript using slider.value .

If you want to execute code every time the value changes, you can listen to the change event.

If that doesn't answer your question, you're going to have to elaborate a bit more.


`I added startDate and endDate.Then I used these in my .AS

<fx:Script>

<![CDATA[

import Devud;

private var my:Devud;

private function init():void{

my = new Devud(); Canvas.addChild(my.getUIComponent());}

public function dateChange():void{

startDate.selectedDate = new Date(slider.values[0]);

endDate.selectedDate = new Date(slider.values[1]);}

</fx:Script>

<flexlib:HSlider id="slider" width="100%" height="50" thumbCount="2" borderColor="0Xff00cc" lockRegionsWhileDragging="true" allowTrackClick="true" maintainProjectionCenter="true"
change="dateChange();" liveDragging="true"
thumbSkin="mx.skins.spark.SliderThumbSkin" trackSkin="mx.skins.spark.SliderTrackSkin"
trackHighlightSkin="mx.skins.spark.SliderTrackHighlightSkin" />

<mx:HBox x="300" y="300" height="50">

<mx:Label text="Start Date :"/> <mx:DateField id="startDate"/>

<mx:Label text="End Date"/> <mx:DateField id="endDate"/>

in my .AS,mxml is devud.mxml.

var mn:devud = new devud();

trace(mn.startDate);

trace(mn.endDate);

I can get the values of the startDate every time I change the slider value

0

精彩评论

暂无评论...
验证码 换一张
取 消