私はas3の初心者です。マウス ホバーでロードされ、マウス アウトで巻き戻される 2 つの並列ムービー クリップを含むボックスを作成したいと考えています。ムービー クリップへのリンクを追加したいのですが、長い間何もできませんでした。
コードは次のようになります。
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();
}
}