![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
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> |
| Sponsored Links |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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> |
|
|||
|
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 |
|
|||
|
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> |
|
|||
|
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> |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise