GFXVoid Graphic Design Forum

Remove Text Formatting
Loading...

» Online Users: 865

0 members and 865 guests
No Members online

» Site Navigation

 > FAQ

» Stats

Members: 35,443
Threads: 103,072
Posts: 826,684
Top Poster: cc.RadillacVIII (7,429)
Welcome to our newest member, Lekelindids
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2005
    Location
    Sweden
    Posts
    345

    Default

    Well now after i made a actionscript tutorial i wanted to Introduce you guys who want to learn Flash Actionscript.
    I know it's kinda strange that i did this after my Actionscript tutorial but... :unsure:

    So you want to learn Flash Actionscript 2.0?
    Then you've came to the right place!
    First things first now, Actionscript is case-sensitive, wich means if you write a capital letter you must write ecaclty as you did before(in case anyone didn't know).

    So you can't call the instance "Ball" if you write "BALL" and vice versa.
    The language is pretty easy because if you want to play the frame 5 on frame 15, then just select frame 15 and add:
    Code:
    gotoAndPlay(5);
    Easy, eh?
    Well every command isn't that simple.The Math commands is a bit more complicated, so Actionscript isn't always easy.

    The simplier command is the Movie handlers, like the gotoAndPlay() and gotoAndStop() aswell as stop() and play(), wich plays or stops the playheads.

    If you doesn't have a programmer background it can be hard sometimes, because of the way it is made.
    The If, Then,Else commands is implented to Flash Actionscript(what program language doesn't?), they are called: if ("condition") { "if the condition is true then do this" }
    else { "if the condition is false then do this instead"}.

    That was funny for a second or two. :lol:

    Operators is very good-made too.
    If something must be "Robertson" then it should look like this:
    Code:
    if (name == "Robertson") {
     * *play();
    } else {
     * *alert="Wrong name!"
    }
    So there's an example of the things we have learned, exept alert. Well those with javascript background know it's an pop-up window that says something.

    The double Equal token is for the equalty.
    The single one is for assigning variables and such.
    Guess what? There is a Triple Equalty too(kinda funny) it's the strict equalty.
    The Strict Equalty tests twoExpressions; it performs just as the equalty(==) Operator but it tests two Expressions for equalty; the result is true if both expressions, including their data types, are equal.
    Example:
    Code:
    // Assigning some strings
    s1 = new String("5");
    s2 = new String("5");
    s3 = new String("Hello");
    n = new Number(5);
    b = new Boolean(true);
    
    s1 == s2; // True
    s1 == s3; // False
    s1 == n; // True
    s1 == b; // False
    
    // so now over to the strict eqally operator!
    s1 === s2; // True
    s1 === s3; // False
    s1 === n; // False
    s1 === b; // False
    So there's how it looks.
    In the code snippet we have all the three different operators!
    The first assings the strings.
    The Second one checks for equalty.
    The Third one checks for strict equalty!

    I'll explain the whole thing.

    The s1, s2 and s3 are strings that can handle both numerals and characters.
    The "n" has the datatype number; it can only handle numerals.
    And the b is a boolean data type; that can only handle "true" or "false" assignments.

    There you have the different data types but now to the equals.

    Code:
    s1 == s2; // True
    s1 == s3; // False
    s1 == n; // True
    s1 == b; // False
    The strings "s1" and "s2" has the number 5 stored in them, so they are equal.
    "s1" and "s3" turn out false because they don't have the same values.
    "s1" and "n" turn out true because their values are equal.
    "s1" and "b" turn out false because they don't the same values.

    Getting a bit rabbly so i'll say something that has been quite popular in the shoubox: "Donuts!".
    Now it's said.

    Now to those triple equals! also known as: Strict Equalty.
    Code:
    s1 === s2; // True
    s1 === s3; // False
    s1 === n; // False
    s1 === b; // False
    This one is much simplier to explain.
    "s1" and "s2" is equal because they have the same values and data types.
    the "s1" against "s3" is false because they don't have the same values assigned to them.
    The two others turn out false because they don't have the same data types.

    Ahhh... What a wonderful feeling i have now!
    It's because now i'm gonna introduce you guys to *dramatic voice-over here*Not Equal equal to!
    I bet some of you were not ready for that! :lol:
    So let's begin with them!

    The operator not equal to is written as != .
    So here's an simple example.
    Code:
    a = "Robertson";
    b = "Fool";
    if (a != b){
     * *trace("Robertson is not a fool");
    }
    What this code snippet does is;
    The two first lines assign the two words.
    The if statement checks of "a" is not equal to "b", and then it prints it in the output window.
    An example: The game engine want "Robertson" not to be a fool and decides to run this and prints it in the output window for testing purposes.

    There is a strict inequalty too.
    The strict In equalty is written as: !== .(one exclamation mark and two equals)
    I don't need to explain that much about this one, because it's the excact opposite to the strict eqaultys!
    I'll give you an Example anyways!
    Example:
    Code:
    s1 = new String("5");
    s2 = new String("5");
    s3 = new String("Hello");
    n *= new Number(5);
    b = new Boolean(true);
    
    s1 !== s2; // false
    s1 !== s3; // true
    s1 !== n; // true
    s1 !== b; // true
    Try to think that one out for yourself!

    So you can't think that out?
    Well.. then i shall help.
    The first line is true because they have the same values and data types!
    And the rest of it is true because of they have different values and data types.

    Well the new assignment way isn't like that anymore (even though it works) it take pretty much time assigning like that.
    So i'll show the new(can you call it that?)
    Example:
    Code:
    // Assigning
    s1 = 5;
    s2 = 5;
    s3 = Hello;
    n = 5;
    b = true;
    So the inequalty is made up like this aswell as the equalties and strict equalties:
    Example:
    Code:
    // Assigning
    s1 = 5;
    s2 = 5;
    s3 = Hello;
    n = 5;
    b = true;
    
    s1 !== s2; // false
    s1 !== s3; // true
    s1 !== n; // true
    s1 !== b; // true
    There was one other inequalty operator, but it was depraced on Flash 5.
    It looked like this: <> .

    Now i&#39;m gonna introduce you to the and operator.
    Looks pretty much like a "and and": && .
    That the way it looks, pretty easy to remember&#33;
    So the usage for this is to add two expressions to one if statement.
    Example:
    Code:
    bananas = 5;
    score = 77;
    hunger = &#40;bananas &#60;= 3&#41; && &#40;score &#60;=70&#41;;
    if &#40;hunger&#41; {
     *trace&#40;&#34;You Start Getting hungry&#34;&#41;;
    } else {
     * trace&#40;&#34;You aren&#39;t hungry at this time&#34;&#41;;
    }
    The example above is maybe for a banana survival game or something.. dunno :unsure: .
    I think you know what this is for.
    Lines 1 & 2 assigns the values of bananas and score.
    line 3 handle if bananas is lower than three (the <= means lower than) and if te score is lower than 70.
    and if the hunger is true it Prints "You Start Getting Hungry" in a Authoring Enviroment
    (AT) and if it&#39;s anything else it Prints "You aren&#39;t hungry at this time".
    Pretty easy.
    This operator is called "logical AND".

    There is a bitwise AND assignment too and it looks like this: &= .
    A it&#39;s an "and, assignment" .
    It assigns the expression 1 to the expression 2.
    The following example assigns the value of exp1 to exp2.
    Example:
    Code:
    exp1 = 199;
    exp2 = 5;
    trace&#40;exp1 &= exp2&#41;;
    // it assigns the value of exp1 to exp2. So the value of exp2 is now 199.
    There is OR operators too, they are used to check if one of the two values is true or not.
    Example:
    Code:
    carX = 500;
    carY = 400;
    if &#40;carX *&#62; 500 || carY &#62; 400&#41; {
     * carX = 250;
     * carY = 200;
     * trace&#40;&#34;The car is out of bounds&#34;&#41;;
    } else {
     *trace&#40;&#34;the car is within the boundries&#34;&#41;;
    }
    That shows a simple useage of the OR operator.
    If the car is higher than X OR Y then the action is called.
    If anything else it just prints "the car is within the boundries".

    Well i&#39;m too tired to write anything more so i&#39;ll stop here for a while.. :lol:
    Noooooo! My old signature is gone! Gone forever!!!
    *sniff*
    New one!

  2. #2
    Join Date
    Mar 2005
    Location
    Insanity Sq.
    Posts
    3,811

    Default

    Pretty nice introductory tut. Nobody specifies what variables are anymore though. Now you just say

    Code:
    s1 = 5;
    s2 = five;
    s3 = blahblahblah;
    and it can tell what they all are. Much easier that way. Well good tut, though i dunno if it&#39;s an "introduction" per se, maybe just a beginners tut.
    If you want help...
    Screw you
    If you make sigs...
    Screw you

  3. #3
    Join Date
    May 2005
    Location
    Sweden
    Posts
    345

    Default

    I&#39;m gonna add more &#33;
    Did you think that was all?

    And that with the assignment, yeah that works too.
    I&#39;ll add that.
    /*----------------------------------------------
    //Update:
    //
    1. Fixed some Typos.
    //1.1.0 Added "new" type of assignment.
    //1.1.1 Added the OR and AND operators.
    //1.1.2 Corrected 3 typos.
    ----------------------------------------------*&#092;
    I&#39;ll add all the updates above&#33; ^
    Noooooo! My old signature is gone! Gone forever!!!
    *sniff*
    New one!

  4. #4
    Join Date
    Dec 2004
    Location
    hehehe
    Posts
    855

    Default

    a very good tut. quite informative.

    one question though, could you by any chance write a tut dealing with the &#39;show&#39; and &#39;hide&#39; of a MC? and turning them on and off within the same frame.

  5. #5
    Join Date
    May 2005
    Location
    Sweden
    Posts
    345

    Default

    Hmm, not sure if you need one anymore, but I could do one.
    Noooooo! My old signature is gone! Gone forever!!!
    *sniff*
    New one!

  6. #6
    Join Date
    Sep 2005
    Location
    The Netherlands
    Posts
    553

    Default

    Yeah maso, I need that too...&#33;

    Elite it&#39;s very good, and you have helped me out a lot with some basic problems :wacko:


    Thanks&#33; :lol:

Similar Threads

  1. .introduction
    By .burgy in forum Introductions
    Replies: 6
    Last Post: 08-03-2005, 11:57 AM
  2. Re-Introduction.
    By Maverick in forum Introductions
    Replies: 7
    Last Post: 06-25-2005, 01:18 AM
  3. Re-Introduction
    By Jakska in forum Introductions
    Replies: 4
    Last Post: 03-13-2005, 08:48 PM
  4. Introduction
    By sKiTTle in forum Introductions
    Replies: 4
    Last Post: 01-25-2005, 08:03 PM
  5. Another Introduction
    By Kimberly in forum Introductions
    Replies: 7
    Last Post: 01-07-2005, 12:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBadvanced CMPS v4.1.1