Targeting a variable inside a MC?

I have a movie clip called curtain_mc with this actionscript inside:

onClipEvent (load) {
stop();
f = false;
}

onClipEvent (enterFrame) {
if (this.f == true) {
this.nextFrame();
} else if (this.f != true) {
this.prevFrame();
}
}

On my first frame I have this:
play_btn.onPress = function() {
btnHandler();
};

var btnCounter = 1;
function btnHandler() {
if (btnCounter == 1) {
_parent.curtain_mc.f = true;
btnCounter++;
trace(btnCounter);
} else if (btnCounter == 2) {
_parent.curtain_mc.f = false;
btnCounter = 1;
trace(btnCounter);
}
}

I would like to change the variable ‘f’ from true and false by clicking a button but the actionscript on my keyframe doesn’t recognize the actionscript in my movieclip?? I know its a targeting issue, but not sure how to alter it in order for the two to talk to each other??

Take code off curtain_mc and replace your timeline code with:

curtain_mc.stop();
// stop curtain_mc
curtain_mc.forward = false;
// set the variable "forward" on curtain_mx to false

function btnHandler():Void {
// btnHandler function
curtain_mc.forward = !curtain_mc.forward;
// alternate the forward variable on curtain_mc
}

curtain_mc.onEnterFrame = function():Void {
// curtain_mc's onEnterFrame functions
this[this.forward  ? "nextFrame" : "prevFrame"]()
// if forward is true, go to the next frame, otherwise go to the previous frame
}

play_btn.onPress = btnHandler;
// on press of play_button call btnHandler

Is that what you mean?

Wow! awesome! Bravo! Insert: Adjective meaning thank you and i’m impressed!

exactly what i wanted. and much less code.

so this line: thisthis.forward ? “nextFrame” : “prevFrame”

will have a movieclip go forward or backwards based on the ‘forward’ variable? Very Nice.

? : is a conditional operator.

condition ? if true do this : if false do this

It’s just a shorthand way of writing your if/else statements. The key to making it work is the toggling of the forward variable between false and true using =!

One more quick question: now if i export this swf, and load it into another FLA like this:
createEmptyMovieClip(“curtain”,1);
curtain._x = 262;
curtain._y = 40;
loadMovie(“curtainOpening.swf”, curtain);

and now i want to target that btnHandler function I tried this:

my1_btn.onRelease = function (){
myPlayer.contentPath = “ski3.flv”;
this.curtain.curtain_mc.btnHandler;
}

but i got nothing? any suggestions?

thanks again for your help!!

loadMovie(“curtainOpening.swf”, DEPTH of loading in item);

this.curtain.btnHandler

not

this.curtain.curtain.btnHandler

this.createEmptyMovieClip("curtain", 1);
curtain._x = 262;
curtain._y = 40;
curtain.loadMovie("curtainOpening.swf");
onEnterFrame = function () {
	//check if variable exists
	if (curtain.buttonHandler) {
		delete this.onEnterFrame;
		curtain.buttonHandler();
	}
};