Hello,

I have an image inside of a canvas. I need to move the image in any direction using the mouse and have the image stay inside the canvas. I also do not want scroll bars to appear on the canvas. It's working for me except when x<=0 && y <=0.
Here is some code that shows the problem. I set the width and height of the canvas to be the same as the image.


<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>

<mx:Script>
function posImg(x, y) {
img.x = x;
img.y = y;
}
</mx:Script>

<mx:Panel title="Clip Test">
<mx:Canvas width="495" height="355" hScrollPolicy="off" vScrollPolicy="off">
<mx:Image id="img" source="testmap.jpg" scaleContent="false"/>
</mx:Canvas>
</mx:Panel>

<mx:Label text="Bad Clips"/>
<mx:HBox>
<mx:Button label="-50,-50" click="posImg(-50,-50)"/>
<mx:Button label="0,-50" click="posImg(0,-50)"/>
<mx:Button label="-50,0" click="posImg(-50,0)"/>
</mx:HBox>

<mx:Label text="Good Clips"/>
<mx:HBox>
<mx:Button label="0,0" click="posImg(0,0)"/>
<mx:Button label="1,-50" click="posImg(1,-50)"/>
<mx:Button label="-50,1" click="posImg(-50,1)"/>
<mx:Button label="0,50" click="posImg(0,50)"/>
<mx:Button label="50,0" click="posImg(50,0)"/>
<mx:Button label="50,50" click="posImg(50,50)"/>
</mx:HBox>

</mx:Application>

Any ideas?

--Dasa




Reply via email to