A Flash Developer Resource Site

Page 3 of 3 FirstFirst 123
Results 41 to 52 of 52

Thread: reverse the animation while mouse rolls out

  1. #41
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    That was the solution I posted for AS1........ attached is the demo movie. I have Flash8 now ...... give me a few minutes and I'll look into upgradeing it.

    Edit....... Just tested with player version 8 with AS2.0 and it seems to work the same.

    FlashMX version...
    Last edited by NTD; 03-01-2006 at 11:45 PM.

  2. #42
    Freelance Web Designer ehabaref's Avatar
    Join Date
    Nov 2005
    Location
    New York City
    Posts
    212
    ah ok
    well, i don't have flash 8. but if you say so then that's great

  3. #43
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    I had a few minutes so I streamlined the code a bit. This should work with AS1 or AS2 but requires the same nameing convention as in the demo movie... ie.... rewind movieclips with a base name of "sq" and button MC's with a base name of "btn"...

    code:

    MovieClip.prototype.universalRewind = function() {
    //base instance name of rewind clips
    targetBaseName = "sq";
    this.onRollOver = function() {
    //store the last letter of the current buttons name as the index
    indexOn = substring(this._name, this._name.length, -1);
    trace(index);
    _root[targetBaseName + indexOn].play();
    }
    this.onRollOut = function() {
    //store the last letter of the current buttons name as the index
    indexOff = substring(this._name, this._name.length, -1);
    _root[targetBaseName + indexOff].onEnterFrame = function() {
    this.prevFrame();
    if (this._currentframe == 1) {
    delete this.onEnterFrame;
    }
    }
    }
    }
    //Assign the rewind function to the buttons
    i = 0;
    totalButtons = 3;
    buttonBaseName = "btn";
    while (++i < totalButtons + 1) {
    _root[buttonBaseName + i].universalRewind();
    }



    Should make it easier to apply to multiple clips without the repetitive code

    Hope it helps
    Regards
    NTD

  4. #44
    I'm learning... Thankful's Avatar
    Join Date
    Jun 2005
    Location
    e.v.e.r.y.w.h.e.r.e
    Posts
    487
    Thank you guys so much, this work great...

    However, there is only one little problem now... At the state when one of those lines reaches its "long" point, and you remove your mouse pointer from the button, line starts to go back (as it suppose to), but if you quickly try to hover over the button one more time, line won't extend again untill it completely goes back to its starting point. Then you can hover and "activate" animation again...

    Is there any way, we can have something like in that example from one of my previous posts, with FlashKit 3D letters (NTD's code)... doesn't matter at what point you try to hover over the moiveclip, it always "reacts" immediatelly...

    I hope I explained this so you can understand... if not, just let me know and I iwll try again.

    Cheers !
    :: ONLINE PORTFOLIO :: web site (Flash version 7 required, recommended screen resolution: at least 1024x768 pixels)

    :: SASHA-Z-CREATIONS :: web site

  5. #45
    I'm learning... Thankful's Avatar
    Join Date
    Jun 2005
    Location
    e.v.e.r.y.w.h.e.r.e
    Posts
    487
    I just found something on Kirupa.com and it works perfectly. Originally it was just one button, but I multiplied it and now there are 3 buttons on the stage not interfering one with another... also backward action works always regardless of at what point you hover those buttons with your mouse pointer.

    Example can be seen here:
    http://img231.imageshack.us/my.php?i...button37yl.swf

    Just wanted to ask our friend NTD, what he thinks about this solution... is it still good or it needs some additional improvements ?

    Thanks again people, you are the best !

    P.S. Fla file is in attachment...
    :: ONLINE PORTFOLIO :: web site (Flash version 7 required, recommended screen resolution: at least 1024x768 pixels)

    :: SASHA-Z-CREATIONS :: web site

  6. #46
    I'm learning... Thankful's Avatar
    Join Date
    Jun 2005
    Location
    e.v.e.r.y.w.h.e.r.e
    Posts
    487
    Double post by mistake... sorry...
    :: ONLINE PORTFOLIO :: web site (Flash version 7 required, recommended screen resolution: at least 1024x768 pixels)

    :: SASHA-Z-CREATIONS :: web site

  7. #47
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    To adapt the function I posted to work as you described, just delete the current objects enterframe event on rollover....

    code:

    MovieClip.prototype.universalRewind = function() {
    //base instance name of rewind clips
    targetBaseName = "sq";
    this.onRollOver = function() {
    //store the last letter of the current buttons name as the index
    indexOn = substring(this._name, this._name.length, -1);
    trace(index);
    //delete the current objects enterframe event on rollover
    delete _root[targetBaseName + indexOn].onEnterFrame;
    _root[targetBaseName + indexOn].play();
    }
    this.onRollOut = function() {
    //store the last letter of the current buttons name as the index
    indexOff = substring(this._name, this._name.length, -1);
    _root[targetBaseName + indexOff].onEnterFrame = function() {
    this.prevFrame();
    if (this._currentframe == 1) {
    delete this.onEnterFrame;
    }
    }
    }
    }
    //Assign the rewind function to the buttons
    i = 0;
    totalButtons = 3;
    buttonBaseName = "btn";
    while (++i < totalButtons + 1) {
    _root[buttonBaseName + i].universalRewind();
    }



    The demo you posted seems to work pretty well, although, I prefer frame code over object code. Say you had 1000 of those buttons on stage and you needed to edit the url property I know.. a bit of a stretch with 1000 buttons.... but hopefully you get the point that frame code is easier to edit. The demo utilizes the same method of wrapping a prevFrame in an enterFrame event. There are several ways to use this technique. Whatever works best for you is the way to go

    Regards
    NTD
    Last edited by NTD; 03-02-2006 at 10:36 AM.

  8. #48
    I'm learning... Thankful's Avatar
    Join Date
    Jun 2005
    Location
    e.v.e.r.y.w.h.e.r.e
    Posts
    487
    Thank you NTD my friend, and you are helpfull like always

    Yes I get your point, and I understand now that frame code is much more efficient and easier to edit (manage) when you have a bunch of movieclips like that. You just simply open one frame and edit everything inside... much easier than searching all around your FLA file and editing each button (or MC) separatelly... Yes, this is very useful and it works perfect. I got your point, thanks again !

    however, in this particular case, I just needed two buttons (MCs) to work together without interfering one with another... so, object code also works.

    But sure, in the future whenever I have for example, 5 or more buttons (MCs) inside my FLA file I will use frame code.

    Cheers !

    EDIT:

    Just one small correction for future reference in case someone also have similar problems...

    At the end of your code (latest reply) there is just one "}" missing... thats' all, other than that it works perfectly...
    Last edited by Thankful; 03-02-2006 at 10:33 AM.
    :: ONLINE PORTFOLIO :: web site (Flash version 7 required, recommended screen resolution: at least 1024x768 pixels)

    :: SASHA-Z-CREATIONS :: web site

  9. #49
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    Whatever gets a project to fruition and works as expected is the way to go The function I posted could be extended in several ways, such as controlling the movieclip property from the function instead of using a manual tween, but I'll leave that up to others to explore for the time being

    Regards
    NTD

    Edit*** Oops ........ fixed the missing brace

  10. #50
    I'm learning... Thankful's Avatar
    Join Date
    Jun 2005
    Location
    e.v.e.r.y.w.h.e.r.e
    Posts
    487
    Ok, and now all I want from you is to admit that you actually came somewhere from outer space

    I simply admire you guys, and you are incredible... what a knowledge and the way you use your knowledge is also outstanding. Best of all, you make all of us mortals, very interested in all that stuff, and you make everything sound like ".it's not easy, but it's possible and it's do-able...".

    That gives us some kind of feeling "yes, I want to do that, and I will do that this way or another, but sure I will do that..."

    Thanks again !
    :: ONLINE PORTFOLIO :: web site (Flash version 7 required, recommended screen resolution: at least 1024x768 pixels)

    :: SASHA-Z-CREATIONS :: web site

  11. #51
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Ok, and now all I want from you is to admit that you actually came somewhere from outer space
    ...3rd rock from the sun, just like everybody else

    I find inspiration from lots of coders around FK as well as people with a creative eye and desire to learn. Hopefully someday I'll be able to break into the industry full time instead of small independent projects. I think I'm ready

    Regards
    NTD

  12. #52
    I'm learning... Thankful's Avatar
    Join Date
    Jun 2005
    Location
    e.v.e.r.y.w.h.e.r.e
    Posts
    487
    Judging by your work and your personality, you are more than ready my friend... trust me on this one, I know exactly what I'm talking about...

    I don't know everything but that doesn't mean I am not interested in everything because I really am. I also know I will never be able to learn some stuff some other people are magicians for, but that doesn't stop me to try...

    Life is full of ups and downs... you have to try... you will land hard many times, but you always have to get up and try again... until you manage to do it finally... you know about the old one:

    "What doesn't kill you, it just makes you stronger"

    And it is so true... sooo true.

    Cheers !
    :: ONLINE PORTFOLIO :: web site (Flash version 7 required, recommended screen resolution: at least 1024x768 pixels)

    :: SASHA-Z-CREATIONS :: web site

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