# Navigation class with ON state

**URL:** <https://forum.kirupa.com/t/navigation-class-with-on-state/179193>\
**Category:** flash\
**Created:** [February 17, 2006, 2:03pm UTC](https://forum.kirupa.com/t/navigation-class-with-on-state/179193 "2006-02-17T14:03:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vectorjunk](https://avatars.discourse-cdn.com/v4/letter/v/8baadc/32.png) [@Vectorjunk](https://forum.kirupa.com/u/Vectorjunk)\
**Post date:** [February 17, 2006, 2:03pm UTC](https://forum.kirupa.com/t/navigation-class-with-on-state/179193/1 "2006-02-17T14:03:09Z")

</div>

Hello,  
This is my first attempt at writing a class, so be gentle (-:  
I have used this navigation script several times in regular flash coding without problems (as in functions). Now I’m trying to put this code in a class for easier usage in future projects.

Concept of the code is that I pass the instance of the mc in an variable so that I have an old and new location for enabling and disabling a “ON” state in an mc (vars : OldLocation && NewLocation).  
This is pretty basic stuff but I can’t get it to work inside a class…

Offcourse at the first click you will get an undefined because of no instance defined yet (I define it in the fla file).

Does anyone knows why I can’t rewrite the var OldLocation ?

My code :

```php

class ButtonClass extends MovieClip {
	
	public var OldLocation;
	public var NewLocation;
	
	public function ButtonClass() {
		this.onRollOver = this.over;
		this.onRollOut = this.out;
		this.onRelease = this.doAction;
	}
	
	private function over() { this.gotoAndPlay(2); }
	private function out () { this.gotoAndPlay(7); }
	
	private function doAction() {
		SmartNavi(this);
	}
	
	public function SmartNavi(item) {
		NewLocation = item;
		
		trace ("OldLocation = " + OldLocation);
		trace ("NewLocation = " + NewLocation);
		
		OldLocation.enabled = true; // Reset old location state
		OldLocation.gotoAndPlay(7); // Reset old location
		
		NewLocation.enabled = false; // Disable new location
		NewLocation.gotoAndStop(6); // Set new state
// !!! Here's the problem !!!
		OldLocation = NewLocation;	// Keep in mind
	}

}

```

Regards,  
Kenny
