AS3 NumericStepper 组件
我正在 Flash CS4 中创建 Actionscript 3 应用程序。我创建了一个名为 dropDown 的影片剪辑,并将 Actionscript 导出为 dropDown。在这个影片剪辑中,我放置了一个 numericStepper 组件。我还有一个基本的影片剪辑,其中包含一个文本框,上面写着 Add Dropdown Exporting for Actionscript as DropDownBtn。真的很基本。
添加下拉按钮通过事件侦听器和回调函数创建影片剪辑的实例。
创建实例后,我似乎无法访问数字步进器的值。我的代码如下:
//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;
}
I am creating an Actionscript 3 application in Flash CS4. I created a movie clip called dropDown with it exporting for Actionscript as dropDown. Inside this movie clip i dropped a numericStepper Component. I also have a basic movie clip of a box with text that says Add Dropdown exporting for Actionscript as DropDownBtn. Really basic.
the Add Dropdown button creates an instance of the movieclip via an event listener and callback function.
Once the instance is created I cant seem to access the value of the Numeric Stepper. MY code is as follows:
//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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您已将
范围限定在 addDropdown 函数内部
您需要将其移到该函数之外以使其具有全局范围
you have
scoped to inside the addDropdown function
You need to move it outside that function to make it have a global scope
好的,我明白了。
我必须在影片剪辑中引用 NumericStepper 的实例名称。像这样。
感谢您的帮助。
Ok I got it.
I had to reference the instance name of the NumericStepper inside the movie clip. Like this.
thanks for your help.