How to use the Macromedia Flash Actionscript local connection object


posted: 06-09-05
author: PrimeVector
website: http://www.free-webmaster-resource.com
views: 12837
comments: 9
total pages: 4
current page: 1
page jump: 1 | 2 | 3 | 4

view live example
jump to comments
download source files


advice

Readers that dont have Flash MX2004+ installed wont be able to use the tutorials that make use of the components. You can buy Macromedia Flash Pro 8 from here, or just download a trial first. This is the latest and best version of Flash and we can do nothing else but recommend it to everybody because we absolutely love it. This new edition opens up a lot more of the magic that was already there, and it certainly is a new fresh wind for us Flash developers. Its a great investment for the future.


What am i going to learn in this tutorial ?

Hello reader, im pleased you made the decision to learn more about the localConnection Object. I know it sounds a bit intimidating but rest assured its really not difficult at all. For certain things i found the LocalConnection object to be very useful and that is why i decided to share some of its usefulness with you. The LocalConnection object has a very nice way of setting up a connection between two different swf's. This is very useful when you have multiple swf's sitting in a html page and you want all of them to be able to contact each other and pass some data around.

In this tutorial we are going to setup two different swf's in a html file. The two swf's are connected to eachother and on the press of a button you can send a piece of text to the other swf. You can take this as far as you can, the possibilities are endless.

The two swf's we will create are inside a html page, this is necassary to make the localConnection work, it wont work in flash itself. So first we are going to setup the visuals and code for movieA.swf and then we'll setup the visuals and code for movieB.swf. We then create the html file to hold two swf's and can enjoy our newly learned skill and see it in effect. To learn more about the localConnection Object please visit this link.


Lets get our hands dirty

Download the source files for this tutorial and open movieA.fla. You will see two textboxes, two labels and a submit button. These are flash mx2004 components and are very easy to add. Just press crtl+f7 to open the flash components menu, drag and drop the components you want to use onto the main stage and select the properties box to give it a name. I used components because i didnt want the main focus of this tutorial be blurred with a load of information that isnt related to the localConnection Object and thus i chose for the ease of components.

Now have a good look at how i setup this file, as you can see i have a special layer i use for all the code. I really dislike the way a lot of people code and that is having code spread out all over the place. Code should be executed and controlled from a central place in your swf and should not be placed on objects like buttons etc. Having code in one place makes debugging your code a lot easier to do. You dont have to search in your swf when something goes wrong and this gives you a lot more control.

On the other layers there are two textInput components, two labels and a submit button. One of the input textboxes will be used to send text to the other swf, the other to display the received text. The button will be used to actually call the localConnection.send function to send the text to the other receiving swf. The labels are used to display some instructual text. If you dont know how to setup default text for a component, just do this. Add the component to the document, select it and in it properties box you can set the text under the parameters tab.

Select every item on stage and have a look at its properties box. You will notice every item has a name (called 'instance name') This name is used by actionscript to indenfify the items. Just like we use our names to indenfify ourselves. So only the items that need to be controlled by actionscript, like the input text and display text, must have an instance name.

Ok after having inspected all the items its time to start with the code. Select the first frame of the code layer and press f9. The actions frame will popup and you will see the code that is described on page 2 in front of you.


Amazing Webmaster Widgets




next page
page jump: 1 | 2 | 3 | 4
jump to comments


Comments

9 comment(s) found in 2 pages  
viewing comment(s): 1 - 6
page: 1 

1 | 2 |

05-08-07:guest

28-05-07:guest

thanks for the lesson :) you're explaination are clear and simple to understand great tutorial :D

06-11-06:guest

It works for me with Firefox (1.5.0.7) but it doesn't seem to work with IE 7 and Opera 9

23-02-06:hello

lol nice

19-12-05:guest

12-12-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!
Play World War 2 Commando Free!
Play World War 2 Commando 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 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!
Make cash with Penny Stocks!
Make cash with Penny Stocks!
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