0

我正在尝试使用 Action Script 3.0 创建一个程序,在该程序中单击一个元素,单击另一个元素,第一个元素转到第二个元素。

这是我的代码:

import flash.display.MovieClip;
import flash.display.SimpleButton;
import  flash.display.MovieClip;
import  flash.events.MouseEvent;

stop();

var Plchange:MovieClip;
var As:Array = new Array(A1,A2,A3,A4,A5,A6,A7,A8,A9);
var Bs:Array = new Array(B1,B2,B3,B4,B5,B6,B7,B8,B9);
var Cs:Array =new Array(C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12);
var Cs1:Array=new Array(C13,C14,C15,C16,C17,C18,C19,C20,C21,C22,C23,C24);

for ( var i:int =0; i<=8 ;i++)
{   
As[i].addEventListener(MouseEvent.CLICK, function(me:MouseEvent):void{ gotoPlace(me, As[i])});
Bs[i].addEventListener(MouseEvent.CLICK, function(me:MouseEvent):void{ gotoPlace(me, Bs[i])});


}
for ( var Y:int =0; i<=12 ;Y++)
{   
Cs[Y].addEventListener(MouseEvent.CLICK, function(me:MouseEvent):void{ Set(me, Cs[Y])});
Cs1[Y].addEventListener(MouseEvent.CLICK, function(me:MouseEvent):void{ Set(me,      Cs1[Y])});
}
function gotoPlace(event:MouseEvent, boing:MovieClip)
{
boing = Plchange;
}
function Set(event:MouseEvent, clip:MovieClip)
{
Plchange.x = clip.x;
Plchange.y = clip.y;
}

我收到一个错误:

TypeError:错误#1010:术语未定义且没有属性。在 NineMen_fla::MainTimeline/frame1()

我哪里错了?请告诉我。

4

1 回答 1

0

首先,gotoPlace你不应该输入Plchange = boing;反之亦然。其次,您必须检查是否Plchange在 function 中分配了一个值Set()。像这样:

var Plchange:MovieClip=null;
function gotoPlace(event:MouseEvent, boing:MovieClip)
{
    Plchange = boing;
}
function Set(event:MouseEvent, clip:MovieClip)
{
    if (!Plchange) return; // Plchange is not assigned
    Plchange.x = clip.x;
    Plchange.y = clip.y;
}
于 2013-10-19T09:17:55.943 回答