Balloon algorithm in actionscript 3

date: 03 Oct, 2009, actionscript: 3 FP9, complexity: complexity level 4.09 of 5complexity level 4.09 of 5complexity level 4.09 of 5complexity level 4.09 of 5complexity level 4.09 of 5, feedback (votes): users score 4.94 of 5 (290 votes)users score 4.94 of 5 (290 votes)users score 4.94 of 5 (290 votes)users score 4.94 of 5 (290 votes)users score 4.94 of 5 (290 votes)

This Balloon was an experiment I did playing a bit with Verlet physics (if I can catalogue the Verlet concept as part of physics). Using Verlet can be quite powerful but at the same time is a bit limited due to the simplicity of how physics are applied, we don't have much control of it and for adjusting stiffness between dots we need to do quite much, there are some people out there working a lot with it and making amazing things like this physics engine for actionscript 3.

In this experiment I made a rope (string) based on 30 dots linking them each other by using Splines curves. There is not mystery on this project, it can look complicated but it is not, it is based on the normal behaviour of Verlet particles. Verlet concept is very simple but looks like a huge monster engine running behind when what it does is basically moving dots on the screen based always on their previous positions, so the speed and direction of each dot is defined just by using the difference between its current position and the previous one and at the end all we need to do is just stick all dots together again trying to maintain same distance they got from the beginning to maintain its shape (polygon made of these dots).

At this moment I got a really basic system for animating this balloon, it is still a beta version but what I got so far can be downloaded here; I hope it could be usefull to someone, I have to finish it as soon as I have some spare time. Also I'm planning to break the whole source code in order to explain well detailed each part of it. I think it is really important understand how it works, you could apply these concepts almost in any kind of project (interactive game) you do if you want to have a beauty UI and offer a cool user experience.

With the source code I just added a tiny SWC called BalloonSkin.swc, it contents the balloon MovieClip (Sprite, it is not animated) that is being used in the program but the rest is being drawn on the fly. All you need is the Open Source Flex SDK, this source code is compatible with flash player 9, and don't forget to add the SWC when you compile it by using the parameters –library-path+=BalloonSkin.swc

Windows XP command line

Pull the balloon by the string with your mouse, but be careful I'm not validating screen dimensions, so if you lost it you may refresh your browser to see it again, lol!


download sourcecode - feel free to ask any question about this balloon.

have you seem this balloon in HTML5? have a go, I just translate it all to HTML5.

date: 08 Mar 2012 - 13:16:38, published by Bob
OK, got an example working. In Flash, for the stage properties, point the Class toward the BalloonMain class. Thanks, fun stuff.
date: 08 Mar 2012 - 13:07:18, published by Bob
OK, I'm a dope. How do I use your swc in a Flash file. So, far I am able to see the BalloonRed in my Component Panel, but now what do I do with it? You don't happen to have a zipped file of a completed fla using your code? Looks cool but I'm a dope.
date: 18 Aug 2011 - 21:06:50, published by KralOyun
Very useful work. I will download sourcecode.Thanks...
date: 18 Jun 2011 - 04:30:34, published by Niklas
Hi there! Interesting article. The baloon though is running virtually the same in both HTML5 & flash for me.
date: 02 Mar 2011 - 02:26:35, published by Sahil
great, fabulous and awesome work
date: 03 Apr 2010 - 02:14:20, published by shan
so cool n excellent..work..........praiseful....friend
date: 08 Mar 2010 - 00:12:12, published by marco
Alex : The great Marco from MX
date: 06 Feb 2010 - 11:54:44, published by pinkninja
hey dude, I been looking for something like this a while ago, definitely Verlet concept rocks! it is quite good in terms of performance, awesome! let me know when the source code is available cheers!