Incrementing Counter on Stage through Class
Hello everyone, I have a thread similar to this one about saving and loading a counter. However, I can't get the counter to increment when colliding with an object. When colliding with the object, it makes it not visible so you can't see it anymore.
My counter that saves and loads looks like this:
var so:SharedObject = SharedObject.getLocal("myStuff","/");
var JumpCounter: int = 0;
if(so.data.JumpCounter)
{
JumpCounter = so.data.JumpCounter;
}
And when you jump:
JumpCounter++;
so.data.JumpCounter = JumpCounter;
so.flush();
It ouputs here to a text box:
JumpBox.text = JumpCounter.toString();
This all works fine, I just can't get it to increment when colliding with my MovieClip.
I have a class that looks like this attached to my MovieClip that I want to increment that looks like this:
package {
import flash.display.*;
import flash.events.*;
public class AddJumps extends MovieClip{
//construct function
public function AddJumps():void
{
addEventListener(Event.ENTER_FRAME, collision);
}
private function collision(e:Event):void{
if(this.hitTestObject(MovieClip(root).Player)){
MovieClip(root).JumpIcon.visible = false;
}
}
}
}
I'm unsure as how to access or increment my counter from within a class. I can't seem to remember how to access the stage.
Thanks in advance!