Check out "Do you speak JavaScript?" - my latest video course on advanced JavaScript.
Language APIs, Popular Concepts, Design Patterns, Advanced Techniques In the Browser

Pattern fill with AS3 (repeat-x)

Currently I'm working on an AIR application and in the header of it there is a nice gradient which has to be repeated by the x axis to fill the whole screen area. One way to do it is to use a really wide image, something like 2000px. The other way is to use a simple trick and repeat a small part with the gradient.

function drawBackground(): void {
    var clip: MovieClip = new GradientMovieClip();
    var bd: BitmapData = new BitmapData(clip.width, clip.height, true, 0xFFFFFF);
    // set the color to 0xFFFFFF if you use transparent png file for the pattern
    bd.draw(clip);;;, 0, widthOfTheScreen, heightOfTheScreen);;
If you enjoy this post, share it on Twitter, Facebook or LinkedIn.