thanks. i will give this a go.
fyi - emails to your acm account seem to be bouncing. i emailed your company
about it.

On 5/9/07, Michael Labriola <[EMAIL PROTECTED]> wrote:


There are a couple of work arounds. This one is the least horrible.

This code is not great but it should give you an idea of this
approach.

A few things to note: there is a big chunk of bad form right in the
middle of the code that specifically sets the text property... this
is not a good way to go

Second, this code still uses the measured sizes of the original
label. You would probably want to consider implementing your own
measure method.

In any case, this is a start, I will blog a final version in a few
days.

ML
http://blogs.digitalprimates.net/codeSlinger

package net.digitalprimates.flex2.mx.containers
{
import flash.events.Event;

import mx.containers.FormItem;
import mx.controls.FormItemLabel;
import mx.core.ClassFactory;
import mx.core.IFactory;
import mx.core.UIComponent;
import mx.controls.Label;

public class AdvancedFormItem extends FormItem
{
private var _labelFactory:IFactory = new ClassFactory
(FormItemLabel);
protected var _advancedLabel:UIComponent;

[Bindable("labelFactoryChanged")]
public function get labelFactory():IFactory
{
return _labelFactory;
}

public function set labelFactory(value:IFactory):void
{
_labelFactory = value;

dispatchEvent(new Event("labelFactoryChanged"));
}

protected function createAdvancedItemLabel():void {
_advancedLabel = labelFactory.newInstance();
rawChildren.addChild( _advancedLabel );

//This is bad form, but it should give you the idea
Label( _advancedLabel ).text = label;
}

override protected function commitProperties():void
{
super.commitProperties();

createAdvancedItemLabel();
}

override protected function updateDisplayList
(unscaledWidth:Number,

unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth,
unscaledHeight);

var existingLabel:FormItemLabel =
rawChildren.getChildAt( 1 ) as FormItemLabel;
existingLabel.visible = false;

_advancedLabel.setActualSize(
existingLabel.width, existingLabel.height );
_advancedLabel.move( existingLabel.x,
existingLabel.y );
}
}
}

--- In [email protected] <flexcomponents%40yahoogroups.com>,
"dorkie dork from dorktown"
<[EMAIL PROTECTED]> wrote:
>
> it extends the label control. how does the workaround work?
>
> On 5/6/07, Michael Labriola <[EMAIL PROTECTED]> wrote:
> >
> >
> > does your component actually extend label or is it completely
> > different. i ran into this same issue, so, if it extends label, i
> > have a work around for you.
> >
> > --- In 
[email protected]<flexcomponents%40yahoogroups.com><flexcomponents%
40yahoogroups.com>,
> > "dorkie dork from dorktown"
> >
> > <dorkiedorkfromdorktown@> wrote:
> > >
> > > i'm making a label component. it works fine but i'd like to
use it
> > in
> > > mx.controls.FormItem. to do this i think i need the function
> > > createItemLabel() to be public along with any other related
> > properties (ie
> > > _label, etc) so i can extend FormItem (FormItem2) container.
what
> > would be
> > > better is using a factory pattern so i can pass in my label
> > control to the
> > > regular form item and not have to make my own version of
FormItem.
> > >
> > > in the mx.controls.FormItem.as file:
> > >
> > > /**
> > > * @private
> > > */
> > > private function createItemLabel():void
> > >
> >
> >
> >
>

Reply via email to