Select to view content in your preferred language

Aggregating layers

552
0
11-30-2012 11:35 AM
DmitriyKukharev
New Contributor
Hi,

In my application I need to wrap all layers before adding them to the map. For this purpose I implemented proxy class: MyLayer which has similar structure:
class MyLayer extends Layer implement MyInterface
{
public function MyLayer(originalLayer:Layer)
{
    this.originalLayer = originalLayer;
}
///
///overriden methods from Layer.
///

override public function createChildren():void
{
    addChild(originalLayer);
}

override public function get loaded():Boolean
{
    return originalLayer.loaded;
}

/// and others
}


After I started testing my solution I found that for instance TiledLayer does not work because it expects the parent property to be LayerContainer (otherwise scrcollRect is null and loadTiles() throws runtime error). So I overrode scrollRect property:
override public function get scrollRect():Rectangle
{
    return parent.scrollRect;
}


Now everything works well but anyway I am not sure that in future I will not get any problems.

The reason I did this is that I need all layers added to the map implement some interface (MyInterface) that is why I decided to wrap them into my own layer.

Could you recommend something for this case or just tell what other properties (like 'scrollRect') I am required to override.

Thanks.
Tags (2)
0 Kudos
0 Replies