Categories
Featured jobs
» More ActionScript, Flash and Flex jobs.
» Advertise a job for free
Our network
Advertisement

 »  Home  »  Tutorials  »  Flash  »  Beginner  »  Instance Names

Instance Names

By Jesse Stratford | Published 09/9/2005 | Beginner | Rating:
Jesse Stratford
Jesse lives and works in Melbourne Australia. He is the Cofounder and a Director of http://ActionScript.org. A Flash enthusiast, teacher, author, freelancer and speaker Jesse enjoys participating in the http://ActionScript.org community and the wider Flash scene when he has time. 

View all articles by Jesse Stratford
Page 1 of 1
Written by: Jesse Stratford
Time: 5 minutes
Difficulty Level: Beginner
Requirements: Flash 5 or higher.
Topics Covered: Instance Names.
Assumed knowledge: Basically nothing.

Download the source for the above movie here. (Zipped, PC Flash 5 file).

This tutorial outlines, just briefly, what Instance Names are since we will make reference to them all through this site, in all levels of tutorials and open source.

An instance is a copy of any symbol from your Flash file's library which resides on the stage. So any graphic, button or movie clip you put on the stage is an instance. All instances have Instance Names, which by default are "instance1", "instance2", etc.

Instance names become important and useful when you begin using Actionscript at any level. Say you want to look up John Smith in the phone book. You grab the book or jump online and do your search for John Smith. Then when you find his details you can call him and tell him/ask him stuff. It's the same with objects on your stage. You can't tell them or ask them stuff until you know what they're called and where they "live". For the moment we're just working out their names. Where they live is covered in the Paths tutorial.

Up to Flash 5 instance names were only really applicable for Movie Clips, but in MX we can address buttons using their instance names and do all sorts of fancy stuff, so they've become even more important! So let's just quickly run through how to make a clip with an instance name. Go File > New. Now Ctrl F8 will create a new symbol. Name it anything you like, select Movie Clip and hit OK. Now draw a small graphic within this movie clip and press Ctrl E to return to the main stage. Ctrl L will bring up your library. From here, drag one copy of your movie clip on to the stage. Select your movie clip and fire up the Instance Properties Panel (Flash MX), Instance Inspector (Flash 5) or right click and go to Properties (Flash 4).

Now in the "<Instance Name>" field type a name for the instance you've just created (I'll do "Joey", without the quotes of course). Save your file and then Test it using Ctrl Enter. While in the test environment press Ctrl L to bring up the Layers and Objects debugging window. You should now have one copy of clip "Joey" on your stage. The debugging window shows this as Movie Clip: Frame=1 Target="_level0.Joey" which means that Joey is a Movie Clip element, on Frame 1 and its full path is _level0.Joey.

And that's it! I would now recommend you read the Paths tutorial as a quick follow up to this one. Remember to post questions on the Forums rather than emailing me.

Jesse Stratford is the Co-Master of ActionScript.org and a freelance Flash developer and teacher. He is based in Australia and enjoys all things Flash.

NB: If you have comments or feedback please feel free to email me, but please do not email me Flash questions; the forums are provided for that purpose and you will get a faster answer by posting you question there.

If you have found this tutorial helpful, I hope that you will take 30 seconds to visit The Hunger Site where, with just one click you can make a free donation of food to a starving person in a third-world country. We do not benefit financially from this action; it is purely an act of charity.
This tutorial is protected by International Intellectual Property Rights laws and may not be reproduced or redistributed in full or part, without the prior written consent of the author. Unauthorized reproduction of this tutorial or its contents may result in prosecution. I've worked hard on this tutorial, please don't steal it.

How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent

Verification:
Enter the security code shown below:
img


Add comment

Spread The Word / Bookmark this content

Clesto Digg it! Reddit Furl del.icio.us Spurl Yahoo!

Related Articles
Comments
  • Comment #1 (Posted by Leanne - leannetempest at yahoo.co.uk)
    Rating
    The tutorial explains instances but does not explain how the instance names are displayed when each mouse is clicked. Ive downloaded the file and cannot figure out how it works. I assume actionscript makes this work but cannot find any within the file.
     
  • Comment #2 (Posted by rhonda - rhonda.parsons at gmail.com)
    Rating
    this was fun! I just wish you had a link to the paths tutorial.
    Thank you for this!
     
  • Comment #3 (Posted by jskdoo - j at fretfreak)
    Rating
    The AS code is found in the mouse movie clip. The code is:

    on (release) {
    /:name = _name;
    /:target = _target;
    }
     
  • Comment #4 (Posted by Raja - rajaasekar at gmail.com)
    Rating
    on(release){
    this.name = _name;
    this.target =_target;
    }

    this code is not working in flash 8...?
     
Submit Comment



Search Entire Site
Add to Google
Advertisements
Article Options
Latest New Articles
Set up a simple IIS Server for Flash
by Peter McBride

Day 1 at FITC Toronto 2008
by Anthony Pace

Simple reflection effect with AS2
by Jean André Mas

ActionScript.org Meets Josh Tynjala (aka dr_zeus)
by ActionScript.org Staff

Rapidly Create Online Flash Movies to Help Users Market, Sell and Support Software and Hardware
by Sabrina F

mailing list
Enter your email address:
mailing list
Subscribe Unsubscribe
© 2000-2007 actionscript.org! All Rights Reserved.
Read our Privacy Statement and Terms of Use...
Our dedicated server is hosted and managed by WebScorpion Webhosting.