tailedmouse
tailedmouse

Reputation: 365

Target event Issue

The goal i am trying to achieve with this code is, if a clip was targeted after it displayed it should play. If the Monday choice was targeted it should play the Monday clip. But the code is not working. The error is this:

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();
    }

}

I am not entirely sure if I am doing this correctly. There are only really 2 list of things on the screen, the initial movie clip at the start which doesn't need any interaction, and the clips that needs playing if clicked. Can somebody please help me out with it?

Upvotes: 0

Views: 44

Answers (1)

Josh
Josh

Reputation: 8149

In play_target, you are trying to access play_event which is undefined. You event in that case is e.

Upvotes: 1

Related Questions