author: Krasimir Tsonev

Hi there, I'm . Senior front-end engineer with over 13 years of experience. I write, speak and occasionally code stuff. Follow me on Twitter, GitHub, Facebook or LinkedIn

5 useful ActionScript 3 tips

Sometimes, when you work on some project, you find something that is small, but very interesting and useful. Usually I'm adding such kind of things in classes that I like to call helpers. The following tips are part of my helpers.

Change the fill color of a MovieClip

function setMovieClipColor(clip: MovieClip, color: uint): void {
  var ct: ColorTransform = new ColorTransform();
  ct.color = color;
  clip.transform.colorTransform = ct;

Convert color from uint to hex

var color:uint = 0xff0000;
trace(color.toString(16)); // -> ff0000;

Remove all the children of a MovieClip

  function removeAllChildren(movie: MovieClip): void {
    var numOfChilds: int = movie.numChildren;
    while (movie.numChildren > 0) {
      if (movie.getChildAt(0)) {
        if (movie.contains(movie.getChildAt(0))) {


public function create(handler: Function, ...args): Function {
        return function (...innerArgs): void {
          handler.apply(this, innerArgs.concat(args));

Date validation

public function validateDate(day: Number, month: Number, year: Number): Boolean {
        var date: Date = new Date(year, month, day);
        if (date.getMonth() == month) {
          return true;
        } else {
          return false;
If you enjoy this post, share it on Twitter, Facebook or LinkedIn. Or maybe comment below: