FLEX,Actionscript:关于mouseOver事件和图像缩放的2个问题

时间:2022-09-25 23:53:07

1) if I create items in a for loop, is correct to add a new eventListener for each item ? Or should I add only 1 eventListener to the parent ? and call the event through ID ?

1)如果我在for循环中创建项目,为每个项目添加一个新的eventListener是否正确?或者我应该只向父级添加1个eventListener?并通过ID调用事件?

2) if I want to scale my item, (a LinkButton with icon image), I noticed that the icon is sometimes resized with delay, so I have a bit of flickering when I trigger the event. Should I not use icons, and set the image in another way ? How can I fix this ?

2)如果我想缩放我的项目(带有图标图像的LinkBut​​ton),我注意到图标有时会延迟调整大小,所以当我触发事件时我会有一些闪烁。我不应该使用图标,并以另一种方式设置图像吗?我怎样才能解决这个问题 ?

thanks

1 个解决方案

#1


0  

1) if I create items in a for loop, is correct to add a new eventListener for each item ? Or should I add only 1 eventListener to the parent ? and call the event through ID ?

1)如果我在for循环中创建项目,为每个项目添加一个新的eventListener是否正确?或者我应该只向父级添加1个eventListener?并通过ID调用事件?

It depends. If the items are listening for something, add it to them. If the parent is listening, add it to the parent. If you add it only to the parent, set the useCapture arg to true in the addEventListener method. It can get confusing in Flash because there is no difference between an event listener and an event handler: the handler actually points to the class that contains the handler.

这取决于。如果项目正在侦听某些内容,请将其添加到其中。如果父级正在侦听,请将其添加到父级。如果仅将其添加到父级,请在addEventListener方法中将useCapture arg设置为true。它可能会在Flash中混淆,因为事件侦听器和事件处理程序之间没有区别:处理程序实际上指向包含处理程序的类。

2) if I want to scale my item, (a LinkButton with icon image), I noticed that the icon is sometimes resized with delay, so I have a bit of flickering when I trigger the event. Should I not use icons, and set the image in another way ? How can I fix this ?

2)如果我想缩放我的项目(带有图标图像的LinkBut​​ton),我注意到图标有时会延迟调整大小,所以当我触发事件时我会有一些闪烁。我不应该使用图标,并以另一种方式设置图像吗?我怎样才能解决这个问题 ?

Without knowing how exactly you are doing this, I can't offer concrete solutions. Are you using a Resize effect? Are you scaling using overrides on scaleX and scaleY properties? Does this handle on mouseover or via some other event? All I can tell you is that you may be better off not using the LinkButton, or may want to change the skin instead of resizing. Show your code if you want more informed answers.

在不知道你究竟是怎么做的情况下,我无法提供具体的解决方案。你在使用调整大小效果吗?您是否在scaleX和scaleY属性上使用覆盖进行缩放?这是处理鼠标悬停还是通过其他事件?我可以告诉你的是,你可能最好不要使用LinkBut​​ton,或者可能想改变皮肤而不是调整大小。如果您想要更明智的答案,请显示您的代码。

#1


0  

1) if I create items in a for loop, is correct to add a new eventListener for each item ? Or should I add only 1 eventListener to the parent ? and call the event through ID ?

1)如果我在for循环中创建项目,为每个项目添加一个新的eventListener是否正确?或者我应该只向父级添加1个eventListener?并通过ID调用事件?

It depends. If the items are listening for something, add it to them. If the parent is listening, add it to the parent. If you add it only to the parent, set the useCapture arg to true in the addEventListener method. It can get confusing in Flash because there is no difference between an event listener and an event handler: the handler actually points to the class that contains the handler.

这取决于。如果项目正在侦听某些内容,请将其添加到其中。如果父级正在侦听,请将其添加到父级。如果仅将其添加到父级,请在addEventListener方法中将useCapture arg设置为true。它可能会在Flash中混淆,因为事件侦听器和事件处理程序之间没有区别:处理程序实际上指向包含处理程序的类。

2) if I want to scale my item, (a LinkButton with icon image), I noticed that the icon is sometimes resized with delay, so I have a bit of flickering when I trigger the event. Should I not use icons, and set the image in another way ? How can I fix this ?

2)如果我想缩放我的项目(带有图标图像的LinkBut​​ton),我注意到图标有时会延迟调整大小,所以当我触发事件时我会有一些闪烁。我不应该使用图标,并以另一种方式设置图像吗?我怎样才能解决这个问题 ?

Without knowing how exactly you are doing this, I can't offer concrete solutions. Are you using a Resize effect? Are you scaling using overrides on scaleX and scaleY properties? Does this handle on mouseover or via some other event? All I can tell you is that you may be better off not using the LinkButton, or may want to change the skin instead of resizing. Show your code if you want more informed answers.

在不知道你究竟是怎么做的情况下,我无法提供具体的解决方案。你在使用调整大小效果吗?您是否在scaleX和scaleY属性上使用覆盖进行缩放?这是处理鼠标悬停还是通过其他事件?我可以告诉你的是,你可能最好不要使用LinkBut​​ton,或者可能想改变皮肤而不是调整大小。如果您想要更明智的答案,请显示您的代码。