Flash using ActionScript libraries tutorial: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
Line 34: Line 34:
== Snowflakes ==
== Snowflakes ==


You might want snowflakes. Creating a nice snowing animation with drawings is almost impossible and programming them yourself is really difficult (unless you
You might want snowflakes. Creating a nice snowing animation with '''lots''' of snowflakes by drawings would be very tedious and programming them yourself is a bit difficult (unless you
are a "real" programmer). You now have two options:
are a "real" programmer). You now have two options:
* Finding some special purpose snowflakes code on the web (there is, e.g. [http://www.oman3d.com/tutorials/flash/video/snowflakes.php Creating Falling Snowflakes in Flash Using ActionScript ]).
* Finding some special purpose snowflakes code on the web
* Using a more general purpose library, something we will do here.
** There is e.g. the [http://www.oman3d.com/tutorials/flash/video/snowflakes.php Creating Falling Snowflakes in Flash Using ActionScript 2 ]). We also have a flying kites example in the [[Flash embedded movie clip tutorial]] that you could repurpose.
* Using a more general purpose library that will create the whole animation (including the snowflakes), something we will do here.


Step 1 - download the FLINT particle system
{{quotation|Flint is an open-source project to create a versatile particle system in Actionscript 3. The aim is to create a system that handles the common functionality for all particle systems, has methods for common particle behaviour, and lets developers extend it easily with their own custom behaviours without needing to touch the core code. ([http://flintparticles.org/about])}}. That may sound very technical and it actually is. Such libraries are meant primarily for "real" ActionScript programmers. However, Flash designers with a little bit of ActionScript programming know-how can also use such code, in particular simply repurpose examples found in the documentation.
* Firstly have a [http://flintparticles.org/examples look] at what this particle system can do. Cool isn't it ?
* So, get FLINT from http://flintparticles.org/. I took:
** [http://flint-particle-system.googlecode.com/files/Flint_2_0_0_b.zip Flint_2_0_0_b.zip]
... At the present time, there may be a more recent version. E.g. a 2.0 final.
You also may download extra stuff, e.g.
* [http://flint-particle-system.googlecode.com/files/Flint_2_0_0_b_examples.zip Flint_2_0_0_b_examples.zip]
* [http://flint-particle-system.googlecode.com/files/Flint_2_0_0_b_docs.zip Flint_2_0_0_b_docs.zip]
Dezip these three archives in a new directory.
Now since we are interested in snowflakes were are actually really lucky. There is both example code (in the example zip file) and a nice [http://flintparticles.org/tutorials/snowfall Introducing Flint with a snow effect] tutorial made by the author.
Step 2 - create a new Flash (ActionScript 3.0) file
* Create a new directory for this project
* Make sure that you really use ActionScript 3.0, else change that in the ''File->PublishSettings - Flash tab'' too.
* Copy the "src" sub-directory of the Flint system to the root of this new directory and rename it something like "flint"
Step 3 - Fix the classpath
* Open the ''File->Publish Settings - Flash tab''
* Then click on the ''Settings ...'' button next to the ActionScript version. You should see something like this now:
* Add the name of the subdirectory where the flint system sits. Click on the "+" sign and e.g. type "flint".
Basically, what you have to understand at this point is that your application has to know in which directory to look for the FLINT code. If you want to understand about packages and classes you'll have to dig fairly deeply into programming.
== A note one classes and packages ==
All ActionScript code that you will import is defined with classes (see the [[ActionScript 3]] tutorials if you really want to learn how programming works.). Theses classes can then be bundled together in so-called packages which allows to organize code into discrete groups that can be imported by other scripts. E.g.
package packageName {
    class someClassName {
    }
}
More information about setting the Class path can be found at Adobe, i.e. [http://livedocs.adobe.com/flash/9.0/UsingFlash/help.html?content=WS3e7c64e37a1d85e1e229110db38dec34-7fa2.html here] and [http://livedocs.adobe.com/flash/9.0/UsingFlash/help.html?content=WS3e7c64e37a1d85e1e229110db38dec34-7fa2.html here] in the "Using Flash documentation".
More information about packages can be found in Adobe's [http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000040.html Packages and namespaces] chapter in the [http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part1_Programming_AS3_1.html Programming ActionScript 3.0] tutorial which is very technical.





Revision as of 16:41, 23 October 2008

<pageby nominor="false" comments="false"/>

This article or section is currently under construction

In principle, someone is working on it and there should be a better version in a not so distant future.
If you want to modify this page, please discuss it with the person working on it (see the "history")

Draft

This entry is part of the Flash tutorials.

Introduction

Learning goals
  • Learn how to use ActionScript libraries
Prerequisites
Environment
  • Flash CS3
Moving on
Level and target population
  • Beginners (but see the prerequisites)
Quality
  • ...
To Do
  • Everything

There exist several free high quality ActionScript libraries available and that can be used by Flash designers that only possess very little programming skills.

Typical examples of such libraries are:

  • Flash 3D libaraires that allow a CS3 developer to create animated and interactive 3D scenes.
  • Special purpose animation libraries like the FLiNT particle system that allows you to create stuff like fireworks and snowflakes.
  • Tweening libraries like TweenLite that allow you to define sophisticated animations with a few method calls (instead of spending hours of drawing).

Snowflakes

You might want snowflakes. Creating a nice snowing animation with lots of snowflakes by drawings would be very tedious and programming them yourself is a bit difficult (unless you are a "real" programmer). You now have two options:

Step 1 - download the FLINT particle system

“Flint is an open-source project to create a versatile particle system in Actionscript 3. The aim is to create a system that handles the common functionality for all particle systems, has methods for common particle behaviour, and lets developers extend it easily with their own custom behaviours without needing to touch the core code. ([1])”. That may sound very technical and it actually is. Such libraries are meant primarily for "real" ActionScript programmers. However, Flash designers with a little bit of ActionScript programming know-how can also use such code, in particular simply repurpose examples found in the documentation.

... At the present time, there may be a more recent version. E.g. a 2.0 final.

You also may download extra stuff, e.g.

Dezip these three archives in a new directory.

Now since we are interested in snowflakes were are actually really lucky. There is both example code (in the example zip file) and a nice Introducing Flint with a snow effect tutorial made by the author.

Step 2 - create a new Flash (ActionScript 3.0) file

  • Create a new directory for this project
  • Make sure that you really use ActionScript 3.0, else change that in the File->PublishSettings - Flash tab too.
  • Copy the "src" sub-directory of the Flint system to the root of this new directory and rename it something like "flint"

Step 3 - Fix the classpath

  • Open the File->Publish Settings - Flash tab
  • Then click on the Settings ... button next to the ActionScript version. You should see something like this now:
  • Add the name of the subdirectory where the flint system sits. Click on the "+" sign and e.g. type "flint".

Basically, what you have to understand at this point is that your application has to know in which directory to look for the FLINT code. If you want to understand about packages and classes you'll have to dig fairly deeply into programming.

A note one classes and packages

All ActionScript code that you will import is defined with classes (see the ActionScript 3 tutorials if you really want to learn how programming works.). Theses classes can then be bundled together in so-called packages which allows to organize code into discrete groups that can be imported by other scripts. E.g.

package packageName {
   class someClassName { 
   } 
}

More information about setting the Class path can be found at Adobe, i.e. here and here in the "Using Flash documentation".

More information about packages can be found in Adobe's Packages and namespaces chapter in the Programming ActionScript 3.0 tutorial which is very technical.