I would like to develop a network graphics application for Flex - imagine that you place nodes on a canvas and connect them to links. Nodes must have editable text and other user interface components.
I'm trying to find examples of creating a completely new user interface component from scratch, but all I managed to find are trivial examples that extend existing components: RedButton, which extends Button, for example, or ComboBox, which has states to choose from.
My main question is: which ActionScript method defines the component drawing? What is the ActionScript equivalent for Java paint ()?
You want to create a component that will override the updateDisplayList method and make your drawing there:
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList( unscaledWidth, unscaledHeight ); // The drawing API is found on the components "graphics" property graphics.clear(); graphics.lineTo( 0, unscaledWidth ); // etc }
More information can be found here: http://livedocs.adobe.com/flex/3/html/help.html?content=ascomponents_advanced_3.html
I would suggest looking at the flexlib project if you need examples of custom components.
There is good general info in liveocs here
Although you can create custom components in MXML and ActionScript, I would recommend implementing them in ActionScript.
In short, this is what you need to do:
ActionScript UIComponent. , createChildren(), commitProperties(), measure(), layoutChrome() updateDisplayList().
5- Peter Ent . 1.
ItemRenderers ItemEditors.
19 Flex 2 Kazoun Lott , .
, Flex , , . "" (, ) invalidateProperties(). invalidateSize(), , ummm, invalidateDisplayList(), - ( ).
. , , ; , - invalidateDisplayList() ; , , .
, , - , , . ( , , .)
, barecomb UIComponent " ", UIComponent ( ), , , , , IUIComponent . , This is an in-depth discussion of Flex Component Architecture by one of the Flex team engineers. I recommend it often and very much; this is excellent, and it explains a number of components development details that are still not all well documented. Extremely valuable material if you intend to create non-trivial custom components that you describe.
Hope this helps. Good luck