0
votes

I want to be able to access a private var from inside a movieclip, does anyone know how I would go about doing that?

I want to be able to access my public function counter(numPoints:int) that is inside the ActionScript class file from inside a movieclip on my main swf. Whenever I try to access it, it comes up as undefined, but how to access it from inside the movieclip is the problem(I know the variables are all defined properly because it works when it isn't inside of a movieclip). Any idea are appreciated ^^;, Thanks!

      unlock3.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_3);

    function fl_ClickToGoToAndStopAtFrame_3(event:MouseEvent):void
    {
        MovieClip(parent).gotoAndStop(8);
        addScore(1);
}

I want to make it so the addScore function works properly, but it always comes out undefined. This script here is inside of the movieclip. The navigation works fine, but I don't know how to target the score.

1
You need to put up some code to describe the issue more clearly. - catholicon
I added the code, I hope that helps. - user2293231

1 Answers

0
votes

It's still unclear what exactly you are doing, your function is named counter but you are calling addScore. See if this helps.

In your document class (lets assume it is called Main) you would have something like:

private var _currentScore:int;

public function addScore(scoreToAdd:int):void
{

_currentScore += scoreToAdd;

trace("New Score: "+_currentScore);

}

Then within your object class which extends MovieClip you would have:

function fl_ClickToGoToAndStopAtFrame_3(event:MouseEvent):void
{
Main.addScore(1);
}