[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • Last Modified:

How can I extend the Canvas component to change the border type and background colors when clicked

The new component will be placed inside of an itemrenderer
0
mhendrix
Asked:
mhendrix
1 Solution
 
mplordCommented:
Hi - hope this helps.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:my="*">
	<my:CustomCanvas horizontalCenter="0" verticalCenter="0" width="156" height="122">
	</my:CustomCanvas>
</mx:Application>
 
 
####### CustomCanvas.as
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" click="onClick(event);" borderStyle="solid" borderThickness="3" borderColor="#000000" backgroundColor="#FFFFFF">
	
	<mx:Script>
		<![CDATA[
			private static var flag:Boolean = false;
 
			private function onClick(event:Event):void
			{
				if (flag)
				{
					this.setStyle("borderColor", "#000000");
					this.setStyle("backgroundColor", "#FFFFFF"); 
				}
				else
				{
					this.setStyle("borderColor", "#FFFFFF");
					this.setStyle("backgroundColor", "#000000"); 
				}
				
				flag = !flag;
			}
		]]>
	</mx:Script>
</mx:Canvas>

Open in new window

0

Featured Post

Sign your company up to try the MB 660 headset now

Take control and stay focused in noisy open office environments with the MB 660. By reducing background noise, you can revitalize your office and improve concentration.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now