background preloader

ActionScript

Facebook Twitter

ActionScript Tutorials. Tutorials. ActionScript 3 and Flash How to and Tips. Flashandmath.com Site Search In this section we provide short examples, each illustrating how to accomplish a specific task in ActionScript 3 and Flash.

ActionScript 3 and Flash How to and Tips

The collection is just starting. Check back often for new postings. Newest How-Tos and Tips Behavior of a Loaded SWF File versus Behavior of a MovieClip You load an external SWF file at runtime using Loader.load method. Manipulating Display Objects, Events, Dynamic Drawing Flash Components Utilities: Timer, Tween, etc. Loading External Assets Testing Performance Flash Authoring Environment. Tween Tricks in Flash CS3 and ActionScript 3. The ActionScript 3 Tween class can "tween" any numerical property of any object.

Tween Tricks in Flash CS3 and ActionScript 3

"Tween" means change the value of the property over a specified time interval in a specific manner with, for example, one of many available AS3 easing functions applied. Most often the property being "tweened" is the x or the y coordinate of a MovieClip, or its rotation, or its alpha property. Changes in these properties directly create motion or produce change in appearance. This is not how we use the Tween class in the example below: In the example above, we create an auxiliary object, 'paramObj' with a property, 't'.

X(t)=radius*cos(t*pi/180), y(t)=radius*sin(t*pi/180). A mathematically-inclined person will recognize right away that we are using 't' as a parameter in a parametric representation of a circle. Download tween_circle.fla Download the fla file for the applet above. The Code Below, we put our comments as comments within the code to keep the flow clear. import fl.transitions.Tween; var rad:Number=150; Learn ActionScript 3 by Following this Simple Avoider Game Tutorial — Michael James Williams. Table of contents for AS3 Avoider Game Tutorial (This tutorial is also available in Spanish, Polish, Italian, French, Turkish, and Russian.

Learn ActionScript 3 by Following this Simple Avoider Game Tutorial — Michael James Williams

I’ve also started re-writing it for HTML5.) This tutorial’s getting a little old now. It still works, but if you want a more up-to-date guide to learning Flash, I recommend reading my post How to Learn Flash and AS3 for Game Development. Introduction A lot of Flash developers find the jump from ActionScript 2 to ActionScript 3 very daunting. Frozen Haddock has been kind enough to let me rewrite his ActionScript 2 Avoiding Game Tutorial in ActionScript 3. Flash Game University. Center a movieclip on stage resize in AS3: Scriptplayground.

Learn how to center a movieclip any time the stage updates. This example will be for when the user resizes the browser window, but you can adapt the technique to any number of actions. View an of this article before you get started. If you want to skip the overall article explanation here is the . Have you ever seen a web site that is 100% Flash? This of course being a web site that the entire browser contents is in fact a Flash movie. Well in this mini article I am going to show you a very quick and simple way to create this effect Start off by creating a new movieclip instance, placing it on the stage and giving it an instance name of "mySampleMC". Once you have the movieclip on the stage you can open the Actions panel (F9 on win, ALT+F9 on mac) to begin building the script In the Flash editor you do not need to import the classes, however to use this code in an external editor or Flex you need to, so for completeness, lets do that.

AS2 → AS3: Depth Management. Download Example Files Managing depths in AS2 was pretty cumbersome and annoying.

AS2 → AS3: Depth Management

You had to use methods like getNextHighestDepth() or keeping track of depths manually to make sure everything appeared on the stage properly and didn't overwrite each other. Enter AS3 FTW! AS3 has a built in depth management system so you don't have to mess with ugly methods or keeping track of depths manually any longer. In the following example, I'm going to attach 3 boxes to the stage and on rolling over each one, it'll bring that box to the highest depth on the stage. Let's take a look at the AS2 syntax. Actionscript: As you can see when I create the box MovieClip I have to assign its depth to this.getNextHighestDepth(). Here is that same example in AS3: As you can see here, simply calling addChild() on the box we just created will automatically put it at the next highest depth available. ActionScript 3 Tip of the Day.