samedi 10 décembre 2016

How do I stop automatic stretching of the other axis for instances when stretching one of its axis?

When applying code for a laser weapon projectile (an instance of the laser beam itself) which would enable the laser to to act similarly to that of a real one, I had everything working great... except for the fact that the projectile kept stretching in the y axis as well as the x axis, instead of just the x axis. Now, I've found out that something like scaleMode needs to be disabled, but the best I've found is a line of code that goes like "stage.scaleMode = StageScaleMode.NO_SCALE;", which is meant for the stage and not instances themselves and if I tried to apply something like this for an ADDED event within the laser beam's class code I get error 1120 saying . Here is the code I think is necessary to present here from the beam's class:

package
{
    import flash.display.MovieClip;
    import flash.events.*;
    public class weapon3projectileCode extends MovieClip
    {
        private var _root:Object;
        public function weapon3projectileCode()
        {
            addEventListener(Event.ADDED, beginClass);
        }
        private function beginClass(event:Event):void
        {
            _root = MovieClip(root);
            this.scaleMode = StageScaleMode.NO_SCALE;
            this.scaleX = .25;
            this.scaleY = .2;
        }
        private function entFrame(event:Event):void
        {
            if (_root.gamePaused == false)
            {
                x += speed;
                if (stretchWhile < stretchTill)
                {
                    this.width += 25;
                    this.x = _root.playerShip.x;
                    this.y = _root.playerShip.y;
                }
                else if (stretchWhile < shrinkTill)
                {
                    this.width -= 25;
                }
                else if (stretchWhile >= shrinkTill)
                {
                    this.width = .25;
                    removeEventListener(Event.ENTER_FRAME, entFrame);
                    _root.projectilePlayerContainer.removeChild(this);
                }
                stretchWhile ++;
                if(this.x > (stage.width+ this.width))
                {
                    removeEventListener(Event.ENTER_FRAME, entFrame);
                    _root.projectilePlayerContainer.removeChild(this);
                }
            }
            if (_root.removeProjectiles == true)
            {
                removeEventListener(Event.ENTER_FRAME, entFrame);
                _root.projectilePlayerContainer.removeChild(this);
            }
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire