View Full Version : increase/decrease movieclip size help!
imported_invisibleloop
April 25th, 2005, 06:09 AM
Hi
I have a movieclip slider_mc that can be dragged across the screen. There are also lots of small movieclips on the stage that I would like to increase and decrease their size depending on how close the draggable movieclip is to them. If you know what I mean please can you help!
Thanks
A
MichaelxxOA
April 25th, 2005, 06:47 AM
are you going to base this off of the actual distance the slider is from the MC or just the x or just the y? in either case you would be using either, _xscale _yscale or _width _height, the reason I ask the first question is the math, is there a predetermined size you'd like these MC's to end up?
=Michael=
imported_invisibleloop
April 25th, 2005, 07:04 AM
are you going to base this off of the actual distance the slider is from the MC or just the x or just the y? in either case you would be using either, _xscale _yscale or _width _height, the reason I ask the first question is the math, is there a predetermined size you'd like these MC's to end up?
=Michael=
Hi
the slider_mc is on a time/date line and each point (a small circle) along the line increases when the slider gets close to them and decreases the further away the slider gets. When the slider is directly over each point the size is set at a certain size.
Thanks!
A
foodpk
April 25th, 2005, 07:27 AM
Make a movieclip, call it slider_mc and add this code to it.
on (press) {
this.startDrag();
}
on (release) {
stopDrag();
}
Add this code to all the movieclips you want to resize in relation to the slider's position.
onClipEvent(mouseMove) {
control = 5;
distance = Math.sqrt((this._x-_root.slider_mc._x)*(this._x-_root.slider_mc._x)+(this._y-_root.slider_mc._y)*(this._y-_root.slider_mc._y));
this._xscale = 100 - distance/control;
this._yscale = 100 - distance/control;
(this._xscale<0) ? this._xscale = 0 : null;
(this._yscale<0) ? this._yscale = 0 : null;
}
The bigger the variable control is, the farther away the slider will have to be to make the movieclip the size of a point. And if the slider's position is the same as the movieclips, the movieclip will be at its original size.
imported_invisibleloop
April 25th, 2005, 08:53 AM
Make a movieclip, call it slider_mc and add this code to it.
on (press) {
this.startDrag();
}
on (release) {
stopDrag();
}
Add this code to all the movieclips you want to resize in relation to the slider's position.
onClipEvent(mouseMove) {
control = 5;
distance = Math.sqrt((this._x-_root.slider_mc._x)*(this._x-_root.slider_mc._x)+(this._y-_root.slider_mc._y)*(this._y-_root.slider_mc._y));
this._xscale = 100 - distance/control;
this._yscale = 100 - distance/control;
(this._xscale<0) ? this._xscale = 0 : null;
(this._yscale<0) ? this._yscale = 0 : null;
}
The bigger the variable control is, the farther away the slider will have to be to make the movieclip the size of a point. And if the slider's position is the same as the movieclips, the movieclip will be at its original size.
That work's! Fantastic! Just one little thing though! my slider_mc has a transparent screen and in that movieclip is another clip which is the hit area which triggers other mc's. I would like the hitarea clip to be the clip that increases and decreases the points instead of the slider_mc. At the moment the points are at full size at the edge of the slider rather than the centre.
Can you see what I am saying?
A
imported_invisibleloop
April 25th, 2005, 08:56 AM
That work's! Fantastic! Just one little thing though! my slider_mc has a transparent screen and in that movieclip is another clip which is the hit area which triggers other mc's. I would like the hitarea clip to be the clip that increases and decreases the points instead of the slider_mc. At the moment the points are at full size at the edge of the slider rather than the centre.
Can you see what I am saying?
A
Its ok. Just altered the registration point! d'oh!
foodpk
April 25th, 2005, 09:00 AM
That's easy. You see the distance calculation line? Well there, everywhere where it says _root.slider_mc._x and _root.slider_mc._y, try changing it to (_root.slider_mc._x + _root.slider_mc.inside_mc._x) and (_root.slider_mc._y + _root._slider_mc._inside_mc._y), provided that the movieclip inside the slider is called inside_mc
imported_invisibleloop
April 25th, 2005, 11:48 AM
That's easy. You see the distance calculation line? Well there, everywhere where it says _root.slider_mc._x and _root.slider_mc._y, try changing it to (_root.slider_mc._x + _root.slider_mc.inside_mc._x) and (_root.slider_mc._y + _root._slider_mc._inside_mc._y), provided that the movieclip inside the slider is called inside_mc
Top Man! Thanks for all your help!
foodpk
April 25th, 2005, 12:05 PM
No problem!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.