Flash事件调度问题
我对事件调度有疑问。我正在尝试为 youtube 播放器编写代码并找到以下链接..
http://www.codingcolor.com/as3/as3-youtube-chromless-api/
他有很多类似这样的dispatchEvent调用:
dispatchEvent(new YouTubeEvent(YouTubeEvent.ON_IOERROR,event));
据我了解,自定义事件通常像下面这样调度:
dispatchEvent(new Event(YouTubeEvent.ON_IOERROR));
我不知道为什么他可以在On_IOERROR
之后添加,event
。如果有人能帮助我解决这个问题,我将不胜感激。谢谢。
I have a question about the event dispatch. I am trying to write the code for youtube player and find the following link..
http://www.codingcolor.com/as3/as3-youtube-chromless-api/
He has many dispatchEvent call similar like this:
dispatchEvent(new YouTubeEvent(YouTubeEvent.ON_IOERROR,event));
For my understanding, custom event usually dispatch like below:
dispatchEvent(new Event(YouTubeEvent.ON_IOERROR));
I am not sure why he can add ,event
after On_IOERROR
. I appreciate if anyone would help me about this. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在不了解 API 的情况下,我的猜测是
YouTubeEvent
旨在由 API 客户端使用,而不是本机 Flash 事件(例如本例中的IoErrorEvent
)。因此,代码调度 YouTubeEvent 的实例而不是IoErrorEvent
。如果您需要访问该数据,YouTubeEvent
很可能还允许您访问原始事件(通过变量或属性)。关于您的问题“我不确定为什么他可以在 On_IOERROR 之后添加事件”:
YouTubeEvent
必须是 自定义事件(由您或其他人定义的扩展Event
的类)。因此它的构造函数可以采用作者定义的任何参数。Without knowing the API, my guess is that
YouTubeEvent
is intended to be consumed by the API clients, rather than the native flash events (such asIoErrorEvent
, in this case). So, the code dispatches an instance of YouTubeEvent instead ofIoErrorEvent
.YouTubeEvent
most likely also gives you access to the original event (through a variable or property) in case you need access to that data.Regarding your question "I am not sure why he can add ,event after On_IOERROR":
YouTubeEvent
must be a custom event (a class defined by you or someone else that extendsEvent
). So its constructor can take any parameters its author defined.