Skip to main content
Participant
December 15, 2020
Question

Random fireworks effect

  • December 15, 2020
  • 1 reply
  • 297 views

Hi,

I have created a simple movieclip with a fireworks explosion, and added a "this.stop" in the end of the clip.

 

Now I would like this clip to be played randomly in the background of my webbanner. I can easely add it myself to the stage on various positions on the timepline multiple times and play it, but there must be a more simle way to script this?

The clips needs to be randomly scaled as well.

 

Another really alternative is using javascript / createjs to draw all particles, there are som really cool stuff people make with css/js in tutorials, but I dont know how to implement these features in Adobe Animate.

 

Best regards,

Mikkel Svensson

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    December 15, 2020

    assign a linkage id (eg, MC), adjust parameters (timing, position, scaling) and use:

     

    var mc;
    var counter = 10*Math.random();
    createjs.Ticker.addEventListener("tick",f.bind(this));


    function f(){
    if(createjs.Ticker.getTicks()>counter){
    mc = new lib.MC();
    mc.x = Math.random()*(stage.canvas.width-50);
    mc.y = Math.random()*(stage.canvas.height-50);

    mc.scaleX = mc.scaleY *= Math.random();
    this.addChild(mc);
    counter = createjs.Ticker.getTicks()+ 10*Math.random();
    }
    }