A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 52

Thread: reverse the animation while mouse rolls out

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

    Yes, the line in the middle is the bitwise operator "Or". Check to make sure your instance names are correct. The function is applied the same way a standard play or stop function is invoked.....

    code:

    myButton.onRollOver = function() {
    startFrame = 1;
    mcInstanceName.play();
    }
    myButton.onRollOut = function() {
    startFrame = 0;
    mcInstanceName.back();
    }



    I only have FlashMX and most posted files are MX2004 or later, so I didn't look at the file.

  2. #22
    Member
    Join Date
    Apr 2004
    Location
    UK
    Posts
    57
    Here is the list of different operators for AS

    http://www.macromedia.com/support/fl...pt_dictionary/

  3. #23
    Freelance Web Designer ehabaref's Avatar
    Join Date
    Nov 2005
    Location
    New York City
    Posts
    212
    Quote Originally Posted by NTD
    Hi,

    Another method involves Actionscript, using the prevFrame function in an enterframe event to reverse a timeline...

    code:

    startFrame = 0;
    movieclip.prototype.back = function() {
    this.onEnterFrame = function() {
    this.prevFrame();
    // DELETES THE ENTERFRAME IF THE CLIP IS AT FRAME 1
    if (this._currentframe == 1 | startFrame == 1) {
    delete this.onEnterFrame;
    mcInstanceName.play();
    }
    }
    }
    myButton.onRollOver = function() {
    startFrame = 1;
    mcInstanceName.play();
    }
    myButton.onRollOut = function() {
    startFrame = 0;
    mcInstanceName.back();
    }


    OK, i have a question for you. i've been trying to use that reverse effect in a muliple movie clip in one SWF but i got messed up. even though i changed the name of the movie clip. like if the mouse was over one button the other button do the ainmation.. was kinda funny but not what i was looking for. any idea on how to have the same script with diffrent buttons in one SWF?

    have a happy new year, btw

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

    The simple solution would be to remove the prototype and use the function as a normal function. You can specify multiple clips as target parameters. Something like..

    code:

    startFrame = 0;
    function back(targ) {
    targ.onEnterFrame = function() {
    targ.prevFrame();
    // DELETES THE ENTERFRAME IF THE CLIP IS AT FRAME 1
    if (targ._currentframe == 1 | startFrame == 1) {
    delete targ.onEnterFrame;
    mcInstanceName.play();
    }
    }
    }
    myButton.onRollOver = function() {
    startFrame = 1;
    mcInstanceName.play();
    }
    myButton.onRollOut = function() {
    startFrame = 0;
    _root.back(mcInstanceName);
    }


  5. #25
    Senior Member freshly's Avatar
    Join Date
    Dec 2003
    Location
    Toronto, Canada
    Posts
    439
    Try this, put the code on the MC that animates...

    onClipEvent (enterFrame) {
    if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
    this.nextFrame();
    } else {
    this.prevFrame();
    }
    }

    this is the simplest way to make a MC play backwards on rollOut

  6. #26
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    That will work, but it will call the enterFrame event 12 times per second, or whatever frame rate your using, whether the clip is stopped at frame 1 or not. A couple of other onEnterFrame events and an old or slow cpu wont like you much. It's good practice to delete enterFrame events when not in use.

  7. #27
    Senior Member freshly's Avatar
    Join Date
    Dec 2003
    Location
    Toronto, Canada
    Posts
    439
    Hey NTD,

    if I placed updateAfterEvent(); where I did would this solve the problem?

    onClipEvent (enterFrame) {
    if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
    this.nextFrame();
    } else {
    this.prevFrame();
    updateAfterEvent();
    }
    }

  8. #28
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    No, the enterframe event continues to fire at the frame rate per second. UpdateAfterEvent is used to refresh the screen when using setInterval calls. It updates the display (independent of the frames per second set for the movie) when you call it within an onClipEvent handler or as part of a function or method that you pass to setInterval. Flash ignores calls to updateAfterEvent that are not within an onClipEvent handler or part of a function or method passed to setInterval.

    You would need to check if the clip is at frame 1 and delete the enterFrame event. However, with the set up of onClipEvent, this will only allow the code to operate one time once the enterFrame event is deleted. This is why I wrote the function, so that the enterFrame event is reusable after being deleted.

  9. #29
    Senior Member freshly's Avatar
    Join Date
    Dec 2003
    Location
    Toronto, Canada
    Posts
    439
    I'm sorry where do I place this code, can I place it on my MC or do I place it on the timeline

    startFrame = 0;

    function back(targ) {

    targ.onEnterFrame = function() {

    targ.prevFrame();

    // DELETES THE ENTERFRAME IF THE CLIP IS AT FRAME 1

    if (targ._currentframe == 1 | startFrame == 1) {

    delete targ.onEnterFrame;

    mcInstanceName.play();

    }

    }

    }

    myButton.onRollOver = function() {

    startFrame = 1;

    mcInstanceName.play();

    }

    myButton.onRollOut = function() {

    startFrame = 0;

    _root.back(mcInstanceName);

    }

  10. #30
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    I rarely use object code. Consider if you have 1000 movieclips with object code that needs updateing The major difference between object code and frame code is that frame code passes itself to an object by instance name. Frame code is easier to edit at a later point especially with complex projects. The code I posted above would reside on the first frame of a movie. Usually on a layer labeled "actions" above all other content. Pass the instance name of the clip you want to effect in the function parameters....

    _root.back(mcInstanceName);

  11. #31
    Senior Member freshly's Avatar
    Join Date
    Dec 2003
    Location
    Toronto, Canada
    Posts
    439
    Hey I have tried it and it doesn't seem to work, could you post a quick source file for me. I am a designer and "self taught programmer", its usually easy for me to decipher code if I see it!

    That would be great!

    Thanks again!

  12. #32
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Here is a quick demo link of it in action........

    http://www.ntdesigns.net/demoFiles/reverseMC.swf

    The above link uses the first prototype function I posted. I have to step out for awhile. I'll post a demo of the regular function without prototype inheritance later tonight or tomorrow.

    NTD

  13. #33
    Senior Member freshly's Avatar
    Join Date
    Dec 2003
    Location
    Toronto, Canada
    Posts
    439
    Thanks sooo much, I appreciate it!

  14. #34
    Senior Member freshly's Avatar
    Join Date
    Dec 2003
    Location
    Toronto, Canada
    Posts
    439
    Hey NTD, Thankful, and everyone

    In refrence to Thankfuls demo and NTD's code

    the code does not work for flash 8, it plays but does not reverse!

    any fixes?

    I know your working on a source file for me NTD so keep in mind I am
    using flash 8.

    Thanks again!
    Last edited by freshly; 01-04-2006 at 11:28 PM.

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

    I don't have Flash8. Maybe the prototype inheritance is causing an issue as Flash8 uses class based inheritance. However, both AS1 and AS2 are supported by Flash8, so not sure if the problem is code related. Here is a quick demo of using a regular function to control multiple movieclip timelines.

    Regards
    NTD

  16. #36
    Senior Member freshly's Avatar
    Join Date
    Dec 2003
    Location
    Toronto, Canada
    Posts
    439
    Actually this demo that you have made for me works fine in Flash 8 as well.

    Thanks very much, I appreciate it.

    Freshly

  17. #37
    I'm learning... Thankful's Avatar
    Join Date
    Jun 2005
    Location
    e.v.e.r.y.w.h.e.r.e
    Posts
    487
    I don't know what I'm doing wrong here, but regarding this reply:

    http://www.flashkit.com/board/showpo...2&postcount=23

    by ehabaref (in this same thread, same page)...

    I'm having exactly the same problem when I'm trying to place two different "buttons" with different onPress actions on them... it looks like one works well, while other acts strange... it activates another "button" on the scene etc.

    Is there any source code where we can see both buttons in action not interfering one with another by any chance ?

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

    :: SASHA-Z-CREATIONS :: web site

  18. #38
    Freelance Web Designer ehabaref's Avatar
    Join Date
    Nov 2005
    Location
    New York City
    Posts
    212
    try that code
    it works perfectly with me

    b1.onRollOver = over;
    b1.onRollOut = out;
    b1.onrelease = over1;
    b2.onRollOver = over;
    b2.onRollOut = out;
    b2.onrelease = over2;
    b3.onRollOver = over;
    b3.onRollOut = out;
    b3.onrelease = over3;
    b4.onRollOver = over;
    b4.onRollOut = out;
    b4.onrelease = over4;
    b5.onRollOver = over;
    b5.onRollOut = out;
    b5.onrelease = over5;
    function over() {
    this.gotoAndPlay(6);
    }
    function out() {
    this.gotoAndPlay(21);
    }
    function over1() {
    getURL("javascript:NewWindow=window.open('link','m yWindow','width=772,height=443,left=100,top=100,to olbar=No,location=No,scrollbars=No,status=No,resiz able=No,fullscreen=No'); NewWindow.focus(); void(0);");
    }
    function over2() {
    getURL("link", "_blank");
    }
    function over3() {
    getURL("link", "_blank");
    }
    function over4() {
    getURL("link", "_blank");
    }
    function over5() {
    getURL("link", "_blank");
    }

  19. #39
    Freelance Web Designer ehabaref's Avatar
    Join Date
    Nov 2005
    Location
    New York City
    Posts
    212
    you also need to use AS1 in order for the code to work

  20. #40
    I'm learning... Thankful's Avatar
    Join Date
    Jun 2005
    Location
    e.v.e.r.y.w.h.e.r.e
    Posts
    487
    Thanks a lot... the only problem is I have to use AS2 because rest of the Flash where I want to use this requires AS2 to run properly.

    Anyway, do you use this code you just provided with those examples from the beginning of this thread, or you have something else running in the background ?

    Thanks again !
    :: 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