Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Flash - multiple instances with different properties

Posted on 2004-10-27
12
Medium Priority
?
163 Views
Last Modified: 2010-04-03
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
0
Comment
Question by:basiclife
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 16

Expert Comment

by:vickerleung
ID: 12430987
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
 
LVL 16

Expert Comment

by:vickerleung
ID: 12431010
basiclife,

Sample files here~~!!

www.geocities.com/vickerleung/balloon.zip

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

Vicker
0
 
LVL 5

Author Comment

by:basiclife
ID: 12431071
"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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:vickerleung
ID: 12431246
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
 
LVL 5

Author Comment

by:basiclife
ID: 12431292
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
 
LVL 16

Expert Comment

by:vickerleung
ID: 12431352
basiclife,

O~~ sure,

I will upload as MX version

Catch the balloons in your FTP~

Cheers :)
Vicker
0
 
LVL 5

Author Comment

by:basiclife
ID: 12431417
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
 
LVL 5

Author Comment

by:basiclife
ID: 12431426
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
 
LVL 16

Accepted Solution

by:
vickerleung earned 2000 total points
ID: 12431636
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
 
LVL 5

Author Comment

by:basiclife
ID: 12432639
o~~~'s = balloons. sorry
0
 
LVL 16

Expert Comment

by:vickerleung
ID: 12434036
basiclife,

You have scripting error~~!!

It should be

o~~~'s= balloons. sorry;

You missed the semicolon~ haha

Vicker
0
 
LVL 5

Author Comment

by:basiclife
ID: 12439957
lol
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question