Archive for category Web Development

Flash ScrollPane Mouse Wheel Event

Getting the ScrollPane in flash to work with a mouse wheel can be tricky. It will not allow the mouse wheel to scroll if there is not acutal content right underneath the mouse pointer. This can be cumbersome for dynamic content in the pane. To fix this, you can use the following AS3 code to scroll the ScrollPane without having to mess with background sizes in the pane.

   1:  // Listen for mouse wheel event on the stage to scroll content
   2:  stage.addEventListener( MouseEvent.MOUSE_WHEEL,
   3:      function( event:MouseEvent ):void
   4:      {
   5:          if( scrollPane !== null )
   6:          {
   7:              scrollPane.verticalScrollPosition += - ( event.delta * 8 );
   8:          }
   9:      });

You can adjust the “( event.delta * 8 )” to only “event.delta” if you don’t want to change the amount of scrolling that is performed.

, , ,

No Comments

Flash and the Scroll Wheel in the Browser

I have built many AS3 flash apps before, but on this one project I needed to enable scrolling with the mouse wheel. I added a flash scrollpane but it would not respond to the mouse wheel. So I tried adding an event listener to the entire stage to see if I could capture any mouse wheel event. No luck with that either. Countless searches turned up maybe two possible resolutions to the problem, but they did not work either.

The resolution was out there to find, but I did not find it because I didn’t use the right keywords.

The resolution revealed to me was the parameter called “wmode”. The wmode param has three values; opaque, transparent, window(default). While normally most people do not set this parameter, I have a habit of setting it due to it’s necessity when building flash widgets for various web pages. In this case, if you set wmode to either transparent or opaque, the flash will not detect the mouse scroll wheel at all. So be sure not to set this parameter. If you do set it to “window” otherwise your flash app will not detect the mouse wheel events.

, , , ,

No Comments

Javascript Determine Daylight Savings Time

   1:  var is_dst = function(){
   2:      var now = new Date();
   3:      var dst_start = new Date();
   4:      var dst_end = new Date();
   5:      // Set dst start to 2AM 2nd Sunday of March
   6:      dst_start.setMonth( 2 ); // March
   7:      dst_start.setDate( 1 ); // 1st
   8:      dst_start.setHours( 2 );
   9:      dst_start.setMinutes( 0 );
  10:      dst_start.setSeconds( 0 ); // 2AM
  11:      // Need to be on first Sunday
  12:      if( dst_start.getDay() )
  13:          dst_start.setDate( dst_start.getDate() + ( 7 - dst_start.getDay() ) );
  14:   
  15:      // Set to second Sunday
  16:      dst_start.setDate( dst_start.getDate() + 7 );    
  17:      // Set dst end to 2AM 1st Sunday of November
  18:      dst_end.setMonth( 10 );
  19:      dst_end.setDate( 1 );
  20:      dst_end.setHours( 2 );
  21:      dst_end.setMinutes( 0 );
  22:      dst_end.setSeconds( 0 ); // 2AM
  23:      // Need to be on first Sunday
  24:      if( dst_end.getDay() )
  25:          dst_end.setDate( dst_end.getDate() + ( 7 - dst_end.getDay() ) );
  26:   
  27:      return ( now > dst_start && now < dst_end )
  28:  };// /is_dst()

No Comments