Here are a few examples that illustrate using Tweener with AS3. Tweener is an animation Class that makes it easy to get things moving in Flash. The Tweener class files are included with these examples in the cuarina folder. You can download the latest version and read more about Tweener here.
These examples show some simple animation ideas using Tweener. Each movie is built using the Document Class. The FLA file contains a movie clip that is animated. In the First movie these clips are on the stage. In the second and third examples these clips are in the library and attached to the stage. For this to work the Linkage option must be set to Export For Actionscript.
Here are a few examples that use the Loader class to load other SWFs into a main SWF. Here I planned each of the loaded SWFs around it’s own Document class. So, the Actionscript that runs each movie is contained in a document class for that SWF. This method seemed to work pretty well. The loaded movies in this don’t really do anything. But, they each contain something happening going on with Actionscript, which is stored in the Document Class for each SWF.
The FuseKit is really good, but it hasn’t been updated for AS3 yet. If you are working on AS3 projects you can use Tweener as a replacement. Tweener doesn’t have as many options but it will cover most of your animation needs and it’s just as easy to use. It’s much easier than to use than the flash Tween class.
Here’s an AS3 version of the ScrollBar Class. This uses the same methods and properties as the AS2 version of this class.
Make a newinstance of ScrollBar with:
new ScrollBar( target_mc, callBack )
The target_mc must have two clips inside named drag_mc and track_mc. The first is the dragger and the second sets the limits for the dragger. You can design these in any way you like as long as they use the instance names
drag_mc
track_mc
For best results place the registration points of both clips in the upper left corner and align both clips within their parent.
The callback can be any function name that you have defined. The ScrollBar class will send a value from 0 to 1 to the callback function. Think of this as the percentage position of drag_mc from the top of track_mc.
For example if you made a clip with both drag_mc and track_mc you might give that clip the instance name of scroll_mc. To make a new instance of ScrollBar you could use the following:
var a_scrollbar:Scrollbar = new Scrollbar( scroll_mc, test );
When the scrollbar is dragged the function test would be called and passed a value between 0 and 1 representing the position of the dragger. You could use this to scroll some text in a dynamic text field or set the volume of a sound object.
Here is a sample function that would scroll a dynamic text field named scroll_txt:
function test( n ) {
scroll_txt.scroll = Math.round( ( scroll_txt.maxscroll - 1 ) * n ) + 1;
}
Scrollbar( host_mc:MovieClip, call_back_func:Function )Creates a new Instance of Scrollbar. The host_mc clip must contain two clips named drag_mc and track_mc. These clips act as the scrollbar. track_mc sets the limits while drag_mc is the interactive clip.The call back function can be the name of any function you define. It will receive one parameter, a value representing how far the scrollbar is scrolled. The range of the returned value will be from 0.0 to 1.0. With 0.0 being the value returned when the scrollbar is at the top (or left when scrolling horizontally) and 1.0 when the scrollbar is at the bottom (or right). You can use this value to control elements in your movie.
host_mc: a movie clip containing the drag_mc and track_mc.
call_back: the name of a function that will be called when the scrollbar is scrolled.
scroll_horizontal( horizontal_scroll:Boolean )
This method determines whether the scrollbar scrolls vertical or horizontal. By default the scrollbar scrolls vertically. Calling scroll_horizontal() and passing true makes the scrollbar scroll horizontally.
getValue():Number
The method returns the current value of the scrollbar.
setValue( n:Number )
The method sets the current position of the scrollbar. Pass a value of 0 to 100.
This is a great tool for embedding swf’s into your HTML pages. This is an alternative to the markup provided by Adobe via Flash or Dreamweaver. It also circumvents the need to “Activate Flash” on Windows.
I prefer this over the default scripts which often cause problems with the HTML code on the page.
It provides a few extra features also. Like ability to get variables from the URL string for the current page. It can also check the Flash version and provide a link to get the current version of Flash.