Skip to content

dbackeus/actionscript-prototypes

Repository files navigation

Description

Sweet prototypes for actionscript that extend core classes with stuff to make your life easier.

In need of documentation and is under quite heavy development.

Usage

Move the prototypes directory over to your .fla directory or add a classpath so your compiler can find it.

Import the namespace before including:

import prototypes.*

Include everything with:

Prototype.includeAll()

Include all functions from a specific prototype by:

MovieClipPrototype.includeAll()

Include a specific function from a specific prototype by:

MovieClipPrototype.include( "isMouseOver" )

The last one remains quite untested at the moment so can’t promise that it works.

Gotchas

To use the extensions on Number directly on a number without using a variable you need to enclose it in parenthesis or the compiler will shoot syntax errors at you.

// Syntax error
trace( 1.day.ago )

// Works just fine!
trace( (1).day.ago )

// Also works
var n = 1
trace( n.day.ago )

Sometimes you might want to use each on a non variableized array. The flash compiler has some truly weird behaviour when it comes to this. Here’s the breakdown.

// Silent failure with adobe compiler, works with MTASC given that you specifically ended the previous line with a ;
['asdf', 'qwer'].each( function(element) { trace(element) } )

// Enclosing the whole thing in parenthesis makes it work on both compilers
(['asdf', 'qwer'].each( function(element) { trace(element) } )) 

// Works with the adobe compiler but not with MTASC
new Array('asdf', 'qwer').each( function(element) { trace(element) } ) 

// Pre assigning the array to a variable always works
var a = ['asdf', 'qwer]
a.each( function(element) { trace(element) } )

About

Bunch of handy prototypes to make actionscript development easier. Inspired by ruby, rails and jQuery etc.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published