Is This Right

Hey can somebody chek this code out, for some reason it has no syntax errrors but it does not make my character(Sonic) move.
This Code is in the actions frame on my Properties Layer Below that layer is the layer with sonic on it.

right now im just worried about making him move.

/////Moving left And Right/////
if (Key.isDown(Key.RIGHT)) {
if (_root.Sonic.Xspeed<30) {
_root.Sonic.Xspeed += 3;
}
_root.Sonic.Right = true;
} else if (Key.isDown(Key.LEFT)) {
if (_root.Sonic.Xspeed<30) {
_root.Sonic.Xspeed -= 3;
}
_root.Sonic.Right = false;
} else {
/////Friction/////
if (_root.Sonic.Rolling=false) {
_root.Sonic.Xspeed *= 0.7;
} else if (_root.Sonic.Rolling == true) {
_root.Sonic.Xspeed *= 0.9;
}
}
/////Where To Be/////
x=_root.Sonic._x+_root.Sonic.Xspeed
y=_root.Sonic._y+_root.Sonic.Zspeed
_root.Sonic._x=x
_root.Sonic._y=y

Is that all the code you have? If so, you should define ‘Xspeed’ first. And I don’t know what your fla looks like, but the way you build your code, you should have a 2nd frame that says ‘gotoAndPlay(1);’

if in the actions layer, shouldn’t you have a _root.onEnterFrame = function(){} with all that in it, thats what i do anyways

Thanks Alot!

Dauntless you solved my problem all i need was a “gotoAndPlay(1)” on my next Frame.
Dr. Warm , not sure what that would do but thanks any ways.

Dr warms way is actually better… If you write your code like this:

this.onEnterFrame = function(){
 /////Moving left And Right/////
 if (Key.isDown(Key.RIGHT)) {
 if (_root.Sonic.Xspeed<30) {
 _root.Sonic.Xspeed += 3;
 }
 _root.Sonic.Right = true;
 } else if (Key.isDown(Key.LEFT)) {
 if (_root.Sonic.Xspeed<30) {
 _root.Sonic.Xspeed -= 3;
 }
 _root.Sonic.Right = false;
 } else {
 /////Friction/////
 if (_root.Sonic.Rolling=false) {
 _root.Sonic.Xspeed *= 0.7;
 } else if (_root.Sonic.Rolling == true) {
 _root.Sonic.Xspeed *= 0.9;
 }
 }
 /////Where To Be/////
 x=_root.Sonic._x+_root.Sonic.Xspeed
 y=_root.Sonic._y+_root.Sonic.Zspeed
 _root.Sonic._x=x
 _root.Sonic._y=y
} 
stop();

There is no need for the second frame. All the actions are preformed in 1 frame.

Yeah the other way, in two frames was used in flash 5 and before, not that there’s anything wrong with that. I’m guessing you just hold an old tutorial or something.