1 Reply Latest reply on Aug 5, 2009 1:51 PM by kglad

    Question about actionscript.

    TheMskel Level 1

      I have the following actionscript code:


          import flash.display.*;
          import flash.geom.*
          import flash.events.Event;
          public class Particle extends Sprite {
              private var _xpos:Number;
              private var _ypos:Number;
              private var _xvel:Number;
              private var _yvel:Number;
              private var _grav:Number;


              public function Particle(xp:Number, yp:Number, xvel:Number, yvel:Number, grav:Number, col:uint) {
                  _xpos = xp;
                  _ypos = yp;
                  _xvel = xvel
                  _yvel = yvel
                  _grav = grav;
                  var ball:Sprite = new Ball();
                  x = _xpos;
                  y = _ypos;
                  alpha = .8;
                  scaleX = scaleY = Math.random() * 1.9 + .1;
                  addEventListener(Event.ENTER_FRAME, onRun, false, 0, true);
              private function onRun(evt:Event):void {
                  _yvel += _grav;
                  _xpos += _xvel;
                  _ypos += _yvel;
                  x = _xpos;
                  y = _ypos;
                  if (_xpos < 0 || _ypos < 0 || _xpos > stage.stageWidth || _ypos > stage.stageHeight) {
                     removeEventListener(Event.ENTER_FRAME, onRun);



      I have this animation where a monster gets it's head cut off and I want to use this code for the blood. Is there a way I can take this and put it into my timeline. Right now it only plays in the file that calls it. I want to be able to place it in my timeline right where the monster is beheaded and on that point. Thanks!

        • 1. Re: Question about actionscript.
          kglad Adobe Community Professional & MVP

          it looks like you should create a Ball class movieclip (that will look like a blood drop) and then repeatedly call Particle to create the drop of blood.  you'll need to add a parameter to pass Particle so you can add your drops to the displaylist.

          1 person found this helpful