dcsimg
A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: multiple mc communication

  1. #1
    Junior Member
    Join Date
    Feb 2003
    Location
    Reading
    Posts
    7

    multiple mc communication

    Hi can you help me with some script please...

    Have a cluster of 3d graphic movie clip animations that act as buttons. Each mc has a label referencing the open 'n' closed state as well as an instance name i.e cube1, cube2 etc.

    I have managed to get the mc's to work independently using action script to open and close. BUT what I want to achieve now is only open one button at a time i.e. one door closes another door opens.

    So... you click on a button and it plays the animation and stops at 'open'. When you click a different button the current button that is 'open' plays the 'close' animation before playing the 'open' animation within the new button mc.

    How the hell do you capture what's open and whats closed and translate that ???

    Dax.

  2. #2
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    You can use arrays.

    For eg, you could add all the MC instances to an array. Then when you click on a button:

    for (i=0;i< MCarray.length;i++){
    MCarray[i].gotoAndPlay(inactive);
    }
    this.gotoAndPlay( active );

  3. #3
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    another method: remember which one is open:

    Code:
    _global.currentActive = null; //nothing open
    
    //// onRelease button code:
    function doorRelease ()
    {
       if(currentActive != null)
          currentActive.gotoAndPlay('inactive');
    
       currentActive = this;
       this.gotoAndPlay('active');
    }
    
    // attach:
    cube1.onRelease = doorRelease;
    - n.

  4. #4
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    You still need to tell the others to go in though. Although, you could have them all respond to a change in the global variable instead.

  5. #5
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    Originally posted by AlsoGaiusCoffey
    You still need to tell the others to go in though. Although, you could have them all respond to a change in the global variable instead.
    but only one is open at any time, so you can use a single variable to remember which one that is. you don't need to loop through the others because you know that they are closed already.

    - n.

  6. #6
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Nicely done, next time I'll read your code!

  7. #7
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    Originally posted by AlsoGaiusCoffey
    Nicely done, next time I'll read your code!
    (I probably only read yours properly because it was so short )

    - n.

  8. #8
    Junior Member
    Join Date
    Feb 2003
    Location
    Reading
    Posts
    7

    help me i'm drowning

    Hello chaps,

    You all sound very knowledgeable in this particular field
    Unfortunately im not! can you possibly help me further?

    Here is an example script taken from one of my buttons (remember I have a series of these boys!). As you can see I enjoy utilising nested mcs.

    d4 is the instance name for one of the animated mcs containing open and closed labels.
    My experience with action script is very limited... Im trying v.hard to develop promise would really appreciate some input on how to intergrate what you posted previous with my failed attempt. Hope it makes sense!

    Dax.



    //THIS IS TELLING MY 3D GRAPHIC TO PULSE
    on (rollOver) {
    _root.Cube_S.d4.d4original.square_id_d4.gotoAndPla y("start");
    }
    on (rollOut) {
    _root.Cube_S.d4.d4original.square_id_d4.gotoAndSto p("stop");
    }

    //THIS IS WHERE I AM STUCK!!!
    on (release) {
    if (d4.id > 0) {
    trace(id);
    _root.Cube_S["d" + id].gotoAndPlay("open");
    myClip = _root.Cube_S["d" + id];
    }
    _root.Cube_S.d4.gotoAndPlay("closed");
    id = 4;

  9. #9
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Courtesy of Emenem:

    Paste this into the _root timeline (first frame seems appropriate)
    PHP Code:
    _global.currentActive null//nothing open

    //// onRelease button code:
    function doorRelease ()
    {
       if(
    currentActive != null)
          
    currentActive.d4original.square_id_d4.gotoAndPlay("stop");

       
    currentActive this;
       
    this.d4original.square_id_d4.gotoAndPlay("start");

    Then change the button push to:
    PHP Code:
    on (release) {
    _root.doorRelease ();


  10. #10
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    well, pulsing isn't bad - some people would pay good money for that

    what code did you use to make them play independently? say to make cube1 open / close?

    - n.

  11. #11
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    sorry, I was a bit too slow...
    thanks AlsoGaiusCoffey!

    - n.

  12. #12
    Junior Member
    Join Date
    Feb 2003
    Location
    Reading
    Posts
    7

    interesting...

    Not sure previous mail went up, so hear it is again:

    Had a wee play with your code and basically couldn't get it to play ball!
    Have attached an example fla file could you possibly have a look. You can see my pulsating button in action!

    Oh that sound really bad.

    B good if you can help.
    Cheers

    Attached Files Attached Files

  13. #13
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    hi daxellmer,

    might just be a problem with my browser or flashkit but can't open the attached fla, sorry!

    - n.

  14. #14
    Junior Member
    Join Date
    Feb 2003
    Location
    Reading
    Posts
    7
    The fla is a mac based file if that is of any help? I will resave out on a pc and re post shortly.

  15. #15
    Junior Member
    Join Date
    Feb 2003
    Location
    Reading
    Posts
    7

    working example

    Please see attached zip file.
    many thanks

    Dax.
    Attached Files Attached Files

  16. #16
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    thanks dax.

    I've had a look and ended up changing quite a bit, sorry

    Basically, you don't need to use new movie clips for each new cube, just use instances of the same symbol.

    I've changed the instance names to make it a bit easier to see what's going on, changed the 'doorRelease' function a little, changed the code inside the cube movie clips quite a bit (to use relatives references instead of absolute ones - you always started at '_root' again when targeting a movie clip). Also introduced another function that works out which popup.swf to load when a button is clicked (all the cubes are the same symbol now, so can't hard-code that anymore).

    Hope most of it will make sense - should all be working now. You might have to tweak the code that closes the popups though.

    :ccol: - n.
    Attached Files Attached Files

  17. #17
    Junior Member
    Join Date
    Feb 2003
    Location
    Reading
    Posts
    7

    You are the MAN!!!

    Looking really cool nice to see it working at last!
    Thanx v.much for all your help and input - look forward to advancing my project now.

    damn your good.

    Dax

  18. #18
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835

    Re: You are the MAN!!!

    Originally posted by daxellmer
    Looking really cool nice to see it working at last!
    Thanx v.much for all your help and input - look forward to advancing my project now.

    damn your good.

    Dax
    you are welcome! I tried to click as fast as possible to see whether it would break but it kept moving nicely...

    have fun with the rest of it - n.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center