Welcome to WebProNews Breaking eBusiness and Search News
Advertise | Newsletter | Sitemap | News Feeds News Feed 
 WebProNews Search Part of the iEntry network iEntry inc. 

ActionScript 2.0 Best Practices

Ashley Peach
Expert Author
Published: 2006-06-23

WebProNews RSS Feed


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 expected 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 they're great for organization.

Once you start programming things over 1000 lines of code, things can get very complicated and sometimes impossible because you simply don't know what goes next. This is where classes come in. Classes will organize your entire site into manageable sections.

An example of using classes would be a members system. You could create a members class, and 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 user's 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 simply work on a class each and modify or extend another persons class. Where as without OOP you 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, and 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 identify 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 sits 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.

Tags:

Add to Del.icio.us | DiggThis | Yahoo! My Web | Furl

Receive Our Daily Email of Breaking eBusiness News


About the Author:
Ashley Peach - Owns Dog toys, Dog books and Dog coats.

View their website at: http://www.dog-toy.co.uk/

WebProNews RSS Feed

More Expert Articles Articles

Contact WebProNews
Advertisement



TOP NEWS

Targeted Information for Business
WebProNews is part of the iEntry network

Internet Business: Marketing: Small Business:
WebProNews MarketingNewz SmallBusinessNewz
WebProWorld AdvertisingDay PromoteNews
EcommNewz SalesNewz EntrepreneurNewz

Software: Search Engines: Web Design:
WebMasterFree Jayde B2B DesignNewz
NetworkingFiles SearchZA FlashNewz
SecurityConfig SearchNewz WebSiteNotes

Developer: IT Management: Security:
DevWebPro ITManagement SecurityProNews
DevNewz SysAdminNews SecurityConfig
TheDevWeb NetworkingFiles NetworkNewz

The iEntry Network consists of over 100 web publications reaching millions of Internet Professionals. Contact us to advertise.
eBUSINESS RESOURCES
 Advertise | Contact Us | Corporate | Newsletter | Sitemap | Submit an Article | News Feeds
 WebProNews is an iEntry, Inc. ® publication - $line) { echo $line ; } ?> All Rights Reserved
About WebProNews
WebProNews is the number one source for eBusiness News. Over 5 million eBusiness professionals read WebProNews and other iEntry business and tech publications.

WebProNews provides real-time coverage of internet business.

Free Email Newsletters:
WebProNews SearchNewz
WebProWorld DevWebPro
Marketing SecurityNews
Plus over 100 other newsletters!

Send me relevant info on products and services.


WebProWorld
Ten most recent posts.

NetworkingFiles
Featured Software

WebProNews in the News
View all recent mentions of WebProNews from around the world!

Recent Articles On ...
Google eBusiness
Yahoo Ask Jeeves
MSN Blogs
Search Engines Blogging
Affiliate Programs Marketing
eCommerce Advertising
eBay Sun Microsystems
AOL Adsense
Microsoft Adwords
Oracle IBM
Amazon Apple
SEM Mac
SEO iPod
Adsense XBox
PR Adobe



iEntry.com WebProWorld RSS Feed WebProWorld Contact WebProNews Print Version Email a friend Bookmark us