[FMX] changing mouse events into function calls

Hiya,
I’m a semi-newbie and could sure use some help.
I have 4 invisible buttons that all do basically the same thing. I am learning how to consolidate my code using functions and I’m stuck on this one. I am using onRollover, on Rollout and onReleases in a frame actionscript. The code is below for 2 of the buttons.

mission_btn.onRollOver =function(){
mission_mc.gotoAndPlay(“on”);
}

mission_btn.onRollOut=function(){
mission_mc.gotoAndPlay(“off”);
}

mission_btn.onRelease = function(){
sectionLoader (“mission”)
}

facilities_btn.onRollOver =function(){
facilities_mc.gotoAndPlay(“on”);
}

facilities_btn.onRollOut=function(){
facilities_mc.gotoAndPlay(“off”);
}

facilities_btn.onRelease = function(){
sectionLoader (“facilities”)
}

is this enough info to help me change these events into a function?
or should I just continue with this method for the other buttons?

Thanks for the insight!
David

they already are functions

:q:

Ok,
so I’m not the sharpest pencil in the box.
Maybe me question no phrased good.

I guess I wanted to consolidate these button scripts.
like only have 1 onRollover etc,
and where mission_btn is or facilities_btn is, generate that name dynamically and assign it to the rollover or release etc.

Does that make anymore sense?

I’m really trying to explain…

thanks for the patience
David

btn = [mission_btn, facilities_btn];
for (var b in btn) {
	btn**.onRollOver = function () {
		this._parent[this._name.substring(0, this._name.lastIndexOf("_"))+"_mc"].gotoAndPlay("on");
	}
	btn**.onRollOut = function () {
		this._parent[this._name.substring(0, this._name.lastIndexOf("_"))+"_mc"].gotoAndPlay("off");
	}
	btn**.onRelease = function () {
		sectionLoader(this._name.substring(0, this._name.lastIndexOf("_")));
	}
}

that’s the only way i could get it to work :-\

[size=1]well … for five minutes of work it’s not that bad :P[/size]

instead of using substring you could just start off with the prefix and then add _btn or _mc making it a little easier I think :q:
the array being

sections = [“mission”, “facilities”];

etc?

hmm … good point =)

senocular
[size=1]redraw(“lostinbeta”);[/size]

kax
[size=1]erase(“lostinbeta”);[/size]
:stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue:

yeah … i saw it a few minutes ago :stuck_out_tongue:

seems like he won’t let me erase lostinbeta :-\