我是as3的初学者。我想制作一个盒子,在鼠标悬停时加载两个平行的影片剪辑,并在鼠标移出时倒带。我想添加指向电影剪辑的链接,但很长一段时间后我什么都没有。
代码如下所示:
import flash.events.MouseEvent;
for (var fl_ChildIndex:int = 0;
fl_ChildIndex < this.numChildren;
fl_ChildIndex++)
{
this.getChildAt(fl_ChildIndex).addEventListener(MouseEvent.MOUSE_OVER, nawierzch);
}
function nawierzch(event:MouseEvent):void
{
this.addChild(event.currentTarget as DisplayObject);
}
zlec.stop();
zlec.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
zlec.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
zlec.addEventListener(MouseEvent.CLICK, onClick);
zlec.buttonMode = true;
zlec.mouseChildren = true;
function onClick(event:MouseEvent):void
{
trace("click")
var url:String = "http://www.motoopcja.pl";
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, '_blank');
} catch (e:Error) {
trace("Error occurred!");
}
}
function onMouseOver(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.currentTarget);
mc.removeEventListener(Event.ENTER_FRAME, rewind);
mc.play();
mc.addEventListener(Event.ENTER_FRAME, advance);
}
function onMouseOut(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.currentTarget);
mc.removeEventListener(Event.ENTER_FRAME, advance);
mc.prevFrame();
mc.addEventListener(Event.ENTER_FRAME, rewind);
}
function advance(e:Event):void
{
var mc:MovieClip = MovieClip(e.currentTarget);
if (mc.currentFrame == mc.totalFrames)
{
mc.stop();
mc.removeEventListener(Event.ENTER_FRAME, advance);
}
}
function rewind(e:Event):void
{
var mc:MovieClip = MovieClip(e.currentTarget);
if (mc.currentFrame == 1)
{
mc.stop();
mc.removeEventListener(Event.ENTER_FRAME, rewind);
}
else
{
mc.prevFrame();
}
}
wykonaj.stop();
wykonaj.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver2);
wykonaj.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut2);
wykonaj.addEventListener(MouseEvent.CLICK, onClick2);
wykonaj.buttonMode = true;
wykonaj.mouseChildren = true;
function onClick2(e:MouseEvent):void
{
trace("click")
}
function onMouseOver2(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.currentTarget);
mc.removeEventListener(Event.ENTER_FRAME, rewind);
mc.play();
mc.addEventListener(Event.ENTER_FRAME, advance);
}
function onMouseOut2(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.currentTarget);
mc.removeEventListener(Event.ENTER_FRAME, advance);
mc.prevFrame();
mc.addEventListener(Event.ENTER_FRAME, rewind);
}
function advance2(e:Event):void
{
var mc:MovieClip = MovieClip(e.currentTarget);
if (mc.currentFrame == mc.totalFrames)
{
mc.stop();
mc.removeEventListener(Event.ENTER_FRAME, advance);
}
}
function rewind2(e:Event):void
{
var mc:MovieClip = MovieClip(e.currentTarget);
if (mc.currentFrame == 1)
{
mc.stop();
mc.removeEventListener(Event.ENTER_FRAME, rewind);
}
else
{
mc.prevFrame();
}
}