ActionScript 3 Marching Ants Selection Marquee

This is a simple ActionScript 3 implementation of the class marching ants selection marquee you find in applications such as Photoshop.

The class is based off this ActionScript 2 example here;?Ǭ† http://www.nocircleno.com/experiments/selection_ants_proof/index.html, but adds in many more methods and is entirely self contained. Drawing the bitmaps for the marquee internally in the class.

Features

    Either Fixed or user drawn marquee
    Draggable or static fixed marque
    Programatically changeable marquee colours
    Programatically changeable marquee line thickness
    Does not rely on library assets for marquee

View Example Here
http://www.noponies.com/dev/as3_marchingants/

Source Files
Actionscript 3 Marching Ants Marquee Version 1.0

Dependencies
None

ActionScript 3 Full Browser Slideshow

An ActionScript 3 implementation of my AS2 Full Browser XML Cross fading slideshow.

One of the main areas of concern for me when making this file is memory usage. It is pretty easy if no clean up routines are used to push the Flash player memory usage right up and over 100 megs due to the size of the images that are loaded in. To get around this I’ve used bitmap objects which I dispose of after every image cycle. This keeps memory usage to the bare minimum and frees up memory from Flash player instantly, rather than waiting around for the garbage collector to do its thing. If the bitmap approach is ditched and just a pure object deletion approach is used the garbage collector will keep the memory usage of this example down around 40-50 megs, with peaks up to 70 and lows of around 25. With the bitmap approach coupled with the object deletion memory peaks at around 30 (depending on image size) and drops down to lows of 15. Much better I think. This class attempts to keep memory usage down by creating bitmapdata objects from the loaded images. It then runs a routine to keep track of each bitmap loaded so that they can be removed when no longer needed. At most there are only ever two bitmaps in memory. As soon as a new slide is fully displayed, the old slide is removed and all vars pointing to it set to null. Memory usage stays fairly low using this approach, around 20 megs or so depending on the size of the images loaded in.

The slideshow supports a clean up routine, that deletes all objects and disposes of the current bitmap objects. The slideshow dispatches a Loaded, Beginning Load and progress event. Along with various other utility events related to changing slideshow settings.

Purpose and Intent
This class is designed for creating fullscreen background images that can be set to change or transition in the same manner as a traditional slideshow. It is however not really intended as a stand alone slideshow and as a result does not support text descriptions etc. The main idea is that this should be unobtrusive to the end user. The methods for manually loading new slides etc are primarily for developers and not really end user features. With that in mind, the slideshow does work fine if its methods are exposed to a user of your site.

Class Features

  • Change image source Array at runtime
  • Image Alignment within Stage
  • Various Public Methods for loading, pausing, resuming slideshow
  • Random or linear image progression
  • Manual or automatic (timer) image shuffling
  • Various Events
  • Memory Management
  • Looping or non looping
  • Definable Image Time
  • Definable Cross Fade Time
  • Definable Min scale size at which point the images are clipped

This is a fairly complex class. Read the class documentation and look at the included document class for the .fla for examples of how to use the various methods and respond to the various events the class dispatches. If you encounter bugs, please post them here

The download includes a .fla, a document class for that .fla, the main slideShow class and a couple of utility classes, one for parsing XML, one for creating a FullScreen Contextual menu and one for flexibly laying out the button on the stage. Along with the font used and the images used

Feel free to hit that donate button, this was a fair bit of work! Enjoy!

Updates
27 Feb, 2008: Initial Release.
01 Aug, 2008: New methods, clean up of properties, documentation, moved to using NpFSObjectResize class for scaling of images.
24 July, 2009 Fixed tween timing issues, moved events into seperate class, new names for some methods, cleaned up documentation, some refactoring of code.

In this demo, the slides are displayed for 25 secs, cross fade time of 2 secs. Slideshow is in automode and fullscreen is enabled in the host swf.

View Example
Here is an example; http://www.noponies.com/dev/as3_fullbrowser_slide/

Source Files Here are the examples source files; http://www.blog.noponies.com/wp-content/uploads/npfullbrowserxfade.zip

Dependencies
This class uses the NpFSObjectResize Class (via composition) to handle stage alignments and scaling etc.

ActionScript 3 Drag, Zoom, Pan XML Content

ActionScript 3 version of the Actionscript 2 Drag, Pan Zoom example.

Loaded content can be either bitmap, swf or whatver. SWF’s retain their full interactivity. Simply specify what content you want in the XML file. Loaded content pulls an ID parameter from the XML file which is used for sending messages to particular content instances via custom non mouseEvent events. This is demoed as a commented out line as a means of scaling up the content and shuffling a particular instance of content into the center of the screen.

This is a class based implementation of the AS2 timeline implementation. With that in mind, there are 4 core classes in total, with two supporting classes.

Class Breakdown
LayOut.as
This class does the lions work of this demo. It requires two parameters, an XML file, which is provided by the LoadXML class and an integer to specify how many columns to lay the content out into. This class also acts as a mediator in the event dispatch process between content and draggable area. Class handles panning and zooming of loaded content, along with dragging and laying content out in a grid. Within this class are a number of variables that control how the zooming behaves. This class dispatches two other events to indicate loading of content, and content has all loaded. Currently these events do no have listeners, but the framework is there to hook into, should you want to. Loading Started Event dispatchEvent(new Event(LayOut.STARTED_LOADING)); Loading Finished Event dispatchEvent(new Event(LayOut.FINISHED_LOADING));.

ZoomContent.as
This class dispatches events back to the layout class which handles all zooming and panning. eg; dispatchEvent(new Event(ZoomContent.ACTIVE_CONTENT,true));
This class also handles enabling and disabling mouseChildren for loaded content. I didn’t want interactive content to able to recieve mouseEvents when it is scaled down. This is handled by a simple rollOver function which checks the scale of the parentSprite (pass in via the constructor). Class also dispatches events to custom cursor class.”dispatchEvent(new Event(CustomCursor.MOUSE_SHOW, true));” Generally speaking, this class is simply a container class for loaded in content.

CustomCursor.as
Loads in cursor.swf, which is the cursor asset file, with various cursor states. Only the zoom state is used in this demo. You of course can add access the other three states (finger, drag open hand, drag closed hand), if need be.

ContentEvent.as
Use for passing arguments with your custom events. In this instance it passes one parameter, an String, which represents the ID value of a target content instance. This class is used primarily for dispatching events to particular content instances. For instance, this class can be used to create a menu that shuffles and zooms content around independently of mouse Interactivity.

All classes support a method for killing listeners, each class method is fired when a REMOVED_FROM_STAGE event occurs. This of course can be changed for custom listener removal.

Updates 15 Feb, 2008: Adjusted the grid layout function and made the demo more flexible in terms of media it can load.
22 Feb, 2008: Fix for a double click tweening bug.
12 March, 2008: Better fix for double click bug! & Rounding Math Error.

Example Supports

    Mulitple Galleries or content
    Draggable content
    Click Content to scale up
    Double Click to Scale back down
    Scale back to defined point, or point before a scale up operation
    Auto or XML defined Layout
    User defined scale factor
    Custom Cursor

Example
Here is an example. http://www.noponies.com/dev/as3_pan_zoom/ (Click content to zoom, double click to scale back)

Source Files
Here are the various support files; ActionScript 3 Drag Zoom XML Loaded Content V1.5

Dependencies
Demo uses http://www.tweenlite.com for scaling, panning and zooming.

ActionScript 3 Liquid Layout Manager

Simple class that repositions objects passed to it when a stage resize event occurs.

Class is designed to simplify creating flexible or liquid layouts in Flash CS3. For a project I had I needed to create a flexible layout, so rather than creating a set of functions etc that resized the various objects I wrote this class.

It is simple and probably not as optimised as it could be, but does support the features I needed it to well.

Class positions elements using proportions of the stage, rather than specific values. I felt it was simpler to specify a value of 100 for absolute bottom or right, or 50 for middle etc.

Read Class documentation for usage directions.

Class Features

  • Ability to set a min Stage size at which point the layout manager will not reposition objects
  • Layouts are proportionally based
  • Use either clip reg point or clip natural center for positioning
  • Public method for accommodating changes in content dimensions

View Example
Here is an example; http://www.noponies.com/dev/as3_stage_manager (Resize the browser window to see it work, click pink square!)

Source Files
Here are the source files; AS3 Stage Manager Source Files, v1.2

Dependencies
Flash CS3

ActionScript 3 Sliding Images XML Gallery

This file is a ActionScript 3 demo of a sliding images gallery, as used on my work site, http://www.thereformation.co.nz.

Basically images are loaded sequentially from an XML file into a Sprite, which is dynamically masked and then tweened. The gallery has support for text descriptions (via a support class) and also creates a dynamic image number navigation system which updates itself based off how many images you happen to load in.

This is a class based file, which relies on two helper support classes. One of which simply provides an array of images from an XML file. The other, the “TextNavigation” class provides a mechanism for dispatching events to the text navigation section of the gallery. Updating its status, so that it matches the currently displayed image. There is also an optional text descriptions class which will pull in descriptions from an XML file and display these along with the images.

Gallery Features

  • Vertical or Horizontal Sliding
  • External XML Images
  • next, previous, play, pause public methods
  • Supports multiple galleries
  • Event Based Architecture
  • Dynamic tweened mask, so that it supports different image sizes
  • Either Manual or Automatic Image Progression
  • Optional Text Navigation – supports embedded fonts
  • Optional Text Comments – supports embedded fonts

Updates
July 08, 2008: A new rewrite of the class moving it to a more modular structure. I’ve decided to make this a donator file, after spending a solid day rewriting it. Download includes, source, example and documentation.
Jan, 12, 2009: API changes, new events, class now supports loading in new galleries, various bug fixes and documentation improvements. Class is now at Version 1.5

Updated 15 July, with a new method for autotweening text comments

View Example
Here is an example of the file; http://www.noponies.com/dev/as3_slideimages/

Source Files
Donator Only File

Dependencies
Files use TweenLite, available from here; http://www.tweenlite.com

ActionScript 3 XML Accordion Menu

This menu system was written as a means to display images or other content in a condensed manner.

Class based ActionScript 3 Accordion Menu, with either a rollOver/RollOff activation scheme for a onRelease activation scheme. Menu is built using a custom event dispatch scheme to keep each menu item synchronised with the changing states of the menu. The menu grabs a reference to the Stage via the ADDED_TO_STAGE event, which is uses as its base for setting up the communication between menu elements.

Menu Functionality

    Support for Images and Swfs as content.Swfs can contain their own interactivity.Either Click or MouseOver menu to activate it.XML Driven.XML can contain function calls with parameters, or URLs or nothing.Menu Highlighting is an option.Either the whole menu item, or just the menu bar can be used to trigger menu movement.Menu supports content of differing sizes. Menu will auto size the menu bar width, but is content height agnostic.Support for placement.Support for spacing between menu items and menu bar item height.Menu Bar has a test element, pulled in from the XML file.Column support. But you will have to add that change yourself.Menu uses either tweenLite or tweener for menu movement.Custom Event Dispatch class for sending events to particular menu instances. Eg, for telling one menu to slide open after all have loaded.Class has a reset method, should you need to reset the menu

If you are going to get the menu to trigger events it is generally it is better to only use the bar, so as to not interfere with your other nested actions.

Menu is a class file, which relies on be passed three values in its constructor,?Ǭ† (loader content, title text, menu action), all of which are values that are pulled in from the XML file.

Included in the download are two folders, one?Ǭ† accordianAS3_rel contains the onRelease version of the class. The other, accordianAS3_roll contains the RollOver version of the class. In each folder are each classes respective Flash CS3 document, its associated Document Class file, an XML file, an XML parsing class, the tweenLite Class and images and swfs.

Updates10th Feb, 2008: Added custom event dispatch class to both examples.

View ExamplesActionScript 3 XML Accordion Menu: On Release VersionActionScript 3 XML Accordion Menu: On RollOver Version

Source FilesHere are the source files; ActionScript 3 XML Accordion Menu V2

DependenciesClass uses the tweenLite tweening class for menu movement, highlighting etc; http://www.tweenlite.com

ActionScript 3 Print all Items on Stage

Simple class for printing all items on the stage. Along with another class for printing from a contextual menu. Something to note, is that the Flash player wont allow you to add your own “Print” menu item, it seems that is a reserved keyword. Which makes sense.

This class is probably a dirty hack.

This has only been tested when being instantiated from either a document class, maintimeline or via a custom menu class.

Basically what this does is create a temp empty sprite, loop through all instances on the stageand add them to this temp sprite, then print this temp sprite as the print job class accepts only a single sprite as an argument. (unless I’m missing something?). When the print job has been sent the objects are removed from the temp sprite and added back to the stage. The temp sprite is then deleted. There is a degree of error handling in the print functions for trapping cancelled jobs etc. No support for page sizes, or other elements of the printjob class are provided. They can be added, but this was a quick dirty hack to see if printing the stage was relatively simple.

View Example

Here is an example;?Ǭ†http://www.noponies.com/dev/printstage/?Ǭ†

Source Files

Here are the source files; ?Ǭ†Print Stage Source Files?Ǭ†?Ǭ†Archive contains .fla, document class, print class and context menu class.

« Previous PageNext Page »