Image

Imagepinkdagger wrote in Imageflashdev

Actionscript: Moving left and right

Hello,
I'm sorry this is very basic and I may just seem dense. I'm in a first year interactive arts and science course and was given this code to manipulate:

var garg1:MovieClip = attachMovie("gargoyle","garg1",1) ;
garg1._x = 300 ;
garg1._y = 300 ;
garg1._xscale = 20 ;
garg1._yscale = 20 ;
garg1._xscale *= -1 ; // reverse direction of gargoyle image

var g1xv:Number = 5 ;



onEnterFrame = function () {

// update x of gargoyle
garg1._x += g1xv ;



// check gargoyle boundaries and reverse direction/scale if needed

// see if going off right boundary, if so negate velocity
if (garg1._x > Stage.width) {
g1xv *= -1 ; // reverse direction of gargoyle
garg1._xscale *= -1 ; // reverse direction of the image
}

// see if going off left boundary, if so negate velocity
if (garg1._x < 0) {
g1xv *= -1 ; // reverse direction of gargoyle
garg1._xscale *= -1 ; // reverse direction of the image
}

}

As you can see, it also came with explanation. When classmates and I copied this to our ActionScript windows and previewed the animation, it didn't move. However, as far as I can see, there is nothing wrong with the code. The example our professor posted had the animation moving fine, but nothing happens with ours. Did we miss something? :(

I'm currently using Flash MX. TIA.