如何使用 Flash 中的按钮组件修复此潜在错误?

发布于 2024-09-16 12:30:05 字数 1259 浏览 7 评论 0原文

我需要使用 Flash IDE 中 UI 组件面板中的 Button 组件,并将切换属性设置为 true。

如果我将它与时间线脚本一起使用,效果会很好。

如果我在类(文档类)中使用,则所选属性会反转 (当它没有切换时我就明白了,反之亦然)。

另外,如果我在属性检查器中将切换设置为 false,然后在文档类中将切换设置为 true,它仍然会显示为 false。如果我无效,我会将跟踪切换为 true,但是 所选属性始终跟踪 false。

时间轴代码就这么简单:

bold_b.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void {
    trace(event.currentTarget.selected);
}

文档类也很简单:

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;

    public class ButtonTester extends MovieClip
    {
        public function ButtonTester()
        {
            //in timeline works fine, in class it's the other way around
            bold_b.addEventListener(MouseEvent.CLICK, onClick);
            bold_b.toggle = true;
            bold_b.invalidate('toggle',true);
            bold_b.drawNow();
            stage.invalidate();
            trace('bold_b.toggle: ' + bold_b.toggle);
            function onClick(event:MouseEvent):void {
                trace(event.currentTarget.selected);
            }
        }

    }
}

目前我正在使用 Flash CS3。我已经安装了 Flash Player 10。不知道组件的“构建”版本,但它们是在 2007 年在 Flash Player 9.0.28.0 下编写的

有谁知道如何解决这个问题?

I need to use the Button component from the UI Components Panel in the Flash IDE, with the toggle property set to true.

If I use it with a timeline script it works great.

If I use within a class(a Document Class), the selected property is reversed
(I get true when it's not toggled and vice versa).

Also if I set toggle to false in the Property Inspector, then set toggle to true in the document class, it still traces out as false. If I invalidate, I toggle traces true, but
the selected property always traces false.

Timeline code is as simple as this:

bold_b.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void {
    trace(event.currentTarget.selected);
}

Document class is simple as well:

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;

    public class ButtonTester extends MovieClip
    {
        public function ButtonTester()
        {
            //in timeline works fine, in class it's the other way around
            bold_b.addEventListener(MouseEvent.CLICK, onClick);
            bold_b.toggle = true;
            bold_b.invalidate('toggle',true);
            bold_b.drawNow();
            stage.invalidate();
            trace('bold_b.toggle: ' + bold_b.toggle);
            function onClick(event:MouseEvent):void {
                trace(event.currentTarget.selected);
            }
        }

    }
}

Currently I'm using Flash CS3. I've got Flash Player 10 installed. Don't know the components 'build' version, but they were written in 2007 under Flash Player 9.0.28.0

Does anyone know how to get around this ?

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

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

发布评论

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

评论(1

方圜几里 2024-09-23 12:30:05

那这个呢?

import fl.controls.Button;

var myButton:Button = new Button();
myButton.toggle = true;    
myButton.selected = true;
myButton.label = "selected:" + myButton.selected;
myButton.width = 120;
myButton.move(10, 10);
myButton.addEventListener(Event.CHANGE, changeHandler);
addChild(myButton);

function changeHandler(event:Event):void {
    var myBtn:Button = event.currentTarget as Button;
    myBtn.label = "selected:" + myBtn.selected;
}

and what about this?

import fl.controls.Button;

var myButton:Button = new Button();
myButton.toggle = true;    
myButton.selected = true;
myButton.label = "selected:" + myButton.selected;
myButton.width = 120;
myButton.move(10, 10);
myButton.addEventListener(Event.CHANGE, changeHandler);
addChild(myButton);

function changeHandler(event:Event):void {
    var myBtn:Button = event.currentTarget as Button;
    myBtn.label = "selected:" + myBtn.selected;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文