Adobe Dreamweaver Forums



Last 10 THreads :         How to align XML loading text to right (Last Post : loki2357 - Replies : 7 - Views : 8 )           »          Why is this not working!!! (Last Post : mickknight - Replies : 9 - Views : 10 )           »          Clock .getUTC not working (Last Post : kglad - Replies : 1 - Views : 2 )           »          Sound.position (Last Post : kglad - Replies : 3 - Views : 4 )           »          Flex compiler in FlexBuilder and Flex SDK (Last Post : 2009 Matt - Replies : 2 - Views : 3 )           »          Flash Controls Not Displaying in Embedded File (Last Post : kglad - Replies : 3 - Views : 4 )           »          damn bugs again in CS4 (Last Post : xianFF0000 - Replies : 15 - Views : 65 )           »          ProgressEvent reporting incorrect properties? (Last Post : ErikMadsen - Replies : 0 - Views : 1 )           »          ProgressBar and myPlayer (Last Post : W_Bell - Replies : 2 - Views : 3 )           »          Controlling a virtual keyboard from Director MX 2004 (Last Post : RandallH - Replies : 0 - Views : 1 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 10-01-2008, 02:58 PM
SiHoop
 
Posts: n/a
Diggs:
Default ItemRenderer and components

I have 2 questions about the code below that I'm using as an itemRenderer for a
DataGridColumn in a datagrid. First, is it possible to write an event handler
in my main mxml file that will allow me to respond to a mouse click when the
user clicks on the graphic in the DataGridColumn? When I click on the graphic
in the DataGridColumn, I'd like to modify the graphic (as if it were responding
to a button click).

Second, I'm trying to extend the class to something more sophisticated than a
Canvas (I left the code for a Sprite in the file to illustrate what I'm trying
to achieve), but I get error messages when I try a Sprite or UIContainer for my
class extension and then use that as my itemRenderer. How can I use a class
extension that is more sophisticated than a Canvas that will allow me to make
something interactive that can be used as an itemRenderer.?

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="50" >
<mx:Script>
<![CDATA[
import flash.display.Sprite;
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0xff0000);
circle.graphics.drawCircle(10, 10, 6);
circle.graphics.endFill();
//addChild(circle);

graphics.beginFill(0xff0000);
graphics.drawCircle(10, 10, 6);
graphics.endFill();

}
]]>
</mx:Script>
</mx:Canvas>



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-01-2008, 02:59 PM
ntsiii
 
Posts: n/a
Diggs:
Default Re: ItemRenderer and components

You can dispatch a "bubbling" event. Any object in the ancestor chain can
listen for it, including Application.

"more sophisticated than a Canvas " Canvas is a layout container. It does
things like calculate scrollbars and sizing children. Is that the
functionality you need?

If not, extend UIComponent. It can parent your sprite, or whatever.

Tracy

Reply With Quote
  #3 (permalink)  
Old 10-01-2008, 02:59 PM
ntsiii
 
Posts: n/a
Diggs:
Default Re: ItemRenderer and components

You can dispatch a "bubbling" event. Any object in the ancestor chain can
listen for it, including Application.

"more sophisticated than a Canvas " Canvas is a layout container. It does
things like calculate scrollbars and sizing children. Is that the
functionality you need?

If not, extend UIComponent. It can parent your sprite, or whatever.

Tracy

Reply With Quote


  #4 (permalink)  
Old 10-01-2008, 02:59 PM
SiHoop
 
Posts: n/a
Diggs:
Default Re: ItemRenderer and components

If I use a UIComponent I get the following error with the code below (which is
just a change from a Canvas to a UIComponent):
TypeError: Error #1034: Type Coercion failed: cannot convert
components::AddButton@565a331 to mx.controls.listClasses.IListItemRenderer.
at
mx.controls.dataGridClasses:ataGridBase/createCo lumnItemRenderer()[E:\dev\3.0.
x\frameworks\projects\framework\src\mx\controls\da taGridClasses\DataGridBase.as:
1415]

<?xml version="1.0" encoding="utf-8"?>
<mx:UIComponent xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var myColor:uint=uint(0x555500);
graphics.beginFill(myColor);
graphics.drawRoundRect(0, 5, 30, 12, 3);

graphics.endFill();
}
]]>
</mx:Script>
</mx:UIComponent>

Reply With Quote
  #5 (permalink)  
Old 10-01-2008, 02:59 PM
ntsiii
 
Posts: n/a
Diggs:
Default Re: ItemRenderer and components

You can dispatch a "bubbling" event. Any object in the ancestor chain can
listen for it, including Application.

"more sophisticated than a Canvas " Canvas is a layout container. It does
things like calculate scrollbars and sizing children. Is that the
functionality you need?

If not, extend UIComponent. It can parent your sprite, or whatever.

Tracy

Reply With Quote
  #6 (permalink)  
Old 10-01-2008, 02:59 PM
SiHoop
 
Posts: n/a
Diggs:
Default Re: ItemRenderer and components

If I use a UIComponent I get the following error with the code below (which is
just a change from a Canvas to a UIComponent):
TypeError: Error #1034: Type Coercion failed: cannot convert
components::AddButton@565a331 to mx.controls.listClasses.IListItemRenderer.
at
mx.controls.dataGridClasses:ataGridBase/createCo lumnItemRenderer()[E:\dev\3.0.
x\frameworks\projects\framework\src\mx\controls\da taGridClasses\DataGridBase.as:
1415]

<?xml version="1.0" encoding="utf-8"?>
<mx:UIComponent xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var myColor:uint=uint(0x555500);
graphics.beginFill(myColor);
graphics.drawRoundRect(0, 5, 30, 12, 3);

graphics.endFill();
}
]]>
</mx:Script>
</mx:UIComponent>

Reply With Quote


  #7 (permalink)  
Old 10-01-2008, 02:59 PM
SiHoop
 
Posts: n/a
Diggs:
Default Re: ItemRenderer and components

If I use a UIComponent I get the following error with the code below (which is
just a change from a Canvas to a UIComponent):
TypeError: Error #1034: Type Coercion failed: cannot convert
components::AddButton@565a331 to mx.controls.listClasses.IListItemRenderer.
at
mx.controls.dataGridClasses:ataGridBase/createCo lumnItemRenderer()[E:\dev\3.0.
x\frameworks\projects\framework\src\mx\controls\da taGridClasses\DataGridBase.as:
1415]

<?xml version="1.0" encoding="utf-8"?>
<mx:UIComponent xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var myColor:uint=uint(0x555500);
graphics.beginFill(myColor);
graphics.drawRoundRect(0, 5, 30, 12, 3);

graphics.endFill();
}
]]>
</mx:Script>
</mx:UIComponent>

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 10:36 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk