Solved

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

Posted on 2009-05-14
1
402 Views
Last Modified: 2012-08-14
The new component will be placed inside of an itemrenderer
0
Comment
Question by:mhendrix
1 Comment
 
LVL 10

Accepted Solution

by:
mplord earned 500 total points
ID: 24390922
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now