What is the Macromedia Flash Actionscript dot syntax and how do i use it?


posted: 07-09-05
author: PrimeVector
website: http://www.free-webmaster-resource.com
views: 9024
comments: 5
total pages: 1
jump to comments




Check This Amazing Traffic Generating Widgetsl 4 Webmasters!

What is the Macromedia Flash Actionscript dot syntax and how do i use it?

In Macromedia Flash there are multiple ways how you can setup your actionscript code. One of those ways is to place your codes onto an object like a movieClip or button etc..

An example of this could be:

Draw a square
Select it, press f8
Give it "square" as a name and make sure you export it for actionscript in the advanced options. This is really important because now actionscript needs to indentify your object to be able to do something with it. By giving it a linkage and exporting for actionscript, actionscript will know how to indentify the object and you can instruct actionscript to use it.
Then convert it into a movieClip by pressing ok. Select it again now its a movieClip and press f9 to open the code editor. Now one could attach some code like for example this:

on(press){
     trace("hello reader, this is not a good way to setup your code");
}

As you noticed this actually places code onto the object, and that is also why i personally wont ever use it. When you start making a habbit of working like this and creating objects all over your document then its just a matter of time ( and not that much) and you will start running into trouble. You will get into trouble because without a doubt you will have to debug your code after you run it, there is no hiding from that. If you place code on all kinds of objects all over your document then you will loose increddible amounts of time searching where things are going wrong and where you had placed that little piece of code that messes things up. You will stress your hands a lot more by having to click through all your clips and search through all your timelines for that evil bit of code. In other words, its a "Debugging Hell"!


The Actionscript dot-syntax to the resque

Even though other people might still swear by using the way of coding i described above, i swear by using the dot syntax. So lets take the square example again to highlight the major difference between the two.

Draw a square again
Select it, press f8
Give it "squareDotSyn" as a name and make sure you export it for actionscript in the advanced options. This is really important because now actionscript needs to indentify your object to be able to do something with it. By giving it a linkage and exporting for actionscript, actionscript will know how to indentify the object and you can instruct actionscript to use it. Then convert it into a movieClip by pressing ok.

Now here comes the difference, this time dont select the square but create a new layer and call it "code". Select the first frame of this newly created layer and press f9, the code editor pops up and you will have to input this code:

squareDotSyn.onPress = function(){
     trace("this is the way code should be setup, its way better");
}

Remember that we had setup a linkage name "square", here you saw how we instructed actionscript to use this object and attach an onPress event to it. Everytime this object is pressed the text is outputted. ( when run inside flash) Perhaps you dont see the major advantage at this point yet, but i will guarantee you that if you are starting to write more complex pieces of code, you cant thank yourself enough for having learned using the dot-syntax. Now you can address every object in your flash file from right here as long as you have setup a linkage name for each object you want to use. So perhaps we had a clip inside another clip on stage and we would want to setup some rollOver for this clip thats inside the other one. We could easilly do that by doing something like this:

myParentClip.myChildClip.onRollOver = function(){
     trace("ohyeah");
}

Now if we had used the "placing code on objects way", then we would have had to physically enter the parent clip on stage and attach codes to the child clip. If we then would want to change a bit of code, we would have to search for this code all over again in our document and change it etc... This is a huge pain in the butt. It might not seem to be big problem in a small document like this, but in a big document with loads of clips etc.. it will make a huge difference.


Conclusion

If you learn to use the dot-syntax you will develop a feeling for bigger codes and a cross over to something like using PHP wont we as big of a problem as it might be when you are used to never using the dot-syntax. Or making things like a game will be a lot more easilly accomplished by using this better way of setting up your actionscript. Eventhough the dot-syntax seems to execute a fraction slower then that placing code directly onto objects, this minor difference is neglectable if you think about the huge difference in code usability.

I hope i have convinced you of how useful it is to use the dot-syntax with this small example. If you are happy with placing codes all over the place you should do that, but personally i really feel strongly that you are hurting your self by doing that. There is however an exception for really really small Flash documents, but even then i feel you are better off using the dot-syntax. Your codes will grow to a more professional level thats a sure thing.


jump to comments


Amazing Webmaster Widgets




Comments

5 comment(s) found in 1 page  
viewing comment(s): 1 - 5

1 |

27-09-07:paul

oh wow

24-07-07:guest

what is dot in macromedia flash

26-11-06:m

mhm nice

11-04-06:dude

15-10-05:guest



- Press here to view all available smilies!



Latest News

Amazing Webmaster Tool

If you run a MySpace or teens related site with visitors interested in GLITTERS you will need this great tool: Webmaster Glitter Tool It will generate backlinks at an amazing pace!

 

Useful Click To Clipboard Script

This is a nice little copy to clipboard script. You can find it here!

 

Google Pages

Create pages on google quick and easy with Google Pages!

 

My Funny Pictures Site

Have fun on this funny pictutures site i made, i hope youll enjoy it :) PixHumor

 

IS YOUR CHILD SAFE???

With this great program you can make sure your child will be a lot safer while browsing the Internet.

 

New Site

I created a fun site for MSN Messenger Stuff called MSN Freak. You can find the site here: Free Winks @ MSN Freak

 

Useful free unlocker tool

This tool is a very useful tool that runs in the background. Whenever you try to for example copy a folder and explorer sceams at you it wont do that, the barrier is lifted and you can continue to do what you wanted too. Download it here.

 

GOOGLE worldwide: Languages and countries

Useful page showing all the Google Search Engines of all countries. Check it out here.

 

Google Trends

Google trends enables us to see where people want certain things the most. You can enter a keyword and find out where people search for that most often! Check Google Trends

 

Google PageRank Checker

I personally enjoy this Google pagerank checker a lot: Google PageRank Checker

 

New tutorials

I added a new basic Flash tutorial showing how to create a simple motion tween. You can find it here: Basic Flash Motion Tween

 

2 new Flash tutorials

I added 2 new Flash tutorials to the tutorial selection. On deals with the if else conditional statement and the other deals with setting up a bit of color with actionscript. You can checkout the tutorials here: Actionscript and colors and If Else Conditionals.

 

Oh My!

Its mad times overhere, im helping promote and have created a few sites which has taken quite some time from me. site1: http://www.flashgamefreak.com, site2 http://www.freewinks.net, site3 http://www.smilieworx.com and more are to come this and next week. This has taken its toll on my time to write tutorials. I will make up for that as soon as possible. Thanks for your understanding.

 

Basic Flash Tutorials

I added 3 new basic Flash tutorials to the tutorial list. Dealing with layers, What are functions and one about The Registration Point.

 

A bit of a delay

I have had a very crazy time around here the last month, because of this some tutorials have not been written yet. This is a list of tutorial i still need to write and you can expect them in the very near future.

 

Advertise on FWR

If you want to advertise here then please contact me here. We can make a nice deal and you can get stats on them how often you would like.

 

2 new tutorials

2 new web design related tutorials were added ... more Flash tutorials are on their way but its a bit mad around here these last days ;)

 

View All News



In Focus

Play Frogger Now!
Play frogger with 1 click download of gamevance!
Play Airstrike 1941 online for free!
Play Airstrike 1941 online for free!
Free Auto Insurance Quotes!
Saving money with InsureMyCar4Less is simple. After you fill out our quick online form, you get free auto insurance quotes from the best providers in the industry. They compete for your business, and you save money.
Play World War 2 Commando Free!
Play World War 2 Commando online for free!
Make cash with Penny Stocks!
Make cash with Penny Stocks!
Play Aztec Quest online for free!
Play Aztec Quest online for free!
Get a Free Auto Insurance Quote
Free quotes from top insurance carriers!
Do you shop at Home Depot?
Get a ton of Home Depot coupons and gift card offers! Also if your looking to improve you home this is the place to be!
Play Swat 2 Now
Play the swat 2 game and shoot those bad guys!
Play Bubble Boomers
Pop the bubbles of the like colors for this very fun and addictive game for FREE!!!
Customize your Facebook with a theme
Customize the colors and music on your facebook profile page today!
Print Coupons from Home!
Print Grocery Coupons from your house! Instant Savings!
Get free Auto Insurance Quotes!
Saving money with InsureMyCar4Less is simple. After you fill out our quick online form, you get free auto insurance quotes from the best providers in the industry. They compete for your business, and you save money.
Stop identity theft in its tracks!
Protect My ID makes it easy for you!
Save up to 70% on auto insurance!
Do you qualify for 60-70% off your auto insurance rates? Find out right now! Request quotes 24 hours a day with our secure online form. It's super fast and easy. See what your rate is absolutely free!
Play Streetfighter Now!!!
Get all the hottest new games and all the old school games in one place!
Play Pac Man right here!
Get all the hottest new games and all the old school games in one place!
Play the old school Baseball Stars
Get all the hottest new games and all the old school games in one place!
Dont get your identity stolen!
we offer multiple layers of protection and are backed by experian. Start with only $1!
Share your Opinion, win $50,000?
Share your Opinion, win $50,000? Couldn't get any easier! It's free and fun!

Cool Stuff