AS3-101: Intro to Functions Part 2 and Class Overview

– taterboy | September 26th, 2009

Filed under: ActionScript 101, ActionScript 3, Flash, Flex, Tutorials

The Class:
Classes are a collection of variables and/or functions that provide unique functionality. Within a class, functions and variables define the functionality and how that functionality can be expanded or used by other classes or components. In AS3 a class is wrapped inside a package, a class must be public and have a public constructor(function) by the same name.

?View Code ACTIONSCRIPT
package{
	public class FunctionTester{
		public function FunctionTester(){
			//constructor, runs after class is loaded, but before visual elements are loaded.
			//classes and their constructors must be public
			trace("load");
		}
	}
}

Inside the package brackets is where the class is declared and all other classes are imported, also meta information can be placed at this level. Everything else is part of the class and must be contained within the class brackets.
Read All About It »

Technorati Tags: , , , , , , , , , ,

| 3 Comments » | facebook:

AS3-101: Intro to Functions Part 1

– taterboy | September 13th, 2009

Filed under: ActionScript 101, ActionScript 3, Flash, Flex, Tutorials

For Flash Developers:
(If you are looking for Flex related stuff, without a timeline, skip down to “The Foundation”.)
Functions really are the building blocks of programming. They take your code off the timeline and open doors to more complex applications. For instance, place the following code on the timeline of a new Flash file (AS3), publish a preview and see what happens.

?View Code ACTIONSCRIPT
function tester():void{
 trace("something");
}

Notice that nothing happened, meaning the word “somthing” or anything else did not trace out in the console palette. This is because the function was recorded in the Flash Players memory, but not executed. Now add a few frames, say five or more, and add this line on the last frame.

?View Code ACTIONSCRIPT
tester();

Something happens now, the word “something” appears in the console window every time the playhead reaches the last frame. Flash Player will keep looping until it gets a stop() method call. So let’s do that now. Update the function tester with the stop command.

?View Code ACTIONSCRIPT
function tester():void{
	trace("something");
	stop();
}

Now notice the the play head starts on frame 1, loads the function into memory, then progresses on to frame, 2,3,4 until the last frame. Once on the last frame, the function tester from the first frame is executed from the last frame, which also tells the Flash player to stop. We can verify that the Flash Player is indeed on the last frame when tester is called by getting a trace of the current frame. I am sure you will just trust me so we can move on, but just incase you don’t, see below.

?View Code ACTIONSCRIPT
function tester():void{
	trace(currentFrame);
	stop();
}

The Foundation:
(Welcome Flex people)
Like I mentioned earlier, functions are the building blocks to applications, and like blocks different types of functions have different results. First we are going to learn about the most common function and some scenarios for it’s usage.
Read All About It »

Technorati Tags: , , , , , , , , ,

| No Comments » | facebook:

Flash/Flex Tips and Free Book Drawing – Using Test Projects

– taterboy | September 10th, 2009

Filed under: Flash, Flex, Tips

We will give away 1 free copy of Foundation ActionScript 3.0 Animation, Making Things Move and Foundation Flash, Cartoon Animation. Details below.

UPDATE

The drawing has been canceled because of lack of interest. I still have the books and will think of another way to distribute them.

< ?php
require_once('includes/amazonStore.php');
echo '
‘;
echo getItem(’1590597915′,’dazzledish-20′);
echo ‘
‘;
echo getItem(’1590599128′,’dazzledish-20′);
echo ‘

‘;
?>

Because Revisions Suck:
Revisions are so common in our business, you can never take them personally. It is even harder when you feel the project you are working on is finished and the client is asking for a whole new feature. This is normally a good time to go to lunch or take a break. It happens, if they are a good client or you are lucky enough to get a change order out of it, it is difficult to say no. Once over the initial frustration and you are able to think clearly, the seemingly impossible chore becomes less impossible. Ideas begin to flow and your mind fills with thoughts like, “Maybe this will not be so bad” or “It should only take an hour or two”; instead of “It would have been nice to know about this sooner” and other things I dare not publish on this blog.
Read All About It »

Technorati Tags: , , , , , , , ,

| 4 Comments » | facebook: