I was able to get mouse trap working, not in the flexviewer but in an Iframe with a simple map. Displayed is the actionscript file, and just initialize this function on startup private function init():void
{
MouseWheelTrap.setup(stage);
}
package com.sample
{
import flash.display.Stage;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.external.ExternalInterface;
import mx.core.Application;
import mx.core.mx_internal;
/**
* MouseWheelTrap - Simultaneous browser/Flash mousewheel scroll issue work-around
* @version 0.1
* @author Liam O'Donnell
* @usage Simply call the static method MouseWheelTrap.setup(stage)
* @see http://www.spikything.com/blog/?s=mousewheeltrap for updates
* This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
* (c) 2009 spikything.com
*/
public class MouseWheelTrap {
static private var _mouseWheelTrapped :Boolean;
public static function setup(mainStage:Stage):void {
mx.core.FlexGlobals.topLevelApplication.addEventListener(MouseEvent.ROLL_OVER, function():void{
allowBrowserScroll(false);
}
);
//i added 'mx.core.FlexGlobals.topLevelApplication.'making it work better for flex. use 'stage' for flash
mx.core.FlexGlobals.topLevelApplication.addEventListener(MouseEvent.ROLL_OUT, function():void{
allowBrowserScroll(true);
}
);
}
private static function allowBrowserScroll(allow:Boolean):void
{
createMouseWheelTrap();
if (ExternalInterface.available){
ExternalInterface.call("allowBrowserScroll", allow);
}
}
private static function createMouseWheelTrap():void
{
if (_mouseWheelTrapped) {return;} _mouseWheelTrapped = true;
if (ExternalInterface.available){
ExternalInterface.call("eval", "var browserScrolling;function allowBrowserScroll(value){browserScrolling=value;}function handle(delta){if(!browserScrolling){return false;}return true;}function wheel(event){var delta=0;if(!event){event=window.event;}if(event.wheelDelta){delta=event.wheelDelta/120;}else if(event.detail){delta=-event.detail/3;}if(delta){handle(delta);}if(!browserScrolling){if(event.preventDefault){event.preventDefault();}event.returnValue=false;}}if(window.addEventListener){window.addEventListener('DOMMouseScroll',wheel,false);}window.onmousewheel=document.onmousewheel=wheel;allowBrowserScroll(true);");
}
}
}
}
I tried using the javascript, it worked when the map was embedded on the page but not when the map was in an iframe.