I made a custom component, BitmapButton, which is based on spark.components.Button. It basically just takes three Bitmap objects - upBitmap, overBitmap and downBitmap - and then its skin class, BitmapButtonSkin, uses these bitmaps for each state.
Now the problem: I want to make a ButtonBar which uses my BitmapButton for its buttons. What do you think would be the right way to approach this? Do I need to create a new component such as ToggleBitmapButton and then its skin or can I reuse the classes I've already made?
You need only create a custom skin for the ButtonBar and inside it use custom skins for the buttons. From what you have described as your goal, I see no need to create custom components, neither for the ButtonBar, nor for the buttons themselves.
Related
I need to completely initialize a custom component in my Flex app (i.e. I should be able to access it from action script and get its properties and its children etc), But I do not want to add it to the display or make it visible.
I have tried to add it to my visible component, but keep it visible, but often many of its properties are set only when it is drawn, so i don't get what i need.
Is there a way to add a custom component to some sort of 'Virtual' display, that is not visible to the user?
You could add the component to an invisible Sprite - that way the component itself could both be on the stage and have its own visible property set to true.
Did you try using initialize()? After a view is added to the display list, the initialization stage begins. Calling initialize() before addChild() should let you initialize the view without needing to first add it to the stage.
For more info visit:
http://flexscript.wordpress.com/2008/10/24/flex-component-lifecycle-and-flex-component-framework/
http://blog.deadinkvinyl.com/2008/10/05/flex-3-addchild-and-initialize/
Not sure if possible without adding it to the display list, although I'd wish it were to some extent.
I once had to make custom drag proxy, which didn't work with the real component, because of some weird skinning issues. So instead I had PopupMananger add a box as a popup, added my component to the box, called validateNow on the component, drew it in a bitmap data, removed the popup, and used the bitmap data as the proxy.
So what you were trying was missing a call to validateNow most likely.
I'm doing some bit of redesigning here for which we hired an outsourced freelance designer. He sent in the designs however he's used css class styles for the textboxes as opposed to my earlier attempts to apply a ganeral style to the inputs tag which had its hiccups.
I've used the Zend View Helpers to create the textboxes however I would like a simpler way to be able to set it up so by default all textfields would have the base css class 'textfield' - is there a way to do so in code without me having to explicitly make the addition in every call made to the view helper?
If you want to apply this style to all textfields on your page you just need a general textfield style and there is no need to even touch your markup.
If you have other textfields as well which you want to style differently, you will have to either extend Zend_Form, Zend_Form_Element or Zend_Form_Element_Text. Probably it would be easiest to extend the former and adding an attribute 'class' with the value 'textfield' to every text element while looping through all form elements.
But again. Why would you need to touch your markup at all, you just need a style for textfields.
I have a nice looking fxg button, to which I want to attach a tooltip- how do I achieve that without much hassle? (the spark button does this out-of-box, but is not very visually pleasing)
The examples I have seen on search is reverse- using fxg effects in the tooltip...
Thanks again for any guidance/ pointers
Typically you use FXG to draw the skin for a Button, then attach that skin to your Button (either by CSS or by setting the skinClass style on the button when it is declared.) That way you get all of the behaviors of a standard Button drawn however you like using your FXG. You do this by creating a new ButtonSkin based on the default spark ButtonSkin and replacing the default FXG with your own. You will then get the tool tip functionality for free. Hope that helps.
I have a Flex list and a custom ItemRenderer. I'd like to be able to have some items in the list use a different ItemRenderer (say, depending on the class of the item). Is this possible?
E.g.:
<s:List dataProvider="{_systems}" itemRenderer="myItemRenderer"/>
Most items in _systems use myItemRenderer. But if element 3 of _systems is "specialSystem" the renderer would be "specialItemRenderer".
Is this possible?
Use an itemRendererFunction.
Here is a blog post tutorial on that. I also touch on this here.
You use Canvas as ItemRenderer and implement mechanism which will create other controls automatically.
More details you can find in this article: Different Items renderers in List
The main idea:
You create special ItemRenderer which
can create "emulate" other controls,
in our case it is subclass of Canvas
which simply creates and adds desired
control. Then we need some mechanism
to tell our container which renderer
we want to emulate, for this purpose we
use ItemContainerData with special
fields.
Does anyone know an Actionscript equivalent of the javascript getElementsByClassName.
What I would like to do is add a custom 'stylename' to various components which I can then use to get a collection of these objects and therefore process their visibility property.
The idea is I want to hide various components based on what roles a logged in user has - I just want to make this flexible by adding an array of rolenames to a custom property or use the stylename property on a Canvas or Panel etc.
Thanks
I think your best bet is to use flex states. A base state with the differences specified in sub states. heres a nice tutorial from adobe on flex states assuming you're using flex 3.x : http://www.adobe.com/devnet/flex/quickstart/creating_states/