hey guys
this is probably a silly bug but i've got a very strange occurance
i've got a method that is supposed to create a textfield with an
invisible button on top but, even tho the traces come out correctly, i
can't seem to stop the textfield obscuring the button if they're added
to the same sprite. I'd rather know why that was rather than simply
creating another sprite to sit the button in
here's the method
private function createItem():void
{
var w:Number = _nWidth - (BasketItem.PADDING * 2);
_tfItem =
AssetFactory.createTextField(0, 0, w, 20);
_tfItem.autoSize = TextFieldAutoSize.LEFT;
_tfItem.wordWrap = true;
_tfItem.x = BasketItem.PADDING;
_tfItem.background = true;
_tfItem.backgroundColor = 0xFFFFFF;
_sprHitArea =
AssetFactory.createButtonOverlay(0, 0, _nWidth);
_sprHitArea.addEventListener(MouseEvent.CLICK, itemClickHandler,
false, 0, true);
_sprItemLayer.addChild(_tfItem);
_sprItemLayer.addChild(_sprHitArea);
trace("i" + _sprItemLayer.getChildIndex(_tfItem));
// traces as i0
trace("ha" + _sprItemLayer.getChildIndex(_sprHitArea)); // traces
as ha1
}
the AssetFactory.createTextField method is here - AssetFactory is a
static class that i use to create a lot of the common items throughout
my ria
public static function createTextField(nX:Number = 0, nY:Number = 0,
nWidth:Number = 100, nHeight:Number = 100):TextField
{
var tf:TextField = new TextField();
tf.x = nX;
tf.y = nY;
tf.width = nWidth;
tf.height = nHeight;
tf.multiline = true;
tf.embedFonts = true;
tf.selectable = false;
tf.antiAliasType = AntiAliasType.ADVANCED;
tf.sharpness = 200;
tf.styleSheet = SiteData.instance.cssStyle;
return tf;
}
and here is the AssetFactory.createButtonOverlay method
public static function createButtonOverlay(nX:Number = 0, nY:Number
= 0, nWidth:Number = 100, nHeight:Number = 100):Sprite
{
var sp:Sprite = new Sprite();
sp.graphics.beginFill(0xff9900, 0);
sp.graphics.drawRect(nX, nY, nWidth, nHeight);
sp.graphics.endFill();
sp.buttonMode = true;
return sp;
}
i've set the background of the textfield to white and the button
overlay to orange so i can see what is overlapping what and the white
seems to be on top of the orange even though their indices indicate
that the textfield is below the button
i'm very confused about this as it's a fairly simple operation
thanks in advance
a
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders