Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html?filter_coldfusion=9&amp;filter_flex=3&amp;filter_flashplayer=10&amp;filter_air=1.5#floodFill%28%29" rel="nofollow">http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html?filter_coldfusion=9&amp;filter_flex=3&amp;filter_flashplayer=10&amp;filter_air=1.5#floodFill%28%29</a></p> <p>mouseX and mouseY are always the mouse position add a click listener to whatever object and just use the mouseX/mouseY or else the MouseEvent's event.localX and event.localY for the object that the listener is attached to</p> <pre><code>&lt;mx:Image id="myImage" click="(myImage.content as Bitmap).bitmapData.floodFill(event.localX,event.localY,0xFFFFFF)" source="http://www.carolynsbloomingcreations.com/images/square.gif"/&gt; </code></pre> <p>Here's a solution if you use the Flex 4.5 Hero framework otherwise I was unable to get a handle on the bitmapData through the BitmapImage, the above solution also still works with Flex 3 or 4:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*"&gt; &lt;s:layout&gt; &lt;s:VerticalLayout/&gt; &lt;/s:layout&gt; &lt;fx:Declarations&gt; &lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt; &lt;/fx:Declarations&gt; &lt;!-- &lt;mx:Image id="myImage" click="(myImage.content as Bitmap).bitmapData.floodFill(event.localX,event.localY,0xFFFFFF)" source="http://www.carolynsbloomingcreations.com/images/square.gif"/&gt; --&gt; &lt;fx:Script&gt; &lt;![CDATA[ private function handleClick(event:MouseEvent):void { trace('test'); var tempData:BitmapData = new BitmapData(myBitmapImage.width,myBitmapImage.height); tempData = myBitmapImage.bitmapData; var localPoint:Point = container.globalToLocal(new Point(mouseX,mouseY)); tempData.floodFill(localPoint.x,localPoint.y,0xFFFFFFFF); myBitmapImage.source = tempData; trace(localPoint.x + ":" + localPoint.y); } ]]&gt; &lt;/fx:Script&gt; &lt;s:Group id="container" click="handleClick(event)"&gt; &lt;s:BitmapImage id="myBitmapImage" source="@Embed('square.gif')" /&gt; &lt;/s:Group&gt; &lt;/s:Application&gt; </code></pre> <p>even though they exposed the bitmapData in the 4.5 framework it's read only though so I had to copy it and re-assign it to the source that seemed to work</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload