PDA

View Full Version : variable quesiton.



jeremy*
November 17th, 2002, 09:18 PM
Is it possible to give a variable to the _xscale of a given MC.?
i wonder because I ran into a problem with this example:

this is just a simple experiment file I was messing with, here's the problem.
I have a MC, that i want to be able to modify the xscale by an input box and button. basically the user inputs a value, presses the button, and the _xscale of the MC chages to what they put in the input box.
so my MC is named graph.
the input box has a var of xsize.
the button works fine if I use
on release
graph._xscale = xsize

but when I try to give graph._xscale a variable like MCsize

on release
MCsize = xsize

that doesn't work.

is it my syntax or just that I can't give a property of a MC a variable name?

Mr. X
November 18th, 2002, 03:27 AM
you seem a bit confused about what a variable is. It is just a container for whatever you want... You can assign virtually anything to a variable.
I wish I could help but your questrion is a little vague...
What "doesn't work"?

All that MCsize = xsize; does is to assign the value of xsize to MCsize and you can check that this is working with: trace(youVariable); in your script.

Try to think you're assigning values to variables instead of "giving a variable to" properties and other components. It should help you a little.

jeremy*
November 18th, 2002, 04:16 AM
I think my confusion lies in that I thought i could assign
a variable of MCsize = graph._xscale.
and then modify it by another action.
like a button....example:
on release
MCsize = 55.
which would change the xscale to 55

when I do that, and I debug it...it shows that there is the
correct value of MCsize, but the xscale of graph movie clip has not been changed to 55.

I am confused because my graph movie clip is not scaling when I set a new value to MCsize. so if ya can't do that and that won't work, fine, I thought I could......but if you can do that....how?

Mr. X
November 18th, 2002, 04:34 AM
whenever you write:
variable = value;
you assign the value to the variable.
when you write:
MCsize = graph._xscale;
you're assigning the value graph._xscale to MCsize.
you want to do graph._xscale = MCsize;

But they're many other things that could go wrong with variables (scope, life span, etc...) and I would recommended reading "ActionScript, the definite guide" (o'reilley) to get the basic ideas of variales, functions, etc... If not you'll waste time/get frustrated.
Hope that helps. :)

jeremy*
November 18th, 2002, 05:38 AM
thanks again, that was the problem.....I have a friend that can let me borrow that book, I guess I will have to check it out.


thanks again.