Package/Function Help

Hi all,

If anyone can give me a hand trying to get my head around this code I’d be eternally grateful!

I’ve the following package that display some graphics and some formatted text fields (below).

I’m trying to get the two eventhandlers to work - swapping a background image but only if that background image isn’t the current one (if you get what I mean!) - basically like a switch - but i’ts not working in that the click event swaps the image regardless of the current state (setting vars to indicate state but this doesn’t seem to work - see bottom of code in red).

Any ideas would be a blessing!

[SIZE=1][COLOR=blue]package app.gui{[/COLOR][/SIZE]
[SIZE=1][COLOR=blue] import flash.display.Sprite;
import flash.display.MovieClip;
import flash.text.;
import flash.events.
;

public class TextGen extends Sprite {[/COLOR][/SIZE]
[SIZE=1][COLOR=blue] public function TextGen() {

var Navigation:MovieClip=new rightPanel();
addChild(Navigation);
Navigation.x=832;
Navigation.y=2.4;

var Navigation2:MovieClip=new rightPanel2();
addChild(Navigation2);
trace(“NAV2 = " + getChildIndex(Navigation2));
Navigation2.x=832;
Navigation2.y=2.4; [/COLOR][/SIZE]
[SIZE=1][COLOR=blue]
var css:StyleSheet = new StyleSheet();
[/COLOR][/SIZE]
[SIZE=1][COLOR=blue] var body:Object = new Object();
body.fontFamily = “Arial”;
body.textIndent = 0;[/COLOR][/SIZE]
[SIZE=1][COLOR=blue] var heading:Object = new Object();
heading.fontSize = 16;
heading.textIndent = 0;
heading.leading = 10;
heading.letterSpacing = 0;
heading.fontWeight = “bold”;
heading.color = “#333333”;
heading.textAlign = “center”;[/COLOR][/SIZE]
[SIZE=1][COLOR=blue] var byline:Object = new Object();
byline.fontSize = 14;
byline.leading = 20;
byline.fontStyle = “italic”;
byline.textAlign = “right”;[/COLOR][/SIZE]
[SIZE=1][COLOR=blue] css.setStyle(”.heading", heading);
css.setStyle(".byline", byline);
css.setStyle(“body”, body);[/COLOR][/SIZE]
[SIZE=1][COLOR=#0000ff][/COLOR][/SIZE]
[SIZE=1][COLOR=blue] var txtFld:TextField = new TextField();
txtFld.x =830;
txtFld.y =10;
txtFld.width = 100;
txtFld.multiline = true;
txtFld.wordWrap = true;
txtFld.selectable = false;
txtFld.embedFonts = true;
txtFld.autoSize = TextFieldAutoSize.LEFT;
txtFld.styleSheet = css;
txtFld.htmlText = “<body>”;
txtFld.htmlText += “<span class=‘heading’>Text</span>”;
txtFld.htmlText += “</body>”;
addChild(txtFld);

var txtImage:TextField = new TextField();
txtImage.x =936;
txtImage.y =10;
txtImage.width = 100;
txtImage.multiline = true;
txtImage.wordWrap = true;
txtImage.selectable = false;
txtImage.embedFonts = true;
txtImage.autoSize = TextFieldAutoSize.LEFT;
txtImage.styleSheet = css;
txtImage.htmlText = “<body>”;
txtImage.htmlText += “<span class=‘heading’>Images</span>”;
txtImage.htmlText += “</body>”;
addChild(txtImage);

[COLOR=darkred] txtFld.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:Event):void
{
if (navType!=1) {
swapChildren(Navigation,Navigation2);
var navType:int=1;
trace(navType);
}
} [/COLOR][/COLOR][/SIZE]
[SIZE=1][COLOR=blue][COLOR=darkred]
txtImage.addEventListener(MouseEvent.CLICK, clickHandler2);
function clickHandler2(event:Event):void
{
if (navType!=2) {
swapChildren(Navigation,Navigation2);
var navType:int=2;
trace(navType);
}[/COLOR]
}[/COLOR][/SIZE]
[SIZE=1][COLOR=blue] }
[/COLOR][/SIZE][SIZE=1][COLOR=blue]
}
}[/COLOR][/SIZE]