View Full Version : making a mc grow, script included
pkcidstudio
September 23rd, 2005, 11:13 AM
good morning or afternoon all depending on where you are located. here is my question with this script
this.onLoad =function(){
this._xscale = 70;
this._yscale = 70;
};
this.onRollOut =function(){
delete this.onEnterFrame
this._xscale = 70;
this._yscale = 70;
};
this.onRollOver =function(){
this.onEnterFrame = function(){
if(this._xscale <= 110){
this._xscale++;
this._yscale++;}};};
if i have a row of mc (8) on a line that i want this script to work for do i need to have this script written out for (8) mc's or, on the root timeline?
also for more than one mc, am i just changing (this) to what ever the name of the mc is?
also instead of mc's will this script also work for buttons? or do i need to just put a hidden button over the top of this mc?
LostBear
September 23rd, 2005, 11:17 AM
no...you dont. you can make the function in the first frame of your movie timeline and then call it from each of the buttons. easy and much cleaner than having the code on each button. ill make a quick example if u need.
pkcidstudio
September 23rd, 2005, 11:19 AM
ya that would be great
LostBear
September 23rd, 2005, 11:30 AM
aright ill figure it out.give me a few mins.
LostBear
September 23rd, 2005, 12:26 PM
aright ill figure it out.give me a few mins.
hmm. this took longer to figure then expected...i have a rough but u should be able to build on it. basically what you need to do is set a variable by rolling over the buttons and then some thing happening according to which variable is set...ie the growing and shrinking.
file (http://www.jamessteel.co.uk/grow.zip)
pkcidstudio
September 23rd, 2005, 12:35 PM
well thank you for working something for me, keep it up though. i have about 10 sites i am working on at the same time. so i have time i dont need to get back to it till later, if anyone else would like to give it a wurl. thanks all
rhamej
September 23rd, 2005, 02:33 PM
good morning or afternoon all depending on where you are located. here is my question with this script
this.onLoad =function(){
this._xscale = 70;
this._yscale = 70;
};
this.onRollOut =function(){
delete this.onEnterFrame
this._xscale = 70;
this._yscale = 70;
};
this.onRollOver =function(){
this.onEnterFrame = function(){
if(this._xscale <= 110){
this._xscale++;
this._yscale++;}};};
if i have a row of mc (8) on a line that i want this script to work for do i need to have this script written out for (8) mc's or, on the root timeline?
also for more than one mc, am i just changing (this) to what ever the name of the mc is?
also instead of mc's will this script also work for buttons? or do i need to just put a hidden button over the top of this mc?
Try this maybe?
MovieClip.prototype.scaleIt = function(XscaleSize, YscaleSize) {
this.onEnterFrame = function() {
this._xscale += (XscaleSize-this._xscale)/5;
this._yscale += (YscaleSize-this._yscale)/5;
trace(this._xscale);
trace(this._yscale);
if (Math.abs(this._xscale-XscaleSize)<1 && Math.abs(this._yscale-YscaleSize)<1) {
delete this.onEnterFrame;
trace('im done');
}
};
};
movieClipName.onRollOver = function() {
this.scaleIt(150, 150);
};
movieClipName.onRollOut = function() {
this.scaleIt(100, 100);
};
pkcidstudio
September 23rd, 2005, 04:28 PM
Try this maybe?
MovieClip.prototype.scaleIt = function(XscaleSize, YscaleSize) {
this.onEnterFrame = function() {
this._xscale += (XscaleSize-this._xscale)/5;
this._yscale += (YscaleSize-this._yscale)/5;
trace(this._xscale);
trace(this._yscale);
if (Math.abs(this._xscale-XscaleSize)<1 && Math.abs(this._yscale-YscaleSize)<1) {
delete this.onEnterFrame;
trace('im done');
}
};
};
movieClipName.onRollOver = function() {
this.scaleIt(150, 150);
};
movieClipName.onRollOut = function() {
this.scaleIt(100, 100);
};
does this get placed onto the root level as well. and then it is just written as manny times as there are buttons or mc? also what is
trace('im done');
ElectricGrandpa
September 23rd, 2005, 04:42 PM
trace('im done'); just outputs the message to the output window. You can place his code in the main timeline.
-Matt
rhamej
September 23rd, 2005, 04:44 PM
Ya, place it in the _root. You can call that prototype as many times as you want.
trace is just a debugging tool built in flash. It allows you to check to see if your code is working. I used it to make sure the onEnterFrame was deleting so it wouldnt kill the cpu if you applied the prototype to say 100 mc's at the same time :)
pkcidstudio
September 23rd, 2005, 04:55 PM
fanks alot yall, i thank you
ITS FRIDAY-
pkcidstudio
September 23rd, 2005, 05:20 PM
since my fla file was to big i made a smaller one that i hope you guys an gals can look at an maybe help me out. this is much smaller version of what i am trying to do. but if this could work then i could know what i am supposed to do. so if you are up for it please take a look.
LostBear
September 23rd, 2005, 06:51 PM
thats a massive amount of code.....*scratches head*
....must be an easier way.
rhamej
September 23rd, 2005, 07:45 PM
You cant start instance names with numbers, and you dont need to duplicate the prototype.
pkcidstudio
September 24th, 2005, 07:03 PM
You cant start instance names with numbers, and you dont need to duplicate the prototype.
you the man, you the man. thank you for your help.
see you all on monday-
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.