PDA

View Full Version : (fmx) need help with _xscale



kUHAr
May 13th, 2003, 08:25 AM
Why won't this work??

on(rollOver){
no = i = 0;
while (i<10) {
for(n=0;n<100;n++){}
no = 100 + i;
setProperty("1", _xscale, no);
setProperty("1", _yscale, no);
setProperty("1", _alpha, (80 + i));
i++;
}}
on(rollOut){
no = i = 0;
while (i<10){
for(n=0;n<100;n++){}
no = 110 - i;
setProperty("1", _xscale, no);
setProperty("1", _yscale, no);
setProperty("1", _alpha, (90 - i));
i++;
}}

i wrote that for one of the buttons but it wont work!!
-it skips all in between, at first its i=0 and then i=10, nothing in between, i can't make it to change slowly!
PLZ help!

zylum
May 13th, 2003, 05:37 PM
what exactly are you trying to do?

lostinbeta
May 13th, 2003, 05:47 PM
You can't scale button symbols (I don't think) so you will need to use a movie clip symbol as a button.

Create your button and convert it to a movie clip symbol. Give it the instance name "myButton" (no quotes).

Apply these actions to a frame...

MovieClip.prototype.easeScale = function(finalWidth, finalHeight, speed) {
this.onEnterFrame = function() {
this._width += Math.floor((finalWidth-this._width)/speed);
this._height += Math.floor((finalHeight-this._height)/speed);
};
};
myButton.onRollOver = function() {
this.easeScale(200, 200, 3);
};
myButton.onRollOut = function() {
this.easeScale(100, 100, 3);
};


It uses the easing equation to create a function, then that function is called on rollOver and on rollOut of the myButton instance name. The first parameter is the width, the second parameter is the height, and the third parameter is the speed.

Hawk
May 13th, 2003, 09:54 PM
wow, i just totally understood prototypes from that post, lost...

holy... cow

(not totally) but still... thats cool

lostinbeta
May 13th, 2003, 09:58 PM
Hawk: You might have to further research if you don't know the different between a prototype function and a standard function. There is a major difference between them and I am not that great at explaining things so I am not really the guy to do it.

I am glad my post helped you to better understand the use of prototypes though :)

Hawk
May 13th, 2003, 09:59 PM
yea, well something just clicked... although it could have been my shoulder, which has been bothering me all day :P

i will research them, they look extremely useful

lostinbeta
May 13th, 2003, 10:12 PM
They are very useful. Some of my favorite things to use are functions and prototypes :beam:

Felipe Bastos
May 16th, 2003, 09:24 PM
Hi Lostinbeta
I was experimenting your code and look what the output says:

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: Statement must appear within on/onClipEvent handler
MovieClip.prototype.easeScale = function(finalWidth, finalHeight, speed) {

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 7: Statement must appear within on/onClipEvent handler
myButton.onRollOver = function() {

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 10: Statement must appear within on/onClipEvent handler
myButton.onRollOut = function() {

I put the code in a frame inside the movieclip. Is it correct?

lostinbeta
May 17th, 2003, 12:22 AM
You have to put the actions on a frame on the timeline that contains the movie clips you are targetting.

The errors it is giving you is because you are trying to put it on the movie clip directly, you can't do that. And you can't put the actions inside the movie clip itself because that will mess up the targetting. So you should put them on the timeline that contains the movie clip symbols you are using for buttons.

Felipe Bastos
May 17th, 2003, 12:50 AM
Ok lostinbeta. It worked out! But the Output still shows the same code problems:

I just copied and pasted the code you wrote.

"Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: Statement must appear within on/onClipEvent handler
MovieClip.prototype.easeScale = function(finalWidth, finalHeight, speed) {

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 7: Statement must appear within on/onClipEvent handler
myButton.onRollOver = function() {

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 10: Statement must appear within on/onClipEvent handler
myButton.onRollOut = function() {

:(

lostinbeta
May 17th, 2003, 01:19 AM
You either...

A) Are exporting your movie as Flash 5 (by either using Flash 5, or if you are using MX then go to File/Publish Settings and check the Flash tab to see what your exporting as)

or

B) Are still putting the code on the movie clip symbol. The code is meant to go on a frame not a symbol.

Felipe Bastos
May 17th, 2003, 02:15 AM
I got it.
I put it on a frame but in the movieclip timeline.
It has to be in a main timeline frame.
Now it works.

c u