user1203605
user1203605

Reputation: 83

AS3 What's wrong with this code?

Most of this is working and even with the error, it continues to work in part:

// Make PostItNote MC draggable and keep ON TOP
mcMXredBox.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);

var q:int = 1;

// Add multiple copies of PostItNote when used
function fl_ClickToDrag(event:MouseEvent):void
{
    event.currentTarget.parent.startDrag();
    event.currentTarget.parent.parent.setChildIndex(DisplayObject(event.currentTarget.parent),87);
    var my_PIN = new postItNote();
    my_PIN.name = "my_RTC" + q; // Doesn;t like this line
    this.parent.addChild(my_PIN);
    trace("my_PIN = " + my_PIN);
    this.my_PIN[q].x = 1388.05; // Doesn't like this line
    this.my_PIN[q].y = 100;
    q++;
}

The error is

TypeError: Error #1010: A term is undefined and has no properties.
    at postItNote/fl_ClickToDrag()[postItNote::frame1:71]"

Upvotes: 1

Views: 79

Answers (1)

laurent
laurent

Reputation: 90736

my_PIN.name = "my_RTC" + q; // Doesn;t like this line

This means that name is not a property of the postItNote class.

this.my_PIN[q].x = 1388.05; // Doesn't like this line

You seem to be using the wrong syntax here. What you want is probably just:

my_PIN.x = 1388.05; // In this context, my_PIN already refers to the movie clip named '"my_RTC" + q'

Upvotes: 1

Related Questions