Chakra Media blog

SWFMacMouseWheel - real world example

A couple of weeks ago pixelbreaker released a kick-ass add-on to SWFObject called SWFMacMouseWheel which enables the mousewheel support in Flash for OSX. I was a little bummed on their example code though... so I've created a little example of some scrolling textArea components. It uses a simple hitTest to see if mouse is over the textArea and then increments the vPosition accordingly.

example

swfmousewheeljds

17 Comments so far

  1. Sander December 4th, 2006 7:56 am

    Thank you very much! This is definately easy to implement, you saved my day!

  2. Nylz January 18th, 2007 6:07 am

    I also like to thank you for making it a whole lot easier to implement. I now got it working. Whoohoo :)

  3. justin January 18th, 2007 8:49 am

    you’re welcome! i’m glad it helps… :)

  4. dave March 11th, 2007 11:46 am

    Thanks for making this example. I have a couple questions that maybe you can answer?

    If I move the text area around the mouse wheel scroll stops working or works in a strange location (not over the TextArea). Should it matter where the TextArea is located?

    Can this be done to a dynamic text/scroll box that isn’t a TextArea component?

    It’s still a great example! Thanks

  5. justin March 11th, 2007 6:38 pm

    hey dave

    i took a look at the example and changed the pos of the TextAreas to see if i could re-create what you describe…but everything seemed to work fine for me. i’m not sure what could be causing that. feel free to post an example if you have it and we’ll check it out further.

    Yea, the scrolling of a TextField is possible but it wouldn’t work with the code in this example. The code is using properties specfic to the TextArea component, such as vPosition. So instead of “desc_txt.vPosition++” you’d probably have to use “desc_txt.scroll++”.

    cheers

  6. dave March 12th, 2007 8:23 am

    Hi Justin,

    Thanks for taking the time to help me out.
    Here’s my version of the example with the TextArea moved horizontally.

    http://www.workalicious.com/mousewheelmove/index.html

    It looks like (using the background tones as a guide) the distance moved plus the width of the scrollbar is the non-scrolling area in the new location of the TextArea or I’m totally crazy. Some kind of weird cache going on maybe?

    http://www.workalicious.com/mousewheelmove/_source.zip

  7. dave March 12th, 2007 10:40 am

    So I couldn’t stop messing with your example and I still don’t know what would be causing the odd shifting. But I did figure out that it has something to do with the instance of that TextArea myclip. When i “break apart” myclip and put the code on the first frame of the timeline with the individual TextArea instances I can move them around willy-nilly and all is good.

    I made a new single version with that approach too:
    http://www.workalicious.com/mousewheelmove/singleTextArea.html
    http://www.workalicious.com/mousewheelmove/_singleVersion.zip

  8. justin March 14th, 2007 4:07 pm

    … hey i’m still checking this out, just dealing with some client stuff at the moment. will try to post what i find soon.

  9. justin March 16th, 2007 2:56 pm

    ok, apparently in the hitTest code you need to reference ‘this._parent._xmouse’ (etc) instead of just ‘_xmouse’ … that seems to fix the problem. I updated the code and reposted the download. thanks for bringing this to my attention!

  10. dave March 18th, 2007 9:06 am

    oh that’s excellent. i was making a holder and doing the hitTest on there. Shifting and re-pathing… ‘this._parent._xmouse’ will keep everything much neater.

    i’ve got a nice working version with the zMin scroller and a textbox. i hope i’m not mucking up the blog with a bunch of links, but here’s one more:
    http://www.workalicious.com/dynamicHTML/

    thanks justin!

  11. Keven June 8th, 2007 9:58 am

    Hey dave,
    Do you have the FLA for that last link? Or if anyone else has utilized this code with something other than a text area component.
    Thanks.

  12. justin June 8th, 2007 1:34 pm

    Hey Keven

    i just added a datagrid to the example code to show usage of something other than the textArea… but it essentially works the same. let me know if this helps…

    cheers
    justin

  13. oshi July 5th, 2007 1:54 pm

    Hi,
    i found some “strange behaviours” in the SWFMacMouseWheel/TextArea:

    1. if you scroll over the limit up or down, you need to scroll it back before the content scrolls again. I see that dave fixed the problem, how?
    dave’s link: http://www.workalicious.com/dynamicHTML/

    2. safari scrolls 3 lines and the other browsers 1, is there a way to fix it?

    3. there’s no preloader that works with the textarea, why? it shows the loader only at the end.

    4. when you load 2 or more textareas, obviously with swfmacmousewheel, and continue loading other stuff(example: next section loaded via loadMovieNum or loadMovie), the browsers (all) crash when you scroll somewhere on the site. (I unloaded all the stuff before loading the next content.)

    thanx,
    oshi

  14. justin July 6th, 2007 8:01 am

    hey oshi

    1. i’m not sure exactly how dave did it, but if i had to guess he may be resetting the mousewheel delta so the extra scrolling is not needed somehow … dave, how’d you do it? :)

    2. (another guess)….the difference in scroll length between browsers may be from the way each browser registers mousewheel events.

    3. how exactly do you want to use a preloader with the textArea? do you want the preloader to show while the text is loading into the component? or the loading of the swf with the textArea in it?

    4. i’d like to see an example of this… i’ve had no problem using multiple instances of textAreas with the mouse enabled.

  15. oshi July 7th, 2007 5:15 pm

    hi justin,

    thanx for replying so quickly..

    1. for the “unlimited scroller” let’s hope dave has a problem with swfmacmousewheel and pass by -)..

    2. I known it’s a browser problem, but there must be a way to tell safari the right way..in the next link it’s exceptionally the opposite:
    http://kockumcommunication.se/#/services/

    3. my wish is to load a swf with a textarea in it..the only way I got it work is with an “old” textarea from flash mx..but I need a flash 8 textarea..
    I tried also to set a preloader in the componet (via xml) but it shows exactly the same way, the preloader only at the end..

    4. I have quite a mess in the files and if it works by you, the problem is surely in my mess..if I find the time to tidy up I will send you the code and link the content..

    thanx

  16. justin July 9th, 2007 8:03 am

    hey oshi

    if you get your ‘mess’ cleaned up, let me know… maybe we can get it working. :) send me a link…

  17. wholetv September 9th, 2008 12:40 pm

    thanks yourss free online live word tv to follow..

Leave a reply

Mexico