目标事件问题

时间:2013-05-15 00:40:50

标签: actionscript-3

我试图用这段代码实现的目标是,如果剪辑在显示之后被定位,它应该播放。如果周一选择是针对性的,它应该播放周一剪辑。但是代码不起作用。错误是这样的:

Scene 1, Layer 'Layer 1', Frame 2, Line 75  1120: Access of undefined property play_event.
Scene 1, Layer 'Layer 1', Frame 2, Line 74  1120: Access of undefined property play_event.


var week_pick:Weekday_Choice = new Weekday_Choice ();
var weekdayArray: Array = new Array ();
var monday:Mon_D_but = new Mon_D_but ();
var tuesday:Tues_D_but = new Tues_D_but ();
var wednesday:Wed_D_but = new Wed_D_but ();
var thursday:Thurs_D_but = new Thurs_D_but ();
var friday:Fri_D_but = new Fri_D_but ();
var choice_play: Array = new Array ();

choice_play.push(monday, tuesday, wednesday, thursday, friday);

addChild(week_pick);

choice_play[0].x = 73.1;
choice_play[0].y = 316.75;

choice_play[1].x = 251.9;
choice_play[1].y = 278.35;

choice_play[2].x = 399.95;
choice_play[2].y = 375.85;

choice_play[3].x = 345.2;
choice_play[3].y = 602.4;

choice_play[4].x = 80.15;
choice_play[4].y = 603.05;

week_pick.addEventListener(Event.ENTER_FRAME, moveon);

function moveon(event:Event)
{
    if (week_pick.currentFrame == 103)
    {

        week_pick.stop();
        for (var a = 0; a < choice_play.length; a++)
        {
            addChild(choice_play [a]);
            choice_play[a].alpha = 0;
            choice_play[a].stop();
        }

        this.addEventListener(MouseEvent.CLICK,choice_play_ev);


    }
}

function choice_play_ev(play_event: MouseEvent)
{

    if (play_event.target != week_pick)
    {

        play_event.target.alpha = 1;

        play_event.target.addEventListener(Event.ENTER_FRAME, play_target,false,0,true);

    }

}
function play_target(e:Event)
{

    play_event.target.play();
    if (play_event.target.currentFrame == 15)
    {
        destroyall_2();
    }

}

我不完全确定我是否正确地这样做了。屏幕上只有2个列表,开头的初始影片剪辑不需要任何交互,如果点击则需要播放的剪辑。有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:1)

play_target中,您正在尝试访问未定义的play_event。在这种情况下,您的事件是e