Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cropping/Clipping A Sprite

How is cropping/clipping accomplished on a Sprite in Flex?

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="Init()">
  <mx:Script>
    <![CDATA[
      public function Init():void {
        var spr:Sprite=new Sprite();
        uic.addChild(spr);
        uic.graphics.lineStyle(2,0);
        uic.graphics.moveTo(22, 22);
        uic.graphics.lineTo(2222, 2222);
      }
    ]]>
 </mx:Script>
 <mx:Panel title="StackOverflow">
    <mx:UIComponent width="200" height="200" id="uic"/>
  </mx:Panel>
</mx:WindowedApplication>

Notice that the lineTo completely leaves the UIComponent and Panel.

How can I cause my UIComponent or Sprite, Or Panel for that matter, to be cropped/clipped? alt text
(source: liquidfeline.com)

I realize I could just change the hard-coded 2222's to something more reasonable, but I need a generalized solution to this, since the actual project doesn't involve hard-coded values that I can alter, but works with dynamic data.

like image 982
Joshua Avatar asked May 04 '26 01:05

Joshua


1 Answers

You should also try using scrollRect, this will be faster in performance than a mask. Introduction to the scrollRect from Grant Skinner.

like image 182
simonrichardson Avatar answered May 06 '26 02:05

simonrichardson