ActionScript 2.0 Best Practices

Actionscript is a very powerful language made by macromedia. Learning actionscript can be tricky until you get your mind thinking the same way actionscript does. Actionscript is evolving at a very fast rate into a top programming language. With the release of ActionScript 3.0 excepted in the next few months it's important to get use to good 2.0 practices.

So what are correct 2.0 practices?

Correct 2.0 practices would include strict data typing all variables, function return values and values excepted. Strict data typing can also be used in classes which is another great 2.0 practice. OOP is Object Orientated Programming; OOP is like an advanced external function. Languages such as Java are purely OOP all programming done is Java uses classes. The advantages to classes are they can be re-used time and time again. They can be extended with additional classes, They can be shared and there great for organization. Once you start programming things over 1000 lines of code things can get very complicated and some times impossible because you simply don't know what goes next. This is where classes come in classes with organize your entire site into manageable sections. An example of using classes would be a members system. You could create a members class in that class could contain a signup function that registers the users checked for blank values and further validation. You could then have a login function which checked the users name and password against the database and returned a value of true if the username and password supplied match that of the database. OOP really is the future of programming without OOP you will struggle with medium to large sized projects. Another huge advantage to OOP is when working in a team you can simple work on a class each and modify or extend another persons class. Where as without OOP would have to look through maybe 10,000 lines of code to find 5 lines of code that needed modifying. Good 2.0 practices would also be using movieclips instead of buttons. Movieclips have far more functionality than buttons ever could actionscript 2.0 can do just about anything to movieclips change the coulor, size, shape, movement, the list goes on and on. Buttons really are the past the future is movieclips.

How to define strict datatypeing

for example to define a variable as a number we would use

var - to signal what we are defining is a variable.

thename - anything you like to idefntie the specific variable.

:number - the datatype this could be a number, boolean or string.

= - to define what will be inside the variable.

4 - the value that sites inside the variable.

; - just to end the line of code

So in full

var thename:Number = 4;

String and boolean would look as follows.

var thestring:String = hello;

var theboolean:Boolean = true;

If you wanted to make something happen when a user clicked a movie clip the correct 2.0 code to use would be:

nameofthemovieclip.onPress = function ():Void {

//what you would like to happen in here.

}

We define the function as void so that actionscript does not except a retuned value.

If we were to put expected values inside the function we would use:

myfunc = function (mynumber:Number):Void{

//code goes here

}

So remember to always use correct 2.0 practices and your code will shine.

Ashley Peach - Owns Dog toys, Dog books and Dog coats.
Article Source: The FREE Article Distribution Center

Hot Topics In Education

    Home Schooling Advantages vs. Disadvantages

    Home schooling is an option that is becoming more attractive to parents as time goes on. Schools have become increasingly unstable over the past couple of decades. Children roam the hallways unchecked...

    Homeschooling With a Packaged Curriculum

    Once the decision is made to homeschool, the next major issue is which curriculum or methodology to use. While there are pros and cons for every option, this article will focus on homeschooling with a...

    Teen Books About Learning Disabilities

    Learning disabled children aren't the only ones with books targeted toward them. A growing number of resources for teens have been made available in recent years as well. The teenage years are often t...

    What Every Parent Needs To Know About Teaching Kids Math

    So you want to help your kids with their math homework? Or try to get them a little bit more interested in this important subject?

    Excellent. Just make sure you don't inadvertently make things worse...

    How To Avoid The Most Common College Scholarship Mistakes

    Every semester college students all across the country are pursuing scholarship money to help pay for their college education. Some are very successful in getting scholarships, and others aren't. So h...

    How Much Does Homeschooling Cost?

    You'll definitely find that homeschooling entails more expense than conventional public schooling, but also that it will cost considerably less than the annual $2,000 to $10,000 per child that private...

    Distance Learning Schools

    If you are seeking a way to improve your financial outlook through higher education, but can't conform to a traditional college class schedule, Distance Learning Schools may be just the ticket you nee...

    Making a Career of Your Love for Children - Foster Care Distance Learning Program

    A foster care distance learning program opens up exciting careers in childcare and foster parenting. If you love children and would like to spend your time with them, your love can become an exciting ...

    Encouraging Your Loved One To Finish Their High School Education

    Regardless of the situation, it is hard to watch a loved one throw their future away.

    When you see a loved one end their high school education, it is a difficult thing to watch. Especially when it i...

    History of Distance Learning

    The history of distance learning can be traced back to the 1890's. Distance education was then known as correspondence course. The University of Wisconsin was the pioneer in this venture supported by ...

    The Changing World Of Online Education

    The way we learn is changing faster than ever before. With the Internet, digital libraries and online encyclopedias it seems as if all the world's information is at our finger tips. This makes learnin...

    Online Master's Degree

    Online masters?degree program courses are available for those students who need the flexibility of a web environment in order to balance family, work and educational responsibilities simultaneously. O...

Most Recent Education Supplements

Interesting Today:

Most Recent Education Blogs:

Releated to Education:

Education Links:

Education Education Rss feeds.