Showing posts with label AS3. Show all posts
Showing posts with label AS3. 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 >

23 March 2012

AS3 Load external flash SWFs into a queue to play in a consecutive sequence

This script imports a text file from the local directory and imports all swfs listed in the text file to play on the stage sequentially, i.e. one after another. Its very useful for banner ads and other animations when you need to be able to slot new ads into the sequence.

Continue Reading >

17 July 2011

AS3: 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!

AS2 version here



Continue Reading >

AS3: Wave of values class function - produces incremental and decremental values

Sometimes it's necessary to have a value increment until it gets to a certain point and then have it decrement again in a wave shape. A simple Math.sin() calculation will work in some cases but its not easy to control the increment using that method. This handy & simple class makes it quick and easy to do just this. There's lots of room for improvements & additions so feel free to post updates :)

Continue Reading >

05 June 2011

AS3 handy weighted random & rounding functions with decimal/floating point precision

Like a lot of the "improvements" Adobe made to Actionscript with AS3, the Math.random() function is now a pain in the ass. It only generates a floating point number between 0 and 1 so 99% of the time, you need a few lines of code to get your random on.
With time saving in mind, I've written this weighted random function which makes beautiful randomness a lot handier to implement. For best results throw this in a class package and include it in every project.
Here it comes...

Continue Reading >

18 April 2011

AS3 function to rotate a 2D or 3D MovieClip or Sprite around its center or change to any registration point

OK here we go - I looked everywhere for this one but only found bits of code from various forums and blogs that were part of classes and packages and as such, full of dependent variables. Anyway, after a bit of advice from the very helpful community at StackOverflow and a bit of tinkering, she's up and running!

The function below will rotate a DisplayObject around any point on a 2D or 3D plane. This is particularly useful for rotating around an object's center point so this is the default behaviour. Enjoy!

Continue Reading >

13 February 2011

Actionscript 3: Better Random Function & Better Rounding Function

I was amazed at how lame the rounding and random functions are in AS3 so I've written 2 simple functions to add much needed functionality. Enjoy...
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 >

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