Hey guys I was wondering if anyone could help me, I'm trying to get a simple paint program running and this is what I have:
<?xml version="1.0" encoding="utf-8"?>
<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/halo" backgroundColor="#555555">
<fx:Declarations>
<s:RadioButtonGroup id="drawMode"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.events.ColorPickerEvent;
import mx.graphics.codec.PNGEncoder;
public var currentlyDrawing:Boolean = false;
public var drawingColour:uint;
public var brushSize:int = 2;
public var brushOpacity:Number = 1;
public var xcoord1:int;
public var xcoord2:int;
public var ycoord1:int;
public var ycoord2:int;
protected function canvas1_mouseDownHandler(event:MouseEvent):void
{
currentlyDrawing = true
xcoord1 = paintCanvas.mouseX;
ycoord1 = paintCanvas.mouseY;
}
protected function paintCanvas_mouseMoveHandler(event:MouseEvent):void
{
xcoord2 = paintCanvas.mouseX;
ycoord2 = paintCanvas.mouseY;
if(currentlyDrawing)
{
if(normaldrawMode.selected)
{
paintCanvas.graphics.lineStyle(brushSize, drawingColour, brushOpacity);
paintCanvas.graphics.moveTo(xcoord1, ycoord1);
paintCanvas.graphics.lineTo(xcoord2, ycoord2);
xcoord1 = xcoord2;
ycoord1 = ycoord2;
}
}
}
protected function paintCanvas_mouseUpHandler(event:MouseEvent):void
{
currentlyDrawing = false;
}
protected function colorpicker1_changeHandler(event:ColorPickerEvent):void
{
drawingColour = colourPicker.selectedColor;
}
protected function opacityDragger_changeHandler(event:Event):void
{
brushOpacity = (opacityDragger.value /10);
}
protected function sizeDragger_changeHandler(event:Event):void
{
brushSize = sizeDragger.value;
}
protected function paintCanvas_clickHandler(event:MouseEvent):void
{
paintCanvas.graphics.lineStyle(brushSize, drawingColour, brushOpacity);
if(circledrawMode.selected)
{
paintCanvas.graphics.drawCircle(xcoord1, ycoord1, (brushSize*5));
}
if(squaredrawMode.selected)
{
paintCanvas.graphics.drawRect(xcoord1, ycoord1,(brushSize*5),(brushSize*5));
}
if(rectdrawMode.selected)
{
paintCanvas.graphics.drawRect(xcoord1, ycoord1,(brushSize*4 + 20),(brushSize*4));
}
}
protected function saveImage():void
{
var bitdata:BitmapData = new BitmapData(paintCanvas.width,paintCanvas.height);
bitdata.draw(paintCanvas);
var ba:ByteArray = (new PNGEncoder()).encode(bitdata);
new FileReference().save(ba, "myImage.png");
}
]]>
</fx:Script>
<s:VGroup width="100%" height="100%" horizontalAlign="center" paddingBottom="20" paddingLeft="20" paddingRight="20" paddingTop="20">
<s:Panel width="500" height="500" title="Flash Painter">
<s:HGroup width="100%" height="100%">
<s:VGroup width="100" height="100%" paddingLeft="10" paddingBottom="10" paddingTop="10" paddingRight="10" horizontalAlign="center">
<s:Label text="Brush colour: "/>
<mx:ColorPicker id="colourPicker" change="colorpicker1_changeHandler(event)"/>
<mx:Spacer height="10"/>
<s:Label text="Brush size: "/>
<s:HSlider id="sizeDragger" width="100%" minimum="1" maximum="10" value="2" liveDragging="true" change="sizeDragger_changeHandler(event)"/>
<mx:Spacer height="10"/>
<s:Label text="Brush Opacity: "/>
<s:HSlider id="opacityDragger" width="100%" minimum="1" maximum="10" value="10" liveDragging="true" change="opacityDragger_changeHandler(event)"/>
<mx:Spacer height="20"/>
<mx:HRule width="90%"/>
<mx:Spacer height="20"/>
<s:Label text="Draw Mode:"/>
<s:RadioButton width="100%" id="normaldrawMode" label="Normal" groupName="drawMode" selected="true"/>
<s:RadioButton width="100%" id="circledrawMode" label="Circle" groupName="drawMode"/>
<s:RadioButton width="100%" id="squaredrawMode" label="Square" groupName="drawMode"/>
<s:RadioButton width="100%" id="rectdrawMode" label="Rectangle" groupName="drawMode"/>
<mx:HRule width="90%"/>
<mx:Spacer height="10"/>
<s:Button label="Clear All" click="paintCanvas.graphics.clear();"/>
<s:Button label="Save Image" click="saveImage();"/>
</s:VGroup>
<s:VGroup width="100%" height="100%">
<s:Border id="paintCanvas" borderStyle="solid" width="100%" height="100%"
mouseDown="canvas1_mouseDownHandler(event)"
mouseMove="paintCanvas_mouseMoveHandler(event)"
mouseUp="paintCanvas_mouseUpHandler(event)" click="paintCanvas_clickHandler(event)"/>
</s:VGroup>
</s:HGroup>
</s:Panel>
</s:VGroup>
</s:Application>
I keep getting two error codes that are:
Could not resolve <mx:ColorPicker> to a component implementation and Could not resolve <s:Border> to a component implementation.
Thanks in advance.