[MX] Modify scale and alpha of image via input txt boxes

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:

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).

Thanks for your time but unfortunately it still doesn’t work…

D :beam:

May I see your FLA, sir.

:hat:

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 :frowning: and zipped it’s 180 kb … please help
Thanx,

D

Here, let me give you an FLA instead showing you how it’s done.

All I can say is thanks a lot for taking the time to help me, you are an angel :beam:

D :slight_smile:

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.

Thank you very much - I understand now how it works :beam: …

D :slight_smile: