Charisitter
Charisitter

Reputation: 3

as3 score counter giving error #1006: value is not a function when called from a movieclip

In the main timeline I have the code:

stop();

var score = 0;
scorecounter.text = score;

function updateScore() {
    scorecounter.text = ++score;
}

and inside a movieclip on frame 10 I have the code:

gotoAndPlay(1);    
this(parent).updatescore();

which returns in the output panel

TypeError: Error #1006: value is not a function.

I'm pretty new to flash and have no what is wrong with the code. any and all help will be appreciated, thankyou in advance.

Upvotes: 0

Views: 63

Answers (2)

Umur Karagöz
Umur Karagöz

Reputation: 3190

In AS3, we reach to an objects parent with dot syntax So corrent sytax would be;

this.parent.yourFunction();

But in your case, it will not work. Because you cannot refer to a function in main timeline like that.

Instead, try exploring as3 OOP principles.

Upvotes: 1

Iggy
Iggy

Reputation: 4888

this keyword is not a function. Instead you could do MovieClip(parent).updateScore();

Upvotes: 1

Related Questions