Showing posts with label AS2. Show all posts
Showing posts with label AS2. Show all posts

21 September 2012

Loop Javascript (or Actionscript!) array based on index

Looping arrays is particularly useful for things like photo galleries and other iterative processes where you want the "next photo" button on a gallery to continue from the beginning of the album after the user passes the last photo.

In my humble opinion, I believe this functionality should be built into the core of Ecmascript ( For example, something like myArray[-2] should really return the second last element in the array) but alas we have to write it ourselves, so here goes...
Continue Reading >

11 February 2011

Actionscript/Javascript Colour mode conversion functions - convert HSB/HSL/HSV to RGB to web HEX color or to flash matrix

I wrote/found/tweaked these conversion functions today to convert between the most common colour modes. it was very difficult to find a solid source for converting colours online so I thought I'd post them here for the world. They should work in actionscript 2 & 3 and could easily be tweaked to work in php, python or any other language. Here goes...

Continue Reading >

29 June 2010

AS2: Simple, Powerful String Find & Replace all instances function for Flash Actionscript. Similar to PHP's str_replace replacement.

Exactly what it says on the tin!

AS3 version here



Continue Reading >

18 June 2010

Resize a Movie Clip containing a mask by getting dimensions of visible bounds/area and compensating width/height

This was a head wrecker and took me most of the day today. Actionscript does not see Movie Clips as we do and considers invisible content to be part of the MC. As such, when you try to resize an MC that contains masked content which extends beyond what we consider to be the edges of the MovieClip, flash makes a balls of it.

To counteract this I've written and rewritten a double function which resizes your clip based on the visible area rather than what flash considers the bounds. Here it comes...

Continue Reading >

27 April 2010

Add padding or a solid background to a Movie Clip with Flash Actionscript AS2

I wrote this little function today to add HTML style padding to a Flash MovieClip. It took a lot of testing to get working but it's actually very straight forward and quite a handy one to have in your function arsenal.

It basically draws a rectangle behind all content in the movie clip and repositions the clip on the Stage. It can also be used to add a solid background behind a given MovieClip. Implementation is a synch:

Continue Reading >

11 November 2009

AS2: PHP style trim for Actionscript 2 - with 'any' character support

Theres a few of these functions around but none (that I could find) will allow you to trim non whitespace characters so I pulled this one together which lets you trim any character you want.

//USAGE:
trace(trim(";A test;;", ";"));    //outputs: "A test" 

function trim(str:String, char:String):String{
    if(char==undefined){char=" ";}
    code=char.charCodeAt(0)
    for(var i = 0; str.charCodeAt(i) ==code; i++);
    for(var j = str.length-1; str.charCodeAt(j) ==code; j--);
    return str.substring(i, j+1);
}

09 November 2009

Free AS2 Script for Rotating Website Banner or Slideshow in Flash


This is a simple AS2 function to turn a normal flash MovieClip into a rotating banner or fading photo slideshow for a website. Timings and speeds are customisable, it works with any size images and will even work with animated content. All you have to do is put one photo on each frame of a Movie clip and the script does the rest.
Full instructions and demo below...
Continue Reading >

19 October 2009

Resize function for image or MovieClip with advanced options - Actionscript2 AS2

I found myself often needing to resize images to fit different spaces using actionscript so I wrote this handy function a while back. It allows you to quickly resize the image proportionally to fit your needs and doesn't require much thought. See usage examples below and you'll see what I mean.

Continue Reading >

14 October 2009

mySQL to Flash import class - run queries from AS2 simply & automatically

mySQL2AS package with DataGrid...

This incredibly simple tool takes 5 minutes to set up and allows you to run mySQL queries and return results to flash using Actionscript 2 just as you can in PHP or any other language. Just 3 lines at the top of your flash document make mySQL queries a single function call away.  You can loop through the results, trace them all to the output panel and even display them in a datagrid (a flash table) on the stage.
Continue Reading >

04 October 2009

Save JPG /PNG image from AS2 project using AS3 & PHP

There's a tonne of Actionscript 2 image capture scripts out there but after an extensive search last month, the best ones I could find all ran into horrible memory problems and server timeouts when trying to capture large images. So I figured out a better way...
Continue Reading >
Cron Design Studio: Dublin based web design & software development