views:

667

answers:

2

How do I position a child relative to its containing box?

The Code:

<mx:Script>
 <![CDATA[


        thisMap.scaleX = scaleFactor;
        thisMap.scaleY = scaleFactor;
        thisMap.x = thisMap.x - thisMap.mouseX * 1.3;
        thisMap.y = thisMap.y - thisMap.mouseY * 1.3;

]]>
</mx:Script>

<mx:Box id="mapHolder" x="0" y="30">
 <mx:SWFLoader id="thisMap" source="MyWorld1.swf" />
</mx:Box>

To access thisMap it is not necessary to go through mapHolder.

+1  A: 

A box is a container that manages positioning for you in a horizontal or vertical stack (see VBox or HBox). It looks like you are trying to position thisMap as if it was in a canvas. Try

<mx:Script>
        <![CDATA[


                                thisMap.scaleX = scaleFactor;
                                thisMap.scaleY = scaleFactor;
                                thisMap.x = thisMap.x - thisMap.mouseX * 1.3;
                                thisMap.y = thisMap.y - thisMap.mouseY * 1.3;

]]>
</mx:Script>

<mx:Canvas id="mapHolder" x="0" y="30">
        <mx:SWFLoader id="thisMap" source="MyWorld1.swf" />
</mx:Canvas>

Also i'm not sure how this will look by positioning it relative to the mouse coordinates... it looks like you are trying to achieve some sort of drag functionality. However the canvas should solve the original problem.

James Hay
A: 

I am creating a zoom functionality. When the user clicks thisMap, it zooms into the point that was clicked. I scale this map and adjust for the scaling and centering by offsetting its x, y position. This works fine in the main app, but I can't figure out how to put the swf in some kind of container.

Bryan