English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

alphaClip = function (mc, newAlpha) {
var currentAlpha = mc._alpha;
mc.onEnterFrame = function () {
trace("ok " + mc._alpha)
currentAlpha += (newAlpha - currentAlpha) / 2;
mc._alpha = currentAlpha;
}
}
scaleClip = function (mc, newSize) {
var currentSize = mc._xscale;
mc.onEnterFrame = function () {
currentSize += (newSize - currentSize) / 2;
mc._xscale = mc._yscale = currentSize;
}
}

stop();


CALLED BY:

on (rollOver) {
_parent.alphaClip(this, 100);
_parent.scaleClip(this, 175);
}
on (rollOut) {
_parent.alphaClip(this, 40);
_parent.scaleClip(this, 100);
}

2006-11-12 04:15:32 · 3 answers · asked by ted20two 1 in Computers & Internet Programming & Design

3 answers

Ok, first off...ignore the last guy who was telling you to replace "this" with "_root", he's completely wrong. The actionscript community has been trying to kill "_root" completely for years now (since about version 4!)..."this.yourmovieclip" is exactly the correct format to be using.

However unfortunately, I believe your syntax is falling down because you are trying to use an onEnterFrame function within a function...this is not a good way to do things. By examining your code it appears that you are trying to have two functions, one that eases the alpha up and down and the other that does the same with the scale - am I correct?

Well a good way to do it would be to use the mx.transitions functions (they're easy to understand)...the format would be something like this...

function tweenIt (myMC, theType, startValue, endValue) {
//set up the ease type...look in the flash help file for further options
easeType = mx.transitions.easing.Back.easeIn;
//set the length of time of the tween in seconds
time = 1;
//the main tween code (told you it was simple!)
myTween = new mx.transitions.Tween(myMC, theType, easeType, startValue, endValue, time, true);
}

and call it with something like:

on (rollOver) {
//get the current values
currentAlpha = this._alpha;
currentScale = this._xscale;
//call the function
_parent.tweenIt(this, "_alpha", currentAlpha, 100);
_parent.tweenIt(this, "_xscale", currentScale, 200);
}

you could even move the current value calculation to within the function and eliminate the need to pass the starting value to the function entirely.

Either way, by using mx.transitions you've eliminated the need to use an onEnterFrame loop (which are now considered to be memory hungry, old fashioned and unusable by many) and there will be no function clashes.

Even mx.transitions is considered old nowadays, but at least it will solve your problem. Good luck!

2006-11-13 04:39:44 · answer #1 · answered by gromitski 5 · 0 0

it fairly is the broadest question i've got have been given ever seen asked....... you will no longer probable answer it in a Yahoo! answer. What i'd propose, is dedicate approximately six months to interpreting Macromedia Flash by potential of ability of figuring out to purchase for some books from amazon. Flash isn't something you are able to %. up in a weekend in case you prefer to construct video games. useful you will have the flexibility to create your first flash action photograph in approximately an hour, yet it fairly is a techniques a techniques a techniques from a game. Flash game programming is the main appropriate complicated flash to do. the respond on your 2d question is: click checklist -> placed up.

2016-12-10 07:45:37 · answer #2 · answered by motato 4 · 0 0

First off try to avoid using "this". It can screw things up when you think that is on something but its not. Instead use the actual instance name.

Another thing... For all of your variables add _root. to teh beginning. This will allow them to be accessed throughout the flash file. Also when using an instance name use _root.

So if your button was called dog then use _root.dog

2006-11-12 04:20:01 · answer #3 · answered by Helper123 3 · 0 1

fedest.com, questions and answers