PDA

View Full Version : [MX] Modify scale and alpha of image via input txt boxes



Demonia
July 23rd, 2003, 06:53 AM
I really need some help please. I have just started learning AS from this book and am having a little trouble. I have to make a thingie whereby when u enter values into 2 input txt boxes an image modifies its scale and alpha accordingly. Now I have done everything I am supposed to but the funny thing is NOTHING happens. I'll post the code (I applied it to the button which I think is right)...

on (release, keyPress "<Enter>") {
if (_root.scale>100) {
gotoAndPlay(1);
} else {
myClip._alpha = "opacity";
myClip._yscale = "scale";
myClip._xscale = "scale";
}
}

The script on frame 1 is

scale = " ";
opacity = " ";
_root.myClip._alpha = 100;
_root.myClip._yscale = 100;
_root.myClip._xscale = 100;

and on frame 2

stop ();

I need to figure this out cause I don't see the point of going on if i don't understand what's wrong with this...

Thanks a billion,

D :beam:

thoriphes
July 23rd, 2003, 07:26 AM
First off, you're setting the scales to a string, "scale", not the variable, so kill the quotes. Now with text boxes, the value in any textbox will always be a string, so you have to do a little type conversion. In this case, you want Number(value);

so change this:
myClip._alpha = "opacity";
myClip._yscale = "scale";
myClip._xscale = "scale";
to this:
myClip._alpha = Number(opacity);
myClip._xscale = myClip._yscale = Number(scale);


Lastly with the textboxes, make sure that their variables are set, not just the instance name, to "scale" or "opacity" (w/o quotes).

Demonia
July 23rd, 2003, 07:32 AM
Thanks for your time but unfortunately it still doesn't work...

D :beam:

thoriphes
July 23rd, 2003, 08:12 AM
May I see your FLA, sir.

:hat:

Demonia
July 23rd, 2003, 08:24 AM
Please do not look at the design ... I just plonked some stuff in there to try and do this (in other words it looks like it's been put together by a rhino) :sigh:

I don't know how to get it to you cause it;s 220 kb :( and zipped it's 180 kb ... please help
Thanx,

D

thoriphes
July 23rd, 2003, 08:51 AM
Here, let me give you an FLA instead showing you how it's done.

Demonia
July 23rd, 2003, 09:42 AM
All I can say is thanks a lot for taking the time to help me, you are an angel :beam:

D :)

thoriphes
July 23rd, 2003, 10:15 AM
Here you go, sorry for the delay, i'm at work so i have to balance everything out.

Anyway, I put this together real quick, but it works.

Pay close attention to all the details in this movie, including variable names, instance names, actions, etc.

Demonia
July 23rd, 2003, 10:20 AM
Thank you very much - I understand now how it works :beam: ...

D :)