    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns="*" xmlns:mx="http://www.adobe.com/2006/mxml"
             xmlns:os="http://openscales.org" creationComplete="initMap();">

        <os:Map id="fxmap" width="100%" height="100%" zoom="11" centerLonLat="4.833,45.767">

            <os:TraceInfo x="{width-200}" y="0" visible="{displayTrace}" />

            <!-- OpenStreetMap EPSG:900913 -->
            <os:Mapnik name="Mapnik" isBaseLayer="true"
                       proxy="http://openscales.org/proxy.php?url=" />

            <os:DragHandler id="dragHandler" />
            <os:WheelHandler />
            <os:Spinner id="spinner" x = "{width / 2}" y = "{height / 2}"/>
            <os:MousePosition x="10" y="{height-20}" displayProjection="EPSG:4326"/>

            <!-- Specific layers and handlers of this example -->

            <os:SelectFeaturesHandler id="selectFeaturesHandler" creationComplete="{selectFeaturesHandler.handler.active=false;}"/>

        </os:Map>

        <!-- Specific tools of this example -->

        <mx:VBox horizontalAlign="center" x="10" y="10">
            <mx:ToggleButtonBar id="buttons" selectedIndex="0">
                <mx:dataProvider>
                    <mx:Array>
                        <mx:String>Pan</mx:String>
                        <mx:String>Select</mx:String>
                        <mx:String>Clear</mx:String>
                    </mx:Array>
                </mx:dataProvider>
                <mx:itemClick>
                    <![CDATA[
                        switch (buttons.selectedIndex) {
                            case 0 :
                                Trace.info("pan mode");
                                selectFeaturesHandler.handler.active = false;
                                dragHandler.handler.active = true;
                                break;
                            case 1 :
                                Trace.info("select mode");
                                dragHandler.handler.active = false;
                                selectFeaturesHandler.handler.active = true;
                                break;
                            case 2 :
                                Trace.info("clear selection");
                                (selectFeaturesHandler.handler as SelectFeaturesHandler).clearSelection();
                                // Once the selection is cleared, return in previous mode
                                if (dragHandler.handler.active) {
                                    Trace.info("back to pan mode");
                                    buttons.selectedIndex = 0;
                                } else if (selectFeaturesHandler.handler.active) {
                                    Trace.info("back to select mode");
                                    buttons.selectedIndex = 1;
                                }
                                break;
                            default:
                                Trace.info("unknown mode");
                        }
                    ]]>
                </mx:itemClick>
            </mx:ToggleButtonBar>

        </mx:VBox>

        <mx:Script>
            <![CDATA[
                import org.openscales.core.handler.feature.SelectFeaturesHandler;
                import org.openscales.core.handler.Handler;
                import org.openscales.core.Map;
                import org.openscales.core.Trace;

                // Specific imports for this example
                import org.openscales.core.feature.LineStringFeature;
                import org.openscales.core.feature.MultiLineStringFeature;
                import org.openscales.core.feature.MultiPointFeature;
                import org.openscales.core.feature.MultiPolygonFeature;
                import org.openscales.core.feature.PointFeature;
                import org.openscales.core.feature.PolygonFeature;
                import org.openscales.core.geometry.Collection;
                import org.openscales.core.geometry.Geometry;
                import org.openscales.core.geometry.LineString;
                import org.openscales.core.geometry.LinearRing;
                import org.openscales.core.geometry.MultiLineString;
                import org.openscales.core.geometry.MultiPoint;
                import org.openscales.core.geometry.MultiPolygon;
                import org.openscales.core.geometry.Point;
                import org.openscales.core.geometry.Polygon;
                import org.openscales.core.layer.FeatureLayer;
                import org.openscales.core.style.Rule;
                import org.openscales.core.style.Style;
                import org.openscales.core.style.fill.SolidFill;
                import org.openscales.core.style.symbolizer.PolygonSymbolizer;
                import org.openscales.core.style.stroke.Stroke;

                [Bindable] private var map:Map = null;
                [Bindable] public var displayTrace:Boolean = false;
                [Bindable] public var displayFirebugTrace:Boolean = false;

                private function initMap():void {
                    Trace.useFireBugConsole = displayFirebugTrace;
                    map=fxmap.map;

                    // Specific initialize for this example
                    var layer:FeatureLayer = SampleLayers.features();
                    // Usefull to test selection when a layer is not displayed
                    layer.minZoomLevel = 10;

                    (selectFeaturesHandler.handler as SelectFeaturesHandler).unselectableFeatures = [ layer.getChildAt(4) as PolygonFeature ];
                    map.addLayer(layer);
                    testContainsPoint(layer);
                    testIntersects(layer);
                }

                /**
                 * Test all the containsPoint functions for the relevant géometries.
                 */
                public function testContainsPoint(layer:FeatureLayer):void {
                    // Useful variables for the tests
                    var geom1:Geometry, geom2:Geometry;
                    var testResult:Boolean, testExpectedResult:Boolean;
                    var textResult:String;

                    // LinearRing contains a Point : true
                    testExpectedResult = true;
                    geom1 = ((layer.getChildAt(9) as PolygonFeature).geometry as Collection).componentByIndex(0);
                    geom2 = (layer.getChildAt(5) as PointFeature).geometry;
                    testResult = (geom1 as LinearRing).containsPoint(geom2 as org.openscales.core.geometry.Point);
                    textResult = "Does the outer LinearRing of the blue Polygon contain the red point (true) ? => "+testResult;
                    if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult);

                    // LinearRing contains a Point : false for a point outside of the AABB of the LinearRing
                    testExpectedResult = false;
                    geom1 = ((layer.getChildAt(9) as PolygonFeature).geometry as Collection).componentByIndex(0);
                    geom2 = (layer.getChildAt(0) as PointFeature).geometry;
                    testResult = (geom1 as LinearRing).containsPoint(geom2 as org.openscales.core.geometry.Point);
                    textResult = "Does the outer LinearRing of the blue Polygon contain the black point below the violet multipolygon (false) ? => "+testResult;
                    if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult);

                    // LinearRing contains a Point : false even if the point is inside the AABB of the LinearRing
                    testExpectedResult = false;
                    geom1 = ((layer.getChildAt(9) as PolygonFeature).geometry as Collection).componentByIndex(0);
                    geom2 = (layer.getChildAt(2) as PointFeature).geometry;
                    testResult = (geom1 as LinearRing).containsPoint(geom2 as org.openscales.core.geometry.Point);
                    textResult = "Does the outer LinearRing of the blue Polygon contain the nearest black point (false) ? => "+testResult;
                    if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult);

                    // Polygon contains a Point without management of the holes : true
                    testExpectedResult = true;
                    geom1 = (layer.getChildAt(9) as PolygonFeature).geometry;
                    geom2 = (layer.getChildAt(5) as PointFeature).geometry;
                    testResult = (geom1 as Polygon).isPointInPolygon(geom2 as org.openscales.core.geometry.Point, false);
                    textResult = "Does the blue Polygon contain the red point without managing its holes (true) ? => "+testResult;
                    if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult);

                    // Polygon contains a Point with management of the holes : false
                    testExpectedResult = false;
                    geom1 = (layer.getChildAt(9) as PolygonFeature).geometry;
                    geom2 = (layer.getChildAt(5) as PointFeature).geometry;
                    testResult = (geom1 as Polygon).containsPoint(geom2 as org.openscales.core.geometry.Point);
                    textResult = "Does the blue Polygon contain the red point without managing its holes (false) ? => "+testResult;
                    if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult);

                    // MultiPolygon contains a Point : true
                    testExpectedResult = true;
                    geom1 = ((layer.getChildAt(10) as MultiPolygonFeature).geometry as Collection).componentByIndex(0) as Collection;
                    geom2 = (layer.getChildAt(0) as PointFeature).geometry;
                    testResult = (geom1 as Polygon).containsPoint(geom2 as org.openscales.core.geometry.Point);
                    textResult = "Does the violet MultiPolygon contain the upper black point (true) ? => "+testResult;
                    if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult);

                    // MultiPolygon contains a Point : false
                    testExpectedResult = false;
                    geom1 = ((layer.getChildAt(10) as MultiPolygonFeature).geometry as Collection).componentByIndex(0) as Collection;
                    geom2 = (layer.getChildAt(1) as PointFeature).geometry;
                    testResult = (geom1 as Polygon).containsPoint(geom2 as org.openscales.core.geometry.Point);
                    textResult = "Does the violet MultiPolygon contain the lower black point (false) ? => "+testResult;
                    if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult);
                }

                /**
                 * Test all the intersects functions for the relevant geometries.
                 */
                public function testIntersects(layer:FeatureLayer):void {
                    // Useful variables for the tests
                    var geom1:Geometry, geom2:Geometry;
                    var testResult:Boolean, testExpectedResult:Boolean;
                    var textResult:String;

                    // Polygon intersect a Polygon : true
                    testExpectedResult = true;
                    geom1 = (layer.getChildAt(9) as PolygonFeature).geometry;
                    geom2 = (layer.getChildAt(4) as PolygonFeature).geometry;
                    testResult = (geom1 as Polygon).intersects(geom2 as org.openscales.core.geometry.Polygon);
                    textResult = "Does the blue Polygon intersect the big black rectangle (true) ? => "+testResult;
                    if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult);

                    // Polygon intersect a Polygon : true
                    testExpectedResult = true;
                    geom1 = (layer.getChildAt(9) as PolygonFeature).geometry;
                    geom2 = (layer.getChildAt(11) as PolygonFeature).geometry;
                    testResult = (geom1 as Polygon).intersects(geom2 as org.openscales.core.geometry.Polygon);
                    textResult = "Does the blue Polygon intersect the inside small black rectangle (true) ? => "+testResult;
                    if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult);

                    // Polygon intersect a Polygon : false
                    testExpectedResult = false;
                    geom1 = (layer.getChildAt(9) as PolygonFeature).geometry;
                    geom2 = (layer.getChildAt(12) as PolygonFeature).geometry;
                    testResult = (geom1 as Polygon).intersects(geom2 as org.openscales.core.geometry.Polygon);
                    textResult = "Does the blue Polygon intersect the black lozenge (false) ? => "+testResult;
                    if (testResult==testExpectedResult) Trace.info(textResult) else Trace.error(textResult);
                }
            ]]>
        </mx:Script>

    </mx:Canvas>