Flash - multiple instances with different properties

This question is a follow-up to http:Q_21185524.html

I want to create floating balloons which are buttons with different colour, text and motion. Any help greatly appreciated
LVL 5
basiclifeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vickerleungCommented:
basiclife~

Haha is great that you really wanna know about it~!!

The scripts are little bit hard right here,
I will provide you my sample file later~!!

However I will point out the steps here.

First of all, draw a simple balloon movie clip~
This movieclip should contains a ballon image and a dynamic text field named "content"
Remember that it should be a movieclip!!

And then in the library, right click the balloon mc, click linkage...
Identifier field fill in "balloon"
And then tick the export for actionscript and tick the export in first frame boxes.

In the main stage, add the following codes in frame 1

_root.createEmptyMovieClip("balloon_area", 1); // This is the area which the balloon will be present.
_root.balloon_area._x = 0; // Confirm the position of the balloon area
_root.balloon_area._y = 0;
_root.balloon_number = 1; // This is a number to identify each balloon from each other

_root.balloon_content = new Array ("flash", "dreamweaver", "firework", "freehand", "expert", "exchange"); // An array to store all the names for the balloon

And then add these codes in frame 10, actually what frame number larger than 1 is ok. No big deal
 
balloon_name = "balloon_" add _root.balloon_number; // This will make a more meaningful name for the balloon
_root.balloon_area.attachMovie ("balloon", balloon_name, _root.balloon_number); // It pull a balloon from the library to the balloon area
_root.balloon_area [balloon_name]._x = random (640); // Randomly place the balloon on the stage
_root.balloon_area [balloon_name]._y = 480; // Put the balloon to the bottom
_root.balloon_area [balloon_name].content.text = _root.balloon_content [random (6)]; // Put random text into the balloon
_root.balloon_area [balloon_name].speed = random (5) + 3; // Random speed of the balloon

_root.balloon_area [balloon_name].onEnterFrame = function ()
{
      this._y = this._y - this.speed; // Move the balloon according to it's own speed
      
      if (this._y < -250)
      {
            this.removeMovieClip (); // Remove the balloon is it is out of bound
      }
}
_root.balloon_number++;


on frame 50, put in this code
actually this is a loop back to the code in frame 10 so that another balloon is built
so, if this frame is farer, the balloon will be generated slower

gotoAndPlay (10);

That's it~~!! :)
Vicker
0
vickerleungCommented:
basiclife,

Sample files here~~!!

www.geocities.com/vickerleung/balloon.zip

Of course, draw better balloon than mine before use :p

Vicker
0
basiclifeAuthor Commented:
"This GeoCities site has been deactivated due to inactivity."

You can upload the file here and it'll arrive on my PC

http://bristol-house.demon.co.uk/uni/upload.php put the file in /misc
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

vickerleungCommented:
basiclife,

Haha I am sorry that it is inactivated,

But it is funny that I just upload my file, and it say inactive =.=""

no matter, I have reativated my site and also uploaded to your FTP
Sorry for any inconvenience~

Gd luck :)
Vicker
0
basiclifeAuthor Commented:
No inconvenience at all. Thatnks for the upload. I'm guessing you're using MX 2004? I'm using MX and it wouldn't open the file, however, with a little bit of imagination and a hex editor I can see the script in the file itself (well most of it, I think).

Nice balloons ;-)

If you're bored and have the time, could you upload the file in an older format? Or will my version be unable to do the scripting you've described?

Either way I'm going to sit and have a play for a few hours. Thanks very much for your help so far

In case anyone else wants the file you uploaded, it's at http://bristol-house.demon.co.uk/balloon-28.10.04-09.03.56.zip
0
vickerleungCommented:
basiclife,

O~~ sure,

I will upload as MX version

Catch the balloons in your FTP~

Cheers :)
Vicker
0
basiclifeAuthor Commented:
ok, that file's at  http://bristol-house.demon.co.uk/balloon-28.10.04-09.27.01.zip for anyone reading this later...

Ok, that one loads fine - Thank you very much!

I can see it creating the objects and scrolling through their locations, setting captions, etc...

Ok, some questions: Why does it have to be a movie clip? as I said in the last thread I'm new to this (although the programming itself is not a problem, just the concept here). Also, how can I add mouse interaction? Are the o~~~ 's actually buttons? Despite the fact they're created as a movie clip?

_root.balloon_area[balloon_name].content.text = _root.balloon_content[random(6)]; <-- The 6 is the size of the array I'm guessing?

and lastly, what controls the rate of creation of balloons? Did I miss something? I'm gussing there is no reasonable limit to how many balloons you have except memory / rendering speed (this won't be an issue but I'm curious)
0
basiclifeAuthor Commented:
And now I've left you with that Mammoth set of questions, I'm off to get some sleep. See you tomorrow. Thanks for your help
0
vickerleungCommented:
basiclife,

haha~~ a bunch of questions,
If everyone costs you 500 points, I am sure you will gone mad~

OK, I will try my best to answer them one by one

Why movieclip?
The answer is that it is not simply a graphic =.=""
Quite stupid answer, right?
Actually the point is that, if you have dynamic content, it must be movie clip

The o~~~'s.....
Are you saying the black frame white center o in the movieclip?
It is just the moving point of the movieclip
Hard to explain, I will find some reference for you later

Size of the array...
yep exactly

The rate of generation... ha~ check the following lines I mentioned before

//////////////////////////////////
on frame 50, put in this code
actually this is a loop back to the code in frame 10 so that another balloon is built
so, if this frame is farer, the balloon will be generated slower

gotoAndPlay (10);
//////////////////////////////////

This is actually controlled by the movie frame rate
say for an example 30 fps
and now the frame difference is 50 - 10 = 40
so around 1.3 sec a balloon will be generated (or say in another way the generate script will be run)

Waa~~ finished them all~~ 1... 2... 3... 4... 4 questions, cost you..... emmm... 2000 points XDD
Kidding~~

Hey~~ Explore more in actionscripts, more and more function is coming~~!!

Cheers :)
Vicker

P.S. I have to go too~ See you after a serveral hours~
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
basiclifeAuthor Commented:
o~~~'s = balloons. sorry
0
vickerleungCommented:
basiclife,

You have scripting error~~!!

It should be

o~~~'s= balloons. sorry;

You missed the semicolon~ haha

Vicker
0
basiclifeAuthor Commented:
lol
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.