Here is one file that pop out of my archive. It is Flash scale menu done with some simple math in as1.
08 September 2007
Flash Scale Menu
words by flanture at 5:15 PM
Labels: actionscript, examples, flash, fun
Subscribe to:
Post Comments (Atom)
small educational projects
Here is one file that pop out of my archive. It is Flash scale menu done with some simple math in as1.
words by flanture at 5:15 PM
Labels: actionscript, examples, flash, fun
template by blogger templates
15 comments:
I'm a little lost-- this sounds so simple-- but I can not for the life of me figure this out-- what is the relationship of the numbers(besies those related to"i") to the images/movie clips in the scene?
please help... I'm using FLASH 8.0 BASIC.. thank you so much.
hello Francesco and thanks for your visit,
here is short explanation
dx is imaginary circle, distance when movie clips begin to react to mouse move. You can see in if..else that when distance (d) is smaller than 70, scale of particular movie clip is changing, and if it is bigger or equal to 70 it remains 100, meaning no change.
d is mathematical formula that finds distance between mouse pointer and center of particular movie clip at any enter frame action.
scale have value 100 + (dx - d) which means: closer the mouse pointer to center of movie clip, bigger the scale.
I hope this helps
Flanture
does dx's value of 50 have a specific pixel relation to the size of the movie clips?
also in the formula 100+(dx-d)
does the 100 have a specific relation to the movie sizes?
I'm trying to get this right and for some reason when the movie is tested the 2nd clip is the only one that reacts, but then the whole movie stops as soon as clip 2 enlarges...
A special thank you by the way for such a speedy response. I really appreciate the help...
oops-- I forgot to tell you the dimensions of my clips...
each clip is 122 x 122 square.
in the scene, I have reduced their starting size to 40 x 40
and they are about 75 pixels apart from one another.
hi,
you can change dx to whatever you want, i don't think 50 is something special.
in formula, yes, 100 means movie clip size of 100%, that's why it is 100
please remember that in order to work this out, registration points of movie clips should be at center of those movie clips. This is crucial, because calculation is made in relation to that point !!!
Flanture
that's it I think, reducing original movie clips sizes is making you a problem. Use original size just to test it and see if that's the bug
ok, everything is in place...
but I still only get the "scale up" of the first clip to work and then the movie freezes.
I have 5 clips called ""item1, item2, etc. to item5.
This is the script I have so far...
_root.onEnterFrame=function() {
for(i=0;i<6;i+=1) {
_root["item"+1].onMouseMove=function() {
d = Math.sqrt(Math.abs(_xmouse-this.x) *
Math.abs(xmouse-this._x) +
Math.abs(ymouse-this._y) *
Math.abs(ymouse-this._y) ) ;
dx = 90;
if(d < 90) {
this._xscale = 100+(dx-d) ;
this._yscale = 100+(dx-d) ;
}else{
this._xscale = 100;
this._yscale = 100;
}
}
}
}
Thank you for your help again. This is an amazing forum!
it's clear,
you have 2 bugs: first, since your mcs are item1..item5, you for loop should follow:
for(i=1;i<6;i+=1) not i=0
second bug is in next line: _root["item"+1], should be _root["item"+i], not 1.
that will kill those bugs :)
Flanture
[Flash Adventure]
Sweet! One more question though, now all of the clips are scaling up as soon as the mouse enters the frame...
should this action be applied to:
an empty keyframe (where I have it)
or to each movie individually in the scene
or on the keyframe with the clips
or to someone that has more flash knowledge than I... (I really am trying though!)
I know it's got to be something silly!
you still there? eep. I feel like I'm so close to getting this to work...
WHat i dont understand though is if I kept the clips to their original size, what would they enlarge to if everything in the formula is based upon 100%... when I leave them at original size, the movie has no movement. If I scale them down, the movie scels them all up to 100% then stops... any ideas? Here is the new script with your corrections...
\
_root.onEnterFrame=function() {
for(i=1;i<6;i+=1) {
_root["item"+i].onMouseMove=function() {
d = Math.sqrt(Math.abs(_xmouse-this.x) *
Math.abs(xmouse-this._x) +
Math.abs(ymouse-this._y) *
Math.abs(ymouse-this._y) ) ;
dx = 50;
if(d < 70) {
this._xscale = 100+(dx-d) ;
this._yscale = 100+(dx-d) ;
}else{
this._xscale = 100;
this._yscale = 100;
}
}
}
}
Francesco, I would like to help you, but right now I have some things to do. Why don't you send me your .fla file via flanture [at] gmail [dt] com and I can look at it later. Thanks.
ok so my problem is that it only reacts on the left side of any of my MC's... they have the center of the mc designated as the center, but for some reason its acting like the center left border is the center of the mc, any help?
Hi Adam,
probably code error, check it again. Use code from post, not from previous comment which has more errors (xmouse instead of _xmouse)
Flanture
this is what i have going
_root.onEnterFrame=function(){
for(i=1; i<6; i+=1){
_root["item"+i].onMouseMove=function(){
d= Math.sqrt(Math.abs(_xmouse-this._x)*
Math.abs(_xmouse-this._x)+
Math.abs(_ymouse-this._y)*
Math.abs(_ymouse-this._y));
dx=70;
if(d < 70) {
this._xscale = 100+(dx-d);
this._yscale = 100+(dx-d);
}else{
this._xscale = 100;
this._yscale = 100;
}
}
}
}
code is OK. I can't help you if I don't see your fla file. Can you email it to me: flanture [at] gmail [dt] com ?
Post a Comment