Hi;
Here's code that I found online:

package
{
    import flash.display.MovieClip;
    import flash.utils.setInterval;
    import flash.utils.clearInterval;
    
    public class Fire extends MovieClip
    {
        private var mcFlameContainer:MovieClip;
        
        private var nStageWidth:Number = 550;
        private var nStageHeight:Number = 400;
        
        private var uintMakeAFlame:uint;
        //private var uintCheckStars:uint;
        
        public function Fire ( ) 
        {
            
            mcFlameContainer = new MovieClip ();
            addChild(mcFlameContainer);
            _addRootFlame();
            uintMakeAFlame     = setInterval ( _addNewFlame, 125 );

        }
        
        private function _addRootFlame ( ) : void
        {
            var flameStatic:flame = new flame ( );
            mcFlameContainer.addChild(flameStatic);
            flameStatic.y = 190;
            flameStatic.x = 200;
        }
        
        private function _addNewFlame ( ) : void
        {
            var flameNew:fireBall = new fireBall ( );
            mcFlameContainer.addChild(flameNew);
            flameNew.y = 200;
            flameNew.x = 200;
        }
    }
}
        

Here's how I've tweaked it with your help:

package
{
    import flash.display.MovieClip;
    import flash.utils.setInterval;
    import flash.utils.clearInterval;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import fireBall;
    
    public class Fire extends MovieClip
    {
        private var mcFlameContainer:MovieClip;
        private var i:Number = new Number(0);
        private var kids:Number = new Number();
        private var t:Timer = new Timer(15, 10);
        
        public function Fire() 
        {
            t.start();
            mcFlameContainer = new MovieClip();
            addChild(mcFlameContainer);
            t.addEventListener(TimerEvent.TIMER, _addNewFlame);
        }
        
        private function _addNewFlame(event:TimerEvent):void
        {
            var flameNew:fireBall = new fireBall();
            mcFlameContainer.addChild(flameNew);
            flameNew.y = 200;
            kids = mcFlameContainer.numChildren;
            flameNew.x = 20  + (kids * 10);
        }
    }
}

The problem is this new code creates fireBalls that move up on the screen, 
whereas it should "remember its history" and keep a bunch of fireBalls together 
to give the appearance of a flickering flame. That is, each fireBall in the 
group of fireBalls that make up one iteration of the timer (of which there are 
10) should remain on the screen until they go up (incrementing the y positional 
value) to a certain height, whereupon they disappear. They don't do that. Only 
one fireBall goes up. I assume the reason for that is the following line:

            uintMakeAFlame     = setInterval ( _addNewFlame, 125 );

How do I get all those fireBalls to stay put with the new code?
TIA,
John
PS Here's the code for those fireBalls:

package {
    import flash.display.MovieClip;
    import flash.utils.setInterval;
    import flash.utils.clearInterval;
    import flash.filters.GlowFilter;

    public class fireBall extends MovieClip
    {
        private var uintMovefireBall:uint;

        public function fireBall()
        {
            uintMovefireBall = setInterval (_movefireBall, 8.5);
        }
        private function _movefireBall( ):void
        {
            this.x += Math.random()-.5;
            this.y -= 1;
            this.width -= .45;
            if (this.width<1)
            {
                clearInterval(this.uintMovefireBall);
                parent.removeChild(this);
            }
        }
    }
}


      

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to