[AS2] attachMovie ObjName outside of function

Hello all

I am currently developing an interactive location map of the UK for a client. Every region of the map is a button that, when click, zooms in towards the viewer whilst all the others fade in the background.

This i can do fine with a single function. However the movieClip that is loaded with attachMovie contains buttons that I simply cannot target for any other function. I believe it is something to do with the attachMovie ObjName not being accessible outside of the function they’re created in. I have been trying _global variables but still I cannot assign actions to the buttons.

Please, if some one could just take a look at my code and point me in the right direction so that when I click any of the buttons in the attachMovie I at least get a trace function to work.

I have attached my complete actionscript but the section I’m struggling with is displayed below.


//zoom in
function focus (target_mc:MovieClip, scale_mc:Number, sec:Number, target_x:Number, target_y:Number, focus_mc:String) {
	
	_global.focus_Name = "_focus";
	_global.back_Button = focus_mc + "_back";

	if (ireland._alpha == 100) {

		var zoomInTween:Tween = 	new Tween(target_mc, "_xscale", Regular.easeOut, target_mc._xscale, scale_mc, sec, true);
											new Tween(target_mc, "_yscale", Regular.easeOut, target_mc._yscale, scale_mc, sec, true);
											new Tween(target_mc, "_x", Regular.easeOut, target_mc._x, 185, sec, true);
											new Tween(target_mc, "_y", Regular.easeOut, target_mc._y, 177.5, sec, true);

		fadeoutAll(target_mc);
		disableAll(target_mc);

		zoomInTween.onMotionFinished = function() {
			_root.attachMovie(focus_mc ,focus_Name, 100, {_x:185, _y:177.5, _xscale:scale_mc, _yscale:scale_mc});
			_root.attachMovie("back_btn" ,back_Button, 200, {_x:10, _y:10, _xscale:14.3, _yscale:14.3});
		}

	} else {

		removeMovieClip("_focus");
		removeMovieClip(back_Button);

		var zoomOutTween:Tween = 	new Tween(target_mc, "_xscale", Regular.easeOut, target_mc._xscale, 50, sec, true);
												new Tween(target_mc, "_yscale", Regular.easeOut, target_mc._yscale, 50, sec, true);
												new Tween(target_mc, "_x", Regular.easeOut, target_mc._x, target_x, sec, true);
												new Tween(target_mc, "_y", Regular.easeOut, target_mc._y, target_y, sec, true);
												
		fadeinAll(target_mc);
		enableAll();
	}
}


//beds, bucks, herts & northants
beds.onRollOver = function() {
	colourswapper(beds,"0xFFADEA");
};

beds.onRollOut = function() {
	colourswapper(beds,"0xCE8BBC");
};

beds.onRelease = function() {
	focus(beds, 400, 0.5, 267.9, 282.8, "beds_focus");
	trace (back_Button);
	trace (focus_Name);
};

beds.beds_focus_back.onRelease = function () {
	trace ("It works!");
}

has been solved, thank you

Well done…feel free to leave a clue to the solution for future reference :wink: