首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AS3 NumericStepper组件

AS3 NumericStepper组件
EN

Stack Overflow用户
提问于 2011-04-26 10:14:02
回答 2查看 1.1K关注 0票数 0

我正在创建一个动作脚本3应用程序在闪光CS4。我创建了一个名为dropDown的影片剪辑,并将其导出为dropDown格式。在这个影片剪辑中,我放入了一个numericStepper组件。我还有一个带有文本框的基本影片剪辑,上面写着Add Dropdown exporting for Actionscript as DropDownBtn。非常基础。

添加下拉按钮通过事件侦听器和回调函数创建电影剪辑的实例。

一旦创建了实例,我似乎就不能访问数值步长的值了。我的代码如下:

代码语言:javascript
复制
   //create the load dropdown button
    var newButton = new DropDownBtn();
    //position the button
    newButton.x = 20;
    newButton.y = 20;
    //and add it to the stage
    addChild(newButton);
    //add the event listener to the button
    newButton.addEventListener(MouseEvent.MOUSE_DOWN, addDropdown);

    function addDropdown(e:MouseEvent):void{

        //create and instance of the drop down
        var newDropDown = new dropDown();

        //move it over beside the add dropdown button
        newDropDown.x = newButton.width+40;
        newDropDown.y = 20;

        //add the instance of the newDropDown to the display stack
        addChild(newDropDown);

        //add the event listener to the dropdown
        newDropDown.addEventListener(Event.CHANGE, useDropDownValue);
    }

    function useDropDownValue(e:Event):void{
        //this is where I need to utilize the value of the Numeric Stepper
        //I thought it would be accessed as follows but it doesn't seem to work
        //I added a trace to make sure this function is being executed and that works
        //when i comment out my attempt at using the Numeric Stepper Value
        trace("useDropDownValue Function Accessed");
        var dropDownValue = newDropdown.value;
    }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-04-27 01:52:58

好的,我知道了。

我必须在影片剪辑中引用NumericStepper的实例名称。就像这样。

代码语言:javascript
复制
var numericStepperValue = movieClip.NumericStepperInstance.value;

谢谢你的帮助。

票数 0
EN

Stack Overflow用户

发布于 2011-04-26 10:43:23

你有

代码语言:javascript
复制
 var newDropDown = new dropDown();

作用域为addDropdown函数内部

您需要将其移出该函数,以使其具有全局作用域

代码语言:javascript
复制
 //create the load dropdown button
    var newButton = new DropDownBtn();
    //position the button
    newButton.x = 20;
    newButton.y = 20;
    //and add it to the stage
    addChild(newButton);
    //add the event listener to the button
    newButton.addEventListener(MouseEvent.MOUSE_DOWN, addDropdown);



// GLOBAL SCOPE HERE
//create and instance of the drop down
var newDropDown = new dropDown();
    function addDropdown(e:MouseEvent):void{


        //move it over beside the add dropdown button
        newDropDown.x = newButton.width+40;
        newDropDown.y = 20;

        //add the instance of the newDropDown to the display stack
        addChild(newDropDown);

        //add the event listener to the dropdown
        newDropDown.addEventListener(Event.CHANGE, useDropDownValue);
    }

    function useDropDownValue(e:Event):void{
        //this is where I need to utilize the value of the Numeric Stepper
        //I thought it would be accessed as follows but it doesn't seem to work
        //I added a trace to make sure this function is being executed and that works
        //when i comment out my attempt at using the Numeric Stepper Value
        trace("useDropDownValue Function Accessed");
        var dropDownValue = newDropdown.value;
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5785218

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档