Website Designers and Webmasters

Dedicated to all the tasks Webmasters, Website Developers and Website Designers find themselves facing.

By: Ashton Sanders

Flash Random Scene ActionScript

Mar 9 19:35

Filed under: Flash ActionScript

I recently created a Flash Animation that would randomly play one of three different Flash scenes. Then after each scene, it would go back to the beginning and randomly choose another scene to play. This was all programmed in ActionScript in Flash.

I have a feeling that even though this code is very simple, it will save a little bit of time if I have it stored here for the future.

// First Choose a random number
//from 0 to the number of scenes
num = random(3);

//Depending on which random number
//was chosen, go to a flash scene
switch (num)
{
case 0:
gotoAndPlay(”scenename”, 1);
break;
case 1:
gotoAndPlay(”scenename1″, 1);
break;
case 2:
gotoAndPlay(”scenename2″, 1);
break;
default:
trace ( ” no case tested true ” )
}

That’s it!
-Ashton Sanders

(P.S. If this was useful for you, please leave a comment! ;) )

By: Ashton Sanders

ActionScript Basics – Structure

Apr 13 20:09

Filed under: Flash ActionScript

My Last Post discussed ActionScript Variables. Now I’m going to do a quick run down about ActionScript Structure.

You will notice that many different programming languages have a similar format. PHP and ActionScript, for example, have a very similar syntax. A lot of functions are written exactly the same for both of them. There is one very unique thing about ActionScript: Symbols can be inside Symbols inside Symbols inside Symbols. (A symbol is either a Graphic, Movie Clip or Button. F8 will turn the selected items into a symbol of your choice.)

This structure is very useful for animating in Flash (and a lot more). You can also store variables within movie clips. Lets say you had a movie clip called “ball”.

//This is programmed onto the first frame of your movie.

x = 3;
ball.x = 4;

That code will store two different variables. Even though the variables have the same name, they are located in different places, so the second variable wouldn’t overwrite the first one.

-Yes, this is very basic.
-Ashton Sanders

By: Ashton Sanders

ActionScript Basics – Variables

Apr 13 10:40

Filed under: Flash ActionScript

This post is about variables in AcrionScript (the programming language for Macromedia/Adobe Flash).

ActionScript Basics

Some very quick basics

// <- These two slashes are a comment.
// Everything after a comment on that line
// will not be processed by Flash

every.statement.ends.with.a.semicolon;

Varbiable Basics

What is a variable? A variable is group of numbers and letters or one letter that will store an amount, a string or a true/false statement. A variable cannot start with a number.

// This Creates the variable “x” and
// gives it the numeric value of 4
x = 4;

// trace() will display whatever you put
// between the “(” and “)”.
trace(x);

// That will display: 4

In this example, the numeric value of “4″ was stored in the variable “x”. Here is another example:

number = “4″;

trace(number);
// 4

These last two examples were very similar, but notice that the variable (number) was given the value of “4″ (with quotes around it). The quotes changed the value of the variable from a numeric value to a string. A string is just a group of number, letters, symbols, etc. defined with quotes.

statement = “Here’s a statement for you”;

trace(statement);
// Here’s a statement for you

As I mentioned above, you can give a variable a numeric, string or true/false value. This third value type is called a Boolean value. A boolean value is either yes/no, true/false, 1/0, on/off, etc. In Action Script, you can assign them with either true/false or 1/0.

go = true;

trace(go);
// true

That is a quick summary of how to declare variables the shorthand way in ActionScript. My next posts will be along these same lines, so if you are hungry for more, check out my other ActionScript Posts them out.

If you have any questions, or if I was unclear at any part, feel free to leave a comment, and I’ll get it fixed up for you.

-Until Then,
-Ashton Sanders

By: Ashton Sanders

Tutorial – Flash ActionScript – Path

Mar 17 14:14

Filed under: Flash ActionScript

Animating with Flash is great! It’s the most fun you can have while making a website. But a flash animation doesn’t become interactive without ActionScript.

ActionScript Allows you to send orders to many different sections of your flash animation. Any Flash Animation can have hundreds of different movie clips graphics and buttons. A Flash Movie Clip, Flash graphic or Flash button can be within other Flash Movie Clips or graphics. This Can create a very complicated system of Flash Graphics, Movie Clips and Buttons.

If you look at it like a folder system, it becomes easier to understand. Lets Say movieClipA and movieClipB are inside movieClipC (And those are their names respectively.) This is what the hierarchy would look like:

  • movieClipC
    • movieClipA
    • movieClipB

To send an order to movieClipB (like to stop) this would be your command:

_root.movieClipC.movieClipB.stop();

What is this “_root.” thing?
This first section is where you are starting the command at. “_root.” tells the command to go to the very first level of your flash movie. To compare this to a Windows machine, this is like telling your computer to go all the way back to “C:\”. Then we have the name of the first movie (movieClipC), and then the name of the second movie (movieClipB). Then Finally we have the command to stop (stop();).

More to come soon,
-Ashton Sanders

RSS

Where Am I?

You have found the semi-coherent ramblings of Ashton Sanders: a website designer, developer and webmaster. This is primarily Ashton's place to save notes about techniques and things that he learns in his never-ending conquest of the internet. Hopefully it's coherent enough to be useful to you too.

Subscribe:

Enter your email to get automatic emails whenever Ashton posts on the blog.

Email:

Advertisers:

Email Marketing $19/Month! OIOpublisher Learn how to make Money from Blogging Hillarious, High-Quality Shirts for $6/each Great Book Keeping and Invoicing Software Advertiser Here

Tags and Categories

Links

Blog Roll