边框容器创建通用的 mouseOver 函数

发布于 2024-12-21 11:17:03 字数 456 浏览 2 评论 0原文

我尝试创建一个函数来更改边框容器的边框属性。 为此,我为 MXML 上的每个边框容器创建一个函数。

但我会更好地编码并执行通用功能。

今天我的功能是:

protected function bcContact_mouseOverHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
bcContact.setStyle("borderVisible",true);
bcContact.setStyle("borderWeight",2);
bcContact.setStyle("borderColor",'#000099');
}

bcContact是一个边界容器Id。

我尝试用它替换 bcContact 但它不起作用。

你能帮我解决这个初学者的错误吗?

谢谢

I try to create a function to change border property of border container.
To do that I create a function for each border container on my MXML.

But I'd to code better and to do a generic function.

Today my function is:

protected function bcContact_mouseOverHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
bcContact.setStyle("borderVisible",true);
bcContact.setStyle("borderWeight",2);
bcContact.setStyle("borderColor",'#000099');
}

bcContact is one border container Id.

I try to replace bcContact by this but it doesn't work.

Can you help me to solve this beginner mistake.

Thanks

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

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

发布评论

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

评论(2

权谋诡计 2024-12-28 11:17:03

你可以使用event.CurrentTraget,然后使用比较函数,与ids进行比较并进行设置。

U can use event.CurrentTraget and then use the compare functions, compare with ids and do the settings.

ζ澈沫 2024-12-28 11:17:03

您可以扩展 BorderContainer 类(在 Flash Builder 中,将 BorderContainer 放入“超级类”文本字段中)

您的类将如下所示:

import flash.events.MouseEvent;
import spark.components.BorderContainer;
package com.extensions.containers {

    class MyBorderContainer {

        function MyBorderContainer() {
            this.addEventListener(MouseEvent.MOUSE_OVER, changeStyle);
            this.addEventListener(MouseEvent.MOUSE_OUT, undoStyle);
        }

        private function changeStyle(e:MouseEvent):void {
            this.setStyle("borderVisible",true);
            this.setStyle("borderWeight",2);
            this.setStyle("borderColor",'#000099');
        }

        private function undoStyle(e:MouseEvent):void {
            this.setStyle("borderVisible",false);
            this.setStyle("borderWeight",0);
            this.setStyle("borderColor",'#000000');
        }
    }
}

该类需要位于文件 src/com/extensions/containers 中/MyBorderContainer.as

然后在您的 mxml 中使用它,

<containers:MyBorderContainer>

</containers:MyBorderContainer>

将命名空间 containers 设置为指向 com/extensions/containers

You could extend the BorderContainer class (in Flash Builder, put in BorderContainer in the "Super class" text field)

Your class will look something like this:

import flash.events.MouseEvent;
import spark.components.BorderContainer;
package com.extensions.containers {

    class MyBorderContainer {

        function MyBorderContainer() {
            this.addEventListener(MouseEvent.MOUSE_OVER, changeStyle);
            this.addEventListener(MouseEvent.MOUSE_OUT, undoStyle);
        }

        private function changeStyle(e:MouseEvent):void {
            this.setStyle("borderVisible",true);
            this.setStyle("borderWeight",2);
            this.setStyle("borderColor",'#000099');
        }

        private function undoStyle(e:MouseEvent):void {
            this.setStyle("borderVisible",false);
            this.setStyle("borderWeight",0);
            this.setStyle("borderColor",'#000000');
        }
    }
}

This class will need to be in the file src/com/extensions/containers/MyBorderContainer.as

Then use this in your mxml as

<containers:MyBorderContainer>

</containers:MyBorderContainer>

where the namespace containers is set to point to com/extensions/containers

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文