PDA

View Full Version : need a hand with simple textfield excercise


s-cody
08-25-2005, 05:11 PM
hi, i know i'm a total jerk plus freshman so please someone help me with this very simple problem so that i would practically learn something and know more how to sort the script out ( because i got no clue whenever it reports errors to use handler). one more important thing i only have AS 2.0

here it goes: we got a movie clip named "my_mc". what to do is to move it randomly in the stage ( suppose each move is no more than 4pixels from the last position).next, create a textfield which shows my_mc's position and another one which moves along with my_mc also shows its position

here is my analyse:
//first attach or load or make a "my_mc"
//set 2 variables my_x and my_y for the clip (hey i wonder if this could be mistaken with _x and _y property)
//i'd like to assign new value to these vars for each new move: my_x+=Math.round(Math.random()*4)
//to make my_mc move using my_mc.moveTo(my_x,my_y)
Man i got all panic over here. i don't have a single clue of sticking them together, of what i should do after giving the value and before making it move, how flash knows that those my_x and my_y are the new ones, not those which i set at first place

phew, that's it. i would like to have all things cleared about this my_mc to move first before taking the next part to do with the two textfield, and could you help me with where and when to put the handlers on? whenever i start a simple code by my own, 98% it goes with "the statement must be within a event handler" and kinds of.

thanks soooooo much :)

Ricod
08-27-2005, 11:59 PM
Welcome to AS[org] !

moveTo is part of the drawing API. It's not used to move a clip around. You can do so by altering the value of the _x and _y properties of the mc you wish to move around :
my_mc._x += Math.round(Math.random()*4);
my_mc._y += Math.round(Math.random()*4);

You can alter the text of your dynamic textbox :

my_dynamic_textbox.text = "x: "+ my_mc._x + ", y: "+ my_mc._y;

If you don't have Flash but use something else like PHP, you can still use the livedocs at Macromedia's website to read the manual.