Flash5(help w/ motion actionscript)

Hi,

I was reading the “XY motion tutorial” and I am interested to know how to I create diagonal motion when two button is pressed simultaneously?

Another question concerning the “Random motion tutorial” is what logical step did you take to come up with the “norm” variable? I notice that the motion becomes jumpy when “norm” was taken out.

Thank you for the help
kingvai

Well, about your first question, you’ll have to change your code quite a bit. In the tute, the problem is that one on (press) suppresses the other when you press 2 keys, so what you’ll have to do is something like this:[list][]When the user presses a key, you set a variable to one, for instance if he presses the let arrow, you set left to 1. You do the same for all 4 arrows[]You declare the corresponding on (release events) that will reset the values to 0[*]You have a separate enterFrame that handles the motion. This enterFrame checks whether any of the 4 variables (left, right…) is equal to 1, and if so, move accordingly[/list]I hope you see what I mean :slight_smile:

And about the norm variable, it is simple trigonometry if I remember correctly.

pom :cowboy: