flex3 : insert instance of UIComponent into a textfield
hello
Does anyone know if there is a way of inserting an instance of UIComponent into a textfield?
for example, say I have a mx.controls.Text with some htmlText assigned to it.
I then also create a VBox object, is it possible to refer to this VBox object in the htmlText and embed it into the textfield? in a similar way to embedding an image into the textfield using <img> tags....?
thankyou....
Found out how to hover a UIComponent above a textField
This is a hacky way to do something like what you wanted. Summary is using the "id" field of the <img> tag to get the DisplayObject for the image, getting the geometry of it, then floating the desired other object over it using the same geometry.
First subclass Text to expose the underlying TextField instance:
public class ExposedText extends Text {
public function getTextField(): IUITextField {
return textField;
}
}
Then in your use of it say you've got an ExposedText named textObj. Then do:
var imgRef: DisplayObject = textObj.getTextField().getImageReference( "imgTag" );
var imgRect: Rectangle = imgRef.getBounds( this );
wowBtn.x = imgRect.x;
wowBtn.y = imgRect.y;
wowBtn.width = imgRect.width;
wowBtn.height = imgRect.height;
Where "wowBtn" is an mx:Button I've declared elsewhere, and "imgTag" is what you put in the "id" attribute of your <img> tag inside ExposedText's htmlText property. Phew!