Sample Project with Gallery

Here is a sample project that makes use of the Load_Content, Button_Group and ImageLoader classes.

sample_project_with_gallery

I posted some videos describing the process here:http://vimeo.com/user312541/videos

I’m looking for a better service. One that doesn’t resize the images. I would like to keep them at 800×600. If anyone has any suggestions please post a commont.

SimpleScrollText

Here’s a class that creates a Scrollbar and TextField, that requires no AS at all. The example inlcudes all of the Classes in a package. The classes include, SimpleScrollBar, SimpleScrollText and ScrollBarEvent.

These classes look for MovieClips with the names up_mc, down_mc, drag_mc, track_mc and scroll_txt. You can leave up_mc and down_mc if you do not want these buttons. Or use only the buttons and leave out drag_mc and track_mc.

Assign the SimpleScrollText or SimpleScrollBar class to the Base Class of the MovieClip that contains the Scrollbar elements.

simplescrolltext

Printing an SWF

A question about Joshua Davis and his techniques came up in my online Class. I thought I post to the answer here as others might be interested in how to print the stage in an SWF.

Joshua Davis is pretty inspiring. I like the idea of creating art with Flash via an automated system. He uses a script that creates art automatically by crating movieclips on the stage dynamically. THen he prints these our.

This is not so hard to and doesn’t require any special software other than flash. You can also import the work into Illustrator and work with it there.

Note that randomly generated art may or may not be art. The color choices and other elements may need to be adjusted and added or removed to make a really artful design. That said the process can add interesting elements to your work.

Try it for yourself. Follow these steps.

1) create a Flash movie with some art on the stage. You could just place elements on the stage for now. As you learn AS you can write a script that generates things on the stage.

2) Launch the SWF.

3) Right Click the stage and choose Print…
In the print dialog box print to PDF. This option may show up in different places on different systems.

But the secret is that the PDF can be imported into Illustrated. Printing to the PDF format creates a record of the current content on the stage as vectors in the PDF document.

Note that Illustrator will change a few things or not interpret them correctly. Stroke weight for example, is scaled in Flash but not scaled in Illustrator.

Testing navigateToURL locally

I noticed that navigateToURL (this replaces getURL in AS2) doesn’t seem to work locally, if you want to open a link in the same window (_self). I found this note on the Adobe site. It seems that you need to set “allowScriptAccess” to “always” in the HTML parameters. This needs to be set in both the param tags as below: <param name=”allowScriptAccess” value=”always” /> and in the embed tag: <embed allowScriptAccess=”always” />

SimpleScrollBar class AS3

Here’s an AS3 class that creates a simple scroll bar. Set this as the Base Class for any movie clip. The container clip must have two movie clips named drag_mc and track_mc. These clips act as the dragger and track for the scroll bar

Add an event listener to call a handler when the scroll bar is dragged. SimpleScrollBar dispatches the ScrollBarEvent.UPDATE which includes the property scroll_value. This property holds a value from 0 to 1 representing the position of the dragger.

Here’s some example code. Assume that scroll_mc is a movie clip that contains two clips drag_mc and track_mc. This clip has SimpleScrollBar set as it’s base class.

scroll_mc.addEventListener( ScrollBarEvent.UPDATE, on_update );
function on_update( e:ScrollBarEvent ):void {
	var n:Number = e.scroll_value; // Get the value of scroll bar
	scroll_txt.scrollV = Math.round( ( scroll_txt.maxScrollV - 1 ) * n ) + 1;
}

Download the sample: simplescrollbar-class

XMLLoader

Here’s a simple class that wraps the URLLoader. I called this XMLLoader but it will load any text. The class itself illustrates the basic code required to load a text file. The class can be used to simplify the process in any project.

Save the following as XMLLoader.as

package {
	import flash.events.*;
	import flash.net.*;

	public class XMLLoader extends EventDispatcher {
		public var data;

		public function XMLLoader() {

		}

		public function load( _xml_url:String ):void {
			var loader = new URLLoader();
			loader.addEventListener( Event.COMPLETE, on_complete );
			loader.load( new URLRequest( _xml_url ) );
		}

		private function on_complete( e:Event ):void {
			data = e.target.data;
			dispatchEvent( new Event( Event.COMPLETE ) );
		}
	}
}

Use the class like this. Add the following code to any project:

my_xml = new XMLLoader();
my_xml.addEventListener( Event.COMPLETE, xml_loaded );
my_xml.load( "file.xml" );

Content Manager Class

These are some ideas that I have been working on. The goal was to make a simple system to display images or movie clip symbols on the stage. These use Tween for animation duties so be sure to include the Tweener class in the folder with any project that might use the Content_Manger class.

The basic idea is to animate any currently displayed clip off the stage and remove it from the display list. Then add a new clip to the display list and moveĀ  this clip in to view.

The first version, Content_Manager, extends the MovieClip class and so itself must be added to the display list. Content_Manager_1 example files: Content_Manager

The second version, Content_Manager2 takes three parameters when it is instantiated, these are:

  1. open_tween:Object
  2. close_tween:Object
  3. start_values:Object

These parameters determine the animation object that will be passed to Tweener for clips that are added to a page, open_tween. The animation object passed to Tweener for clips that are removed, close_tween. And an object containing the starting properties for clips that have been added to the stage, start_values.

Start_values set the intial starting properties for a clip, open_tween sets the animation applied to a clip as it moves on to the stage. Close_Tween sets the animation that moves a clip off the stage. Content_Manager_2 Example files: Content_Manager2

This last version of the content manger, Content_Manager3, adds a new parameter for the host clip. THe host clip is when an instance of Content_Manager3 is created. The host clip determines the MovieClip that Content_Manager3 will be adding, removing and animating clips within. Otherwise it is the same as Content_Manager2.

The example files show several ways in which this class can be used.

Add_Page3.fla, shows serveral different ways that clips can be animated by passing different objects to the Content_Manager3.

Add_Page4, shows how the content manager can be nested. Here the main movie uses content manager to add clips that also contain other instances of the Content_Manager3. Here are the Content_Manager3 example files: Content_Manager3