A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Canceling an action for a button on rollout

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    11

    Canceling an action for a button on rollout

    Ok, im self taught flash so forgive me if im not quite using the lingo, im sure ill be taught how to be hip and down with it soon enough. Anyway, my issue is that i have a basic button, with the following script

    PHP Code:
    btn1.onRollOver = function () {
        
    this.gotoAndPlay(2);
    }
    btn1.onRollOut = function () {
        
    this.gotoAndPlay (12)
    }
    btn1.onReleaseOutside = function () {
        
    this.gotoAndPlay (6)
    }
    btn1.onPress = function () {
        
    _root.gotoAndStop (1)

    which all works fine, its just when you skip over the button, it doesn't compleate the OnRollOut function. Now I think this is because it is still trying to compleate the OnRollOver function. Is there any way to get round this or would i be better using a frame reversal technique instead?

    if you want a sample i can provide

    oh yeah, im in flash 8 professional
    Last edited by Night Hawk; 10-24-2008 at 02:31 PM.

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Does not complete? or is it immediately jumping from where it is to the action for roll out?
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Junior Member
    Join Date
    Oct 2008
    Posts
    11
    well this is what it does.

    try moving slowly over it and then skim over it.
    Attached Files Attached Files
    Last edited by Night Hawk; 10-24-2008 at 04:41 PM.

  4. #4
    Senior Member
    Join Date
    Aug 2007
    Posts
    291
    1. How in the frick did you upload an FLA file? I didn't think those were allowed! I thought you had to upload a zip.

    2. I didn't see anything worth noting.

  5. #5
    Junior Member
    Join Date
    Oct 2008
    Posts
    11
    yeah wrong file, sorry. and i just clicked it. There is a preview here

    http://nighthawkgraphics.deviantart....btn1-101646593

    and the correct file is up now

    Edit:

    fixed it, i suppose you could say the power of posting, i simply replaced that chunk of ugly coding with:

    PHP Code:
    this.onEnterFrame = function() {
        if (
    rewind == true) {
            
    prevFrame();
        }
    };
    this.onRollOver = function() {
        
    rewind false;
        
    play();
    };
    this.onRollOut = function() {
        
    rewind true;
    }; 
    Last edited by Night Hawk; 10-24-2008 at 04:51 PM.

  6. #6
    Senior Member
    Join Date
    Aug 2007
    Posts
    291
    Oh, I see. It's not because you're moving fast, it's because you're going OUTSIDE the actual flash movie before it has a chance to finish it's onRollOver animation.... which I guess prevents it from recognizing the onRollOut event. Try this, put a trace statement in your onRollOut event... anything. like this:

    PHP Code:
    btn1.onRollOver = function () {
        
    this.gotoAndPlay(2);
    }
    btn1.onRollOut = function () {
        
    trace("out"); 
        
    this.gotoAndPlay (12)
    }
    btn1.onReleaseOutside = function () {
        
    this.gotoAndPlay (6)
    }
    btn1.onPress = function () {
        
    _root.gotoAndStop (1)

    Let us know if it traces.

  7. #7
    Junior Member
    Join Date
    Oct 2008
    Posts
    11
    it did trace, but the solution above, (which i added at the same time as your post) is a bit neater and is a nice bit of code

    thanks for the help though

  8. #8
    Senior Member
    Join Date
    Aug 2007
    Posts
    291
    Yep, that will work. You may want to be careful with that though. onEnterFrame events are very processor intensive. What if you tried this:

    PHP Code:
    this.onRollOver = function() {  
         
    animate(thistrue);
        
    };
    this.onRollOut = function() {
         
    animate(thisfalse);
    }; 

    function 
    animate(myButton:MovieClipover:Boolean)
    {
        if(
    over)
        {
             
    myButton.gotoAndPlay(2)
        }
        else
        {
             
    myButton.gotoAndPlay(12)
        }

    I don't know why this would give you different results, but it might.

  9. #9
    Junior Member
    Join Date
    Oct 2008
    Posts
    11
    ahh, ok, i might use that instead. I was thinking of a way to do it more logically, but i just dont have the knowladge yet. Thanks for the help

    Incedentally, any reason i cant get dynamic content to load if its in a symbol? do i have to load it in a different way?

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