flex 在函数之间动态改变值

发布于 2024-11-13 08:17:19 字数 1853 浏览 1 评论 0原文

我有一个主 mxml 和 2 个 AS 类。在主 mxml 中,我有一个滑块。我想在移动滑块时获取 AS 类中的滑块值。

Main.MXML

import First;
import Second;
private var my:First;
privaate var scd:Second;
public var sd:Date; 

public function init():void {
     my = new First();
     Canvas.addChild(my.getUIComponent()); 
}

public function dateChange():Date {
    startDate.selectedDate = new Date(slider.values[0]);
    endDate.selectedDate = new Date(slider.values[1]);
    sd = new Date(slider.values[0]);
    scd.calsldr(sd); 
    return sd;                  
}

<mx:HBox width="100%" height="100%" horizontalAlign="center" verticalAlign="top">
<mx:Canvas id="Canvas" backgroundColor="#ffffff" height="600" width="100%"
            horizontalScrollPolicy="off" verticalScrollPolicy="off">
</mx:Canvas>
</mx:HBox>
<flexlib:HSlider id="slider" width="100%" height="50" thumbCount="2"                     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"/>
</mx:HBox>

我的第一个AS是first.AS 调用 Second.AS

addChild(new Second(str) as Sprite);

str 是一个字符串值,

我想使用 Second.AS 中的滑块值 我尝试使用这个:

public function calsldr(dat:Date):void {
    trace(dat);
}

private function visualization():void{ }

我可以从跟踪(dat)获取值......我的意思是日期是滑块变化的。 我如何在函数可视化()中使用这个变化的值

请帮助。

I have a main mxml and 2 AS classes.In the main mxml I have a slider.I want to get the slider values in AS classes as I move the slider.

Main.MXML

import First;
import Second;
private var my:First;
privaate var scd:Second;
public var sd:Date; 

public function init():void {
     my = new First();
     Canvas.addChild(my.getUIComponent()); 
}

public function dateChange():Date {
    startDate.selectedDate = new Date(slider.values[0]);
    endDate.selectedDate = new Date(slider.values[1]);
    sd = new Date(slider.values[0]);
    scd.calsldr(sd); 
    return sd;                  
}

<mx:HBox width="100%" height="100%" horizontalAlign="center" verticalAlign="top">
<mx:Canvas id="Canvas" backgroundColor="#ffffff" height="600" width="100%"
            horizontalScrollPolicy="off" verticalScrollPolicy="off">
</mx:Canvas>
</mx:HBox>
<flexlib:HSlider id="slider" width="100%" height="50" thumbCount="2"                     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"/>
</mx:HBox>

My first AS which is first.AS
calls Second.AS

addChild(new Second(str) as Sprite);

str is a String value

i want to use the slider values in Second.AS
I tried using this:

public function calsldr(dat:Date):void {
    trace(dat);
}

private function visualization():void{ }

I could get the values from trace(dat)....I mean the date's as the slider changes.
How could I use this changing values in function visualization()

PLease help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮年慕年 2024-11-20 08:17:19

@J_A_X
第二个AS是:

public function Second(str:String){
    name = "Second";    }
public function calsldr(dat:Date){
    trace(dat+"fu in maaka"); // As I change the slider the value is changed here  }
protected override function init():void
    {
        var ldr:URLLoader = new URLLoader(new URLRequest(url));
        _bar.loadURL(ldr, function():void {
        var obj:Array = JSON.decode(ldr.data as String) as Array;
        //Sorted the values based on 'str'
    var data:Data = buildData(newarr);
        visualize(data);
        _bar = null; });
    }
public function visualize(data:Data):void{
      // I want to get the dat values here when ever the slider moves
}

@J_A_X
The Second AS is:

public function Second(str:String){
    name = "Second";    }
public function calsldr(dat:Date){
    trace(dat+"fu in maaka"); // As I change the slider the value is changed here  }
protected override function init():void
    {
        var ldr:URLLoader = new URLLoader(new URLRequest(url));
        _bar.loadURL(ldr, function():void {
        var obj:Array = JSON.decode(ldr.data as String) as Array;
        //Sorted the values based on 'str'
    var data:Data = buildData(newarr);
        visualize(data);
        _bar = null; });
    }
public function visualize(data:Data):void{
      // I want to get the dat values here when ever the slider moves
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文