Flash Tutorial: Dynamic Buttons

Flash Tutorial: Adding buttons dynamically to the Flash stage using ActionScript

Level: This is an intermeidate lesson, so I will assume that the reader is familiar with the basic use of the Flash software including stage, timeline, drawing tools, property window, etc.

Version: I will be using Flash CS3 and AS2 (athough tut is compatible with earlier versions of Flash) and instructions are for the Mac. Windows users would use the PC counterparts for specific instructions on Flash Menu/Shortcut instuctions.

Source: http://mikestickney.com/wordpress/flash-tutorial-dynamic-buttons/

Description: In this tutorial, I will explain how to add buttons to your Flash movie with dynamic text content using ActionScript:



Let’s get started!

Note: For this tutorial, I will be using the buttons I created for a previous tutorial titled “Animating a button using a mask effect”.

If you haven’t already, I recommend you start with that tutorial, as I will not be going over the animation process of the button symbols in this tutorial. If you already know how to create button animations, you can use your own button animation symbol, or download the previous tutorial source file here.

—- ads by google —-
// //

Select “File > New” (command-”N”) and select Flash File (ActionScript 2.0) to open a new Flash document file. Save the file, and give it the appropriate name. I will call this “dynamicButton_tutorial.fla”. Feel free to change the document dimensions to whatever you like (”Modify > Document or “command-J”), but for the purpose of this tutorial, I will use 250×100 pixels.

Choose “File > Import > Open External Library” (shift-cmd-O), and navigate to where you placed the source file of our previous tutorial (btnWithMask_tut1.fla) and click “Open”. What this will do is open up just the “Symbol Library” of that source file. Tip: You can also access the symbol library of any .fla file you have open with the dropdown menu in your Symbol Library window (Fig. 1).

Dynamic button tutorial fig. 1

We will be using the symbol called “mc_btn1″ from the Button With Masked Animation source file, so we can simply click and drag this symbol from one library to the other. (Fig. 1). If you notice, when you drag the one symbol, it should also place the symbol “img_highlight” in your current file symbol library. This is because the “img_highlight” symbol is used within the “mc_btn1″ symbol, so Flash knows to import all associated symbols as well.

You can go ahead and close the external symbol library so save space since we don’t need any other symbols from there. In our dynamic button .fla symbol library, double click on our “mc_btn1″ symbol to bring us into symbol editing mode. You should see several layers and animation tweens in your timeline. We are going to leave all of this as is, so go ahead and lock all of these layers. What we need to do is add our text boxes that we will be using as our button labels. Add a new layer above your layer named “mask” and call it “text”. WIth the text tool (T), draw a box roughly the same width of our button, and position it on the center of our button shape. Select your text box, and in the Properties Panel (WIndow > Properties > Properties (cmd-F3)), and give it the settings in Fig. 2.

Dynamic button tutorial fig. 2

Now, select the text box, choose Edit > Copy (cmd-C) and then Edit > Paste in Place (cmd-shift-V), and move it 2 or three pixels up and to the left. In Properties Panel, leave all the settings the same, except change the instance name from “textBlack” to “textWhite”, and change the color to white. What we are doing is simply giving our button label a basic “dropshadow” effect, just to make it more easily legible on all the button states.

We are now done editing our button, but since we are going to be placing our button on the stage using ActionsScript, the final thing we need to do is assign our buttona “Linkage” identifier name. Not to be confused with “symbol name” or “instance name”, an identifier name is used to call our button in ActionScript in order to be place on our stage. To give you button an id, right-click (control-click) on your button symbol in your library, and select “Linkage…” from the menu. This will open the Linkage Properties window (Fig. 3). Click on the “Export for ActionScript” check box and in the “Identifier” field, type “button” and hit OK.

Dynamic button tutorial fig. 3

Now, it’s time for our ActionScript. It may look like a lot, but don’t be too intimidated, it’s not nearly as complicated as it looks, I promise!

On our main timeline, click on the first (and only) layer and give it a name of “actions”. In keyframe one, open the Actions Panel (Window > Actions or alt-F9) and paste the following code:

onLoad = function(){
var button:Array = [home, about, contact];

var xPosition:Number = 50;
var yPosition:Number = 15;


_root[”btn”+i]._x = xPosition;
_root[”btn”+i]._y = yPosition;

yPosition = yPosition + 25;

_root.btn0.textBlack.text = “Home”;
_root.btn1.textBlack.text = “About”;
_root.btn2.textBlack.text = “Contact”;

_root.btn0.textWhite.text = “Home”;
_root.btn1.textWhite.text = “About”;
_root.btn2.textWhite.text = “Contact”;

_root.btn0.link = “http://www.spitshine-design.com”;
_root.btn1.link = “http://www.spitshine-design.com/about.html”;
_root.btn2.link = “http://www.spitshine-design.com/contact.html”;

_root[”btn”+(i)].onRollOver = btnOver;
_root[”btn”+(i)].onRollOut = btnOut;
_root[”btn”+(i)].onRelease = btnRelease;
_root[”btn”+(i)].onPress = btnPress;

function btnOver(){

function btnOut(){

function btnPress(){

function btnRelease() {

That’s it! Go ahead and test your movie. You should see 3 buttons appear, stacked, with the top one labled “home”, the middle one labeled “about” and the bottom one labeled “contact”. You should also see the animation on the different rollover states as well.

Since there is a lot of code here, rather than explain it all here, I decided to heavily comment the code in the source file. Since the real objective of any tutorial is for the reader to actually learn WHY things work and not just how, I encourage you to download the source file and read through the comments. The comments also help to explain the different items that need to be edited to customize your menu, such as placement, position and labels.

As always, I hope you found this tutorial helpful, and comments/questions are welcome. Thanks for reading!

My Technorati Profile

Technorati Profile

Thanks for the support guys for the response and comments.

It has been a long time since I haven’t posted something, but it now time to move and give my site a technorati profile claim.


Get URL Parameters Using Javascript

An easy way to parse the query string in your URL to grab certain values.

Get URL Parameters Using Javascript

Most of the server-side programming languages that I know of like PHP, ASP, or JSP give you easy access to parameters in the query string of a URL. Javascript does not give you easy access. With javascript you must write your own function to parse the window.location.href value to get the query string parameters you want. Here is a small function I wrote that will parse the window.location.href value and return the value for the parameter you specify. It does this using javascript’s built in regular expressions. Here is the function:

function gup( name )
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
    return results[1];

The way that the function is used is fairly simple. Let’s say you have the following URL:


You want to get the value from the frank parameter so you call the javascript function as follows:

var frank_param = gup( ‘frank’ );

Now if you look at the frank_param variable it contains the number 321. The query string was parsed by the regular expression and the value of the frank parameter was retrieved. The function is smart in a couple of ways. For example, if you have an anchor in your URL like our example URL above does (#top) the gup() function knows to stop before the # character. Also, if a requested parameter doesn’t exist in the query string then an empty string is returned instead of a null.

This function has worked very well for my query string parsing needs and should work well for you.

url source: http://www.netlobo.com/url_query_string_javascript.html

20 programming lessons


This post could be viewed as hard lessons learned for newly graduated college students, entry-level programmers, or advanced developers who just want a chuckle. I’ve been programming since I was 11 and I’ve loved technology and programming every since. There are some hard and easy lessons I’ve learned over time. As a fellow programmer, you may not have experienced these, but I’m offering them to individuals who are interested in learning more from my experiences.

1. Set a duration of how long you think it should take to solve a problem – C’mon, admit it! I’m just as guilty as the next programmer. I’ve seen programmers sit in front of a monitor for eight hours at a time trying to solve a particular problem. Set a time table for yourself of 1 hour, 30 minutes, or even 15 minutes. If you can’t figure out a solution to your problem within your time frame, ask for help or research your problem on the Internet instead of trying to be super-coder.

2. A language is a language is a language – Over time, once you understand how one language works, you’ll notice similarities between other languages. The language you choose should provide you with a suitable “comfort” level, the ability to produce efficient (and clean) code, and, above all, allow the language to suit the project and vice-versa.

3. Don’t over-“design pattern” applications – Sometimes it’s just easier to write a simple algorithm than it is to incorporate a singleton or facade pattern. For the most part, it even allows for cleaner, understandable code. 🙂

4. Always backup your code – I’ve experienced a complete hard drive failue and lost a lot of code when I was younger and felt horrible because of what had happened. The one time you don’t back up your data may be the one time where you have a strict deadline with a client and they need it tomorrow. Source code/version control applies here as well.

5. You are not the best at programming. Live with it. – I always thought that I knew so much about programming, but there is always someone out there better than you. Always. Learn from them.

Learn to learn more – With number five explained, I’ve always had a magazine or book in my hand about computers or programming (ask my friends, they’ll confirm). True, there is a lot of technology out there and keeping up with it is a fulltime job, but if you have a smart way of receiving your news, you’ll learn about new technology every single day.

7. Change is constant – Your knowledge of technology and/or programming should be similar to how you treat stocks: Diversify. Don’t get too comfortable with a particular technology. If there’s not enough support for that language or technology, you might as well start updating your resume now and start your training period. My general rule of thumb that has kept me going? Know at least two or three languages, so if one dies off, you have another one to fall back on while you train for a new technology.

8. Support Junior – Assist and train the junior/entry-level developers on good programming guidelines and techniques. You never know…you may move up in rank and you’ll feel more confident having personally trained and prepared them for their next position.

9. Simplify the algorithm – Code like a fiend, but once you’re done, go back through your code and optimize it. A little code improvement here and there will make support happier in the long run.

10. Document your code – Whether its documenting a Web Service API or documenting a simple class, document as you go. I’ve been accused of over-commenting my code and that’s something I’m proud of. It only takes a second to add an additional comment line for each 3 lines of code. If it’s a harder technique to grasp, don’t be afraid to over-comment. This is one problem most architects, backup coders, and support groups don’t complain about if you’ve done your job right.

11. Test, Test, Test – I’m a fan of Black Box Testing. When your routine is finished, your “stamp of approval” period starts. If you have a Quality Assurance department, you may be talking more to them than your project manager regarding errors in your code. If you don’t test your code thoroughly, you may develop more than code. Possibly a bad reputation.

12. Celebrate every success – I’ve met a lot of programmers who have conquered headache-style problems with a great programming technique and celebrated with a fellow programmer by doing the “shake”, the high-five, or even a “happy dance.” Everyone has enlightening periods in their life and even though that one happy coder asked you to come and see his extraordinary piece of code and you’ve seen that one piece of code over 100 times in your experiences, celebrate the success of a fellow developer for the 101-st time.

13. Have Code Reviews Frequently – On projects and personally. In the company, you will always have code reviews of how well you coded something. Don’t look at it as people crucifying your coding style. Think of it as constructive criticism. On the personal front, review your code and always ask, “How could I have done it better?” This will accelerate your learning and make you a better programmer.

14. Reminisce about your code – There are two ways to looking at old code: “I can’t believe I wrote this code” and “I can’t believe I wrote this code.” The first statement is often of disgust and wondering how you can improve it. You’d be surprised at how old code can be resurrected into a possible and better routine, or maybe even an entire product. The second statement is of amazement and achievement. Developers have their one or two project code achievements that they completed and had everyone standing up and taking notice. Again, based on your excellent coding ability, you could take those past routines or projects and update them into a better product or idea.

15. Humor is necessary – In my 20 years of development, I have never met a programmer who hasn’t had a decent sense of humor. Actually, in this industry, it’s a requirement.

16. Beware the know-it-all, possessive coder, and the inexperienced coder – Humble yourself when you meet these types of coders. The know-it-all tries to upstage you instead of working as a team player, the defensive coder created code that he doesn’t want to share with anyone, and the inexperienced coder constantly asks for assistance every ten minutes where the finished code developed is yours, not theirs.

17. No project is ever simple – I’ve been asked by friends, family, and associates to just “whip something up for me.” To “whip” up a program or web site, it takes planning from both parties to complete something that both sides can appreciate. If someone needs a 3-page web site with Microsoft Access from the start, it winds up becoming a 15-page web site with SQL Server, a forum, and a custom CMS (Content Management System).

18. Never take anything for granted – If you take on a simple project, you may think that a certain section will be easy to complete. Don’t think that even for a moment. Unless you have a class, component, or piece of code already coded…and has been tested thoroughly…and is in production from an existing project, don’t think it will be easy.

19. Software is never finished – A fellow programmer once told me that software is never finished, it’s “temporarily completed.” Sound advice. If the client is still using a program you wrote and has stood the test of time, chances are, you are still updating it, which isn’t a bad thing. It keeps you working. 🙂

20. Patience is definitely a virtue – When clients, friends, or family members use a PC, they get frustrated and proceed to hit a component of the PC or storm off. I keep telling everyone, “you are controlling the computer not the other way around.” You need to have a certain level of patience for programming computers. As soon as programmers understand what they did wrong, they look at it from the computers point of view and say, “Oh, that’s why it was doing that.”

The Five Most Soul Sucking Jobs

I have worked all of these jobs except inside sales. I would never do sales because I may as well just cut myself or go play basketball for the Portland Trailblazers.

The most soul sucking jobs in the world are those that make you do naughty things in order to earn a living. Here’s five of them, based on my experience.

1. Bill collector

Why: It’s your job to call old ladies who are on social security who can barely afford groceries and their pills and convince them to cut you a check for a cell phone bill. Either you’re a heartless bastard or you go home at the end of the day feeling emotionally drained.

2. Call center phone jockey

Why: It’s your job to be a meat socket in between the customer and the information or menial tasks that will fix their problem. You think your job is to help the customer, but your job is really to do what your company tells you to do. You’re in constant emotional conflict between doing what’s right for the customer talking in your ear and doing what’s right for the company that pays your wages.

3. Inside salesman

Why: You do whatever it takes to make a sale or you get fired. You make buddies with guys you would never even look at outside your job. You talk it up, you play it nice, you promise the customer anything and it makes you a selfish, materialistic bastard in your life outside work.

4. Factory laborer

Why: You repeat the same action over and over for eight to twelve hours at a time for low pay. You do this all day every day until you are laid off or fired. Your life is a miasma of waking work and sleeping. Your motions and responses are mechanical like your job. You’re depressed because your life lacks color and feeling. You are a cheap replacement for a machine that could do your job better than you could ever hope to.

5. Temp to hire employee

Why: Your job depends on your going the extra mile. While some people get promotions and bonuses for going above and beyond the call of duty, for you it’s a job requirement. There are easily hundreds of people who could do your job and you could be replaced at any time. The only possible reward you might have coming to you is a full time job. You fantasize about the carrot that’s dangled over your head every waking second. Maybe, someday, if you work extra hard your contract will turn into a real job. But probably not. Your employer knows all about dangling the carrot and they know you’ll push yourself just a little harder if they hint that you might be headed for a conversion.

source from: foxmajik

url: http://foxmajik.livejournal.com/877073.html

Third Eye Blind – Burning Man

The rise and fall of my sloppy love
The smatterings, and splatterings
They’ll get you
I’m not the one you were thinking of
Maybe you thought I’d call
Instead of crashing down your hall
Hold me down, I wanna find out
You know you will never get what you need
Blue Diamond strike ’em anywhere
First we caffeinate then incinerate
We’ll get you
And sparks will fly in the summer air
Did you pull out of your stall
Maybe I’ll see you after all
Hold me down, I wanna find out
We say no, cause I live my life like a burning man
Like a burning man, a burning man
Like a burning man
And I won’t get enough until my legs are broken
The stars they shine in an empty void
Life is not to fear, life is to enjoy
He’ll get you
Oh, Mr. Death catches all someday
Baby I thought you’d call
Or leave a light on in the hall

Hold me down but I’ll find out
We say no, cause I live my life like a burning man
Like a burning man, a burning man
Like a burning man
Hold me down, I wanna find out
We say no, cause I live my life like a burning man
Like a burning man, a burning man
Like a burning man
And I won’t get enough, until my legs are broken


Solve Compaq Presario Serial ATA (SATA) controller



Compaq V3000 – Presario Driver Download Page