闪存HTML5的画布fl_MouseOverHandler画布、闪存、fl_MouseOverHandler

由网友(孤独的风景▲)分享简介:我是很新的Flash的ActionScript和放大器; JavaScript,但我希望能在这里如果有可能得到一些帮助。我创建了一个网站使用canvas元素,还有画布上的图像,当你通过滚动的图像,影片剪辑播放,当你点击它的一部分,它带你到另一个页面。我使用Flash创建它,但我有困难搞清楚什么地方出了错。我使用cod...

我是很新的Flash的ActionScript和放大器; JavaScript,但我希望能在这里如果有可能得到一些帮助。我创建了一个网站使用canvas元素,还有画布上的图像,当你通过滚动的图像,影片剪辑播放,当你点击它的一部分,它带你到另一个页面。 我使用Flash创建它,但我有困难搞清楚什么地方出了错。我使用code片段在事件处理程序添加,但我没有收到影片剪辑播放。该链接的网页的工作,但鼠标事件不会。

另外,我的影片剪辑包含很多层,将在有所作为?

任何帮助将是很大的AP preciated。

  / *停止影片剪辑* /
this.movi​​eClip_11.stop();

/ *鼠标悬停事件* /
VAR频率= 3;
stage.enableMouseOver(频率);
this.movi​​eClip_11.addEventListener(鼠标悬停,fl_MouseOverHandler_32);

功能fl_MouseOverHandler_32()
{
this.movi​​eClip_11.play();
}

/ *播放影片剪辑* /

/ *点击进入网页* /
this.movi​​eClip_11.addEventListener(点击,fl_ClickToGoToWebPage_15);

传播fl_ClickToGoToWebPage_15(){
的window.open(___,_self);
}
 

解决方案

问题是,JavaScript的处理范围(即本)不同,以动作。在AS3中,你可以假设该事件处理程序维护其包​​含对象的范围。在JS不是这种情况。这里有几个解决方案,这一问题:

您可以通过传递范围,事件处理程序的绑定方法。例如,这种技术用在Flash中的code段对HTML5的画布/时间轴浏览/点击进入帧播放。

  this.movi​​eClip_11.stop();
VAR频率= 3;
stage.enableMouseOver(频率);
this.movi​​eClip_11.addEventListener(鼠标悬停
    fl_MouseOverHandler_32.bind(本));

功能fl_MouseOverHandler_32()
{
    this.movi​​eClip_11.play();
}
 
PS鼠绘精致的灰色质感U盘

在easeljs提供另一种解决方案(由Flash的制作HTML画布的内容使用的JavaScript库)被调用的EventDispatcher方法中调用的在的实现,而不是的的addEventListener 。 easeljs文档现在事件处理程序假定调度的对象的范围事件。

  this.movi​​eClip_11.stop();
VAR频率= 3;
stage.enableMouseOver(频率);
this.movi​​eClip_11.on(利添利,fl_MouseOverHandler_32);

功能fl_MouseOverHandler_32()
{
    this.play();
}
 

I'm quite new to Flash Actionscript & Javascript but I'm hoping to get some help here if possible. I'm creating a website using the canvas element, there is an image on the canvas and when you scroll over a part of that image, a movie clip plays, when you click on it, it takes you to another page. I'm using flash to create it, but I'm having difficulty figuring out what's going wrong. I'm using code snippets to add in event handlers but I'm not getting the movie clip to play. The link to the page works but the mouse over event does not.

Also, my movie clip contains many layers, will this make a difference?

Any help would be greatly appreciated.

/* Stop a Movie Clip*/
this.movieClip_11.stop();

/* Mouse Over Event*/
var frequency = 3;
stage.enableMouseOver(frequency);
this.movieClip_11.addEventListener("mouseover", fl_MouseOverHandler_32);

function fl_MouseOverHandler_32()
{
this.movieClip_11.play();
}

/* Play a Movie Clip*/

/* Click to Go to Web Page*/
this.movieClip_11.addEventListener("click", fl_ClickToGoToWebPage_15);

function fl_ClickToGoToWebPage_15() {
window.open("___", "_self");
}

解决方案

The problem is that javascript handles scope(i.e. this) differently to ActionScript. In AS3 you can assume that the event handler maintains the scope of its containing object. In JS this isn't the case. Here are a couple of solutions to this problem:

You can pass the scope to the event handler using the bind method. For example, this technique is utilized in the code snippets in Flash for HTML5 Canvas/Timeline Navigation/Click to Go to Frame and Play.

this.movieClip_11.stop();
var frequency=3;
stage.enableMouseOver(frequency);
this.movieClip_11.addEventListener("mouseover",         
    fl_MouseOverHandler_32.bind(this));

function fl_MouseOverHandler_32()
{
    this.movieClip_11.play();
}

An alternative solution available in easeljs(the javascript library utilized by Flash for producing HTML canvas content) is achieved by calling the EventDispatcher method called on instead of addEventListener. easeljs docs Now the event handler assumes the scope of the object that dispatched the event.

this.movieClip_11.stop();
var frequency=3;
stage.enableMouseOver(frequency);
this.movieClip_11.on("rollover",fl_MouseOverHandler_32);

function fl_MouseOverHandler_32()
{
    this.play();
}

阅读全文

相关推荐

最新文章