Quantcast
Channel: Adobe Community : All Content - Adobe Animate CC - General
Viewing all articles
Browse latest Browse all 13519

positioning a random generation script in a specific area

$
0
0

I am creating an series of festive online banner ads which have a timeline controlled by AS2 (all very basic - simple fade in and move to next frame). I have sourced a random generation script to produce a twinkling effect over a section of the banner, however i would like the sparkles to appear only in a specific area of the banner, but the usual _x, _y positioning commands don't appear to work as you can see below I have managed to restrict the are they appear in but as I said not the positioning of them.  My AS knowledge is limited so I'am struggling - code for random generator is below

 

var numOfSparkles:Number = 10;

var fadeAmount:Number;

function attachSparkel() {

  var t: MovieClip = _root.attachMovie("sparkle", "sparkle"+_root.getNextHighestDepth(), _root.getNextHighestDepth());

  t._x = Math.floor(Math.random()*(310-t._width));  /*area covered*/

  t._y = Math.floor(Math.random()*(82-t._height));  /*area covered*/

  t._xscale = t._yscale=Math.floor(Math.random()*50)+80;

  t.fadeAmount = Math.ceil(Math.random()*15); /*fade speed*/

  t.onEnterFrame = function() {

  this._alpha -= this.fadeAmount;

  if (this._alpha<=0) {

  delete this.onEnterFrame;

  attachSparkel();

  }

  };

}

for (i=0;i<numOfSparkles;i++) {

  attachSparkel();

}


Viewing all articles
Browse latest Browse all 13519

Trending Articles