okay i've tried everything i can find in the book re: this problem and
it doesn't seem to be having any affect
i've tried the mouseChildren option (commented out) and useCapture
tomfoolery (seems to be firing in the CAPTURING_PHASE as that's the
only one i can get any result from) and i've also tried separating the
graphic elements from the container displayobject to get rid of any
code wierdness. I've even tried putting the solid block on top of the
text and applying the event to that but none of it has worked.
here is my code (with eventphase extra bits in place):
private function createPeriodBar(dateStart:int, dateEnd:int,
pbTitle:String, pbDate:String, pbList:Array = null):void
{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int = yearsToPixels(dateEnd);
var pbX:int = pixelStart;
var pbWidth:int = pixelEnd - pixelStart;
var pbYStart:int = taTitleBarHeight + pbSpace;
var pbY:int = pbYStart + pbGetY(dateStart, dateEnd) *
(pbHeight+pbSpace);
var pbcontainer:MovieClip = new MovieClip();
var pb:Shape = new Shape();
if (uint(dateEnd-dateStart) > 1)
{
pb.graphics.beginFill(0xFFFFFF,.3);// white 50% alpha
pb.graphics.drawRoundRect(0,0,pbWidth,pbHeight,pbHeight);
pb.graphics.endFill();
pbcontainer.x = pbX;
pbcontainer.y = pbY;
var pbText:SimpleTextField = new
SimpleTextField(0xFFFFFF, 14, headingFont, 4, -2, pbWidth-4, 25,
pbTitle, false);
pbText.selectable = false;
pbText.text += " ";
pbText.text += pbDate;
var pbf:TextFormat = new TextFormat();
pbf.font = subheadingFont;
pbf.size = 10;
var pbCurrentLength = pbTitle.length+1;
var pbDateLength = pbText.length;
pbText.setTextFormat(pbf, pbCurrentLength, pbDateLength);
pbcontainer.addChild(pbText);
pbcontainer.addChild(pb);
//pb.mouseChildren = false; //
} else
{
pb.graphics.beginFill(0xFFFFFF,.5);// white 50% alpha
pb.graphics.drawCircle(0,0,pbHeight/2);
pb.graphics.endFill();
pbcontainer.x = pbX;
pbcontainer.y = pbY+(pbHeight/2);
pbcontainer.addChild(pb);
}
pbcontainer.rolloverText = pbTitle + "\n" + pbDate;
pbcontainer.addEventListener(MouseEvent.CLICK,
pbMouseOverListener, true); // changed to click to make it easier to
track
scrollableBase.addChild(pbcontainer);
}
private function pbMouseOverListener(e:MouseEvent):void
{
if (e.eventPhase == EventPhase.CAPTURING_PHASE)
{
mfTextField.text = e.target.rolloverText;
trace (e.target.rolloverText);
mouseFollower.visible = true;
}
}
really hope you can help because i'm stumped (and it's 12.15 am ;) )
a
On 31 Mar 2008, at 23:20, Allandt Bik-Elliott (Receptacle) wrote:
i have the moock book but i couldn't get my head round the bubbling
phase and how it affected me - i need to look into it a bit more
i added mouseChildren=false but it made the entire event stop - even
on the objects that were working before, and i didn't even get the error
is this because i've drawn directly in the sprite?
here's what i did:
private function createPeriodBar(dateStart:int, dateEnd:int,
pbTitle:String, pbDate:String, pbList:Array = null):void
{
var pixelStart:int = yearsToPixels(dateStart);
var pixelEnd:int = yearsToPixels(dateEnd);
var pbX:int = pixelStart;
var pbWidth:int = pixelEnd - pixelStart;
var pbYStart:int = taTitleBarHeight + pbSpace;
var pbY:int = pbYStart + pbGetY(dateStart, dateEnd) *
(pbHeight+pbSpace);
var pb:MovieClip = new MovieClip();
if (uint(dateEnd-dateStart) > 1)
{
pb.graphics.beginFill(0xFFFFFF,.3);// white 50% alpha
pb.graphics.drawRoundRect(0,0,pbWidth,pbHeight,pbHeight);
pb.graphics.endFill();
pb.x = pbX;
pb.y = pbY;
var pbText:SimpleTextField = new
SimpleTextField(0xFFFFFF, 14, headingFont, 4, -2, pbWidth-4, 25,
pbTitle, false);
pbText.selectable = false;
pbText.text += " ";
pbText.text += pbDate;
var pbf:TextFormat = new TextFormat();
pbf.font = subheadingFont;
pbf.size = 10;
var pbCurrentLength = pbTitle.length+1;
var pbDateLength = pbText.length;
pbText.setTextFormat(pbf, pbCurrentLength,
pbDateLength);
pb.addChild(pbText);
pb.mouseChildren = false;
/////////////////////////////////////////////////////////////<<<<<<<<<<<<<<<<<<<<<<---------------------------------
HERE
} else
{
pb.graphics.beginFill(0xFFFFFF,.5);// white 50% alpha
pb.graphics.drawCircle(0,0,pbHeight/2);
pb.graphics.endFill();
pb.x = pbX;
pb.y = pbY+(pbHeight/2);
}
pb.rolloverText = pbTitle + "\n" + pbDate;
pb.addEventListener(MouseEvent.MOUSE_OVER,
pbMouseOverListener, true);
scrollableBase.addChild(pb);
}
thanks for your input so far
a
On 31 Mar 2008, at 22:30, Steven Sacks wrote:
IMO, explaining Event Bubbling as the reason the TextField is the
target is complicating the immediate solution he needs, which is
mouseChildren = false.
Yes, it's Event Bubbling that's causing the target to be the
TextField. To understand Event Bubbling, read about it in the docs,
or better yet, in a book (like Moock's). But, then you MUST do it
yourself to learn how it works. If you don't play with it yourself,
you will never "get it" no matter how much somebody explains it to
you. I'm fully convinced of that. You gotta mess around with it to
fully understand why it's so amazingly awesome.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders