*

Account

Welcome, Guest. Please login or register.
Did you miss your activation email?
November 24, 2024, 10:40:37 pm

Login with username, password and session length

Resources

Recent posts

[November 01, 2024, 12:46:37 pm]

[October 05, 2024, 07:29:20 am]

[September 05, 2024, 01:54:13 pm]

[July 16, 2024, 11:30:34 pm]

[June 22, 2024, 06:49:40 am]

[March 08, 2024, 12:13:38 am]

[March 08, 2024, 12:12:54 am]

[March 08, 2024, 12:09:37 am]

[December 30, 2023, 08:00:58 pm]

[February 04, 2023, 11:46:41 am]
Pages: [1]   Go Down
  Print  
Author Topic: Coding help - Flash Builder 4  (Read 2019 times)
0 Members and 2 Guests are viewing this topic.
MonthlyMayhem Offline
EIR Veteran
Posts: 164


« on: June 17, 2010, 08:33:09 am »

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:
Code:
<?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.
Logged


aka Maysauze/MrGamenWatch
MonthlyMayhem Offline
EIR Veteran
Posts: 164


« Reply #1 on: June 17, 2010, 10:45:01 pm »

*Bump*
Logged
Grundwaffe Offline
EIR Veteran
Posts: 1128



« Reply #2 on: June 18, 2010, 12:47:45 am »

I think you are asking at the wrong place, try some other forum related to this type of software.
As a suggestion..
Logged

SublimeHauken - Back from the dead - Since 2007'
Pages: [1]   Go Up
  Print  
 
Jump to:  

TinyPortal v1.0 beta 4 © Bloc
Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!
Page created in 0.044 seconds with 35 queries.