Okay, I’ve found some code and tweaked it to fit my project to make a mc zoom and be able to be dragged. The problem is that this code is supposed to be place on the Maintimeline and the result is that only one movieclip per .swf will do this. Is there a way I can take this code and tweak it further so that it can be placed in each movieclip? This way I can have multiple mc’s per .swf that are able to zoom in and out and are able to pan?
here is the actionscript that goes on the maintimeline 1st frame. I want to be able to place in a movieclip and still function the same way. is this possible?
onClipEvent (load) {
function dragZoom(movieClip) {
/************************************************
* Variables for home position of movieClip
* NOTE! You will have to change these values
* according to the movie size. See "readme.doc"
* for how to adjust this to your requirements.
************************************************/
_global.homeX = 314;
_global.homeY = 219;
/************************************************
* Variable for the zooming speed. Adjust this
* value to tweak the speed. The lower the value
* the lower the zoom speed.
************************************************/
_global.zoomIncrement = 10;
/**************************************************
* You can change this variable to alter the zoom
* amount. The default is 200 meaning the image will
* scale to twice the size as 100 is the original size.
* The higher the number the more the zoom will scale
* the image.
**************************************************/
_global.zoomAmount = 200;
/*************************************************
* Create a zoom in function
* Function zoomIn checks if the current xscale
* and yscale is less than 200. If less than 200
* the image scales in x and y are increased by the
* amount that zoomIncrement is set too.
*************************************************/
function zoomIn(movieClip) {
if(movieClip._yscale && movieClip._xscale < zoomAmount) {
movieClip._xscale = movieClip._xscale + zoomIncrement;
movieClip._yscale = movieClip._yscale + zoomIncrement;
} //end if statement
} //end zoomIn function
/**************************************************************
* Create a zoom out function.
* Function checks if the y scale and x scale is
* greater than 100. If the image(movieClip) scale is
* greater than 100 the scale is decreased by the zoomIncrement
* value.
**************************************************************/
function zoomOut(movieClip) {
if(movieClip._yscale && movieClip._xscale > 100) {
movieClip._xscale = movieClip._xscale - zoomIncrement;
movieClip._yscale = movieClip._yscale - zoomIncrement;
} //end the if statement
} //end the zoomOut function
/****************************************************************
* A function for onMouseDown.
* When the user holds the Mouse Down this activates the function.
* On activation of the function the startDrag commands is issued
* and the on enterFrame function is called which then calls the
* zoomIn function created earlier. Due to the onEnterFrame properties
* this enables the zoom to be called at the set frame rate of the movie
* causing a continuous motion
****************************************************************/
movieClip.onPress = function() {
this.startDrag();
movieClip.onEnterFrame = function() {
zoomIn(this);
}; //end onEnterFrame
}; //end onPress
/*****************************************************************
* Releasing the mouse button involkes the stopDrag method and
* excutes the onEnterFrame function. The onEnterFrame function
* calls the zoomOut function which is effectively looped due to
* the onEnterFrame method. The function also returns the movieClip
* home to the original location in a smooth motion
*****************************************************************/
movieClip.onRelease = function() {
this.stopDrag();
movieClip.onEnterFrame = function() {
zoomOut(this);
// Send the image back to the home on release
image._x = image._x - (image._x - homeX) / 5;
image._y = image._y - (image._y - homeY) / 5;
}; //end on EnterFrame function
}; //end onRelease function
} //end programm dragZoom
// Call the function dragZoom to activate!
dragZoom(image);
}