Solved

Flash - multiple instances with different properties

Posted on 2004-10-27
161 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
Question by:basiclife
    12 Comments
     
    LVL 16

    Expert Comment

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

    Expert Comment

    by:vickerleung
    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
    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
    basiclife,

    O~~ sure,

    I will upload as MX version

    Catch the balloons in your FTP~

    Cheers :)
    Vicker
    0
     
    LVL 5

    Author Comment

    by:basiclife
    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
    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:
    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
    o~~~'s = balloons. sorry
    0
     
    LVL 16

    Expert Comment

    by:vickerleung
    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
    lol
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Shellfire Box VPN + Lifetime Subscription

    The Shellfire Box easily connects all of your devices, even those that don't offer the possibility to establish a safe vpn connection. Access blocked content and surf safely, no matter where in the world you are located.

    Suggested Solutions

    Title # Comments Views Activity
    FLV versus SWF 11 253
    Microsoft WSUS 4 74
    Virus or Outlook 2007 problem, how to tell? 8 61
    PDF: Display my cards game? 8 26
    I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

    875 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now