hi guys

in actionscript 3, if i put a mouse event on a movieclip object containing a textfield, should the mouse event be on the movieclip or the textfield?

here's my code (comments added to see where the problem is occurring)
CODE
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; // sets the starting point for all periodBars var pbY:int = pbYStart + pbGetY(dateStart, dateEnd) * (pbHeight +pbSpace); // pbGetY is a separate function that automatically stacks the periodBars where they will fit without overlapping
                        
var pb:MovieClip = new MovieClip(); // was a sprite but sprites cannot have strings attached to them, eg my rolloverText variable
                        
if (uint(dateEnd-dateStart) > 1) // if the difference between the start and end dates is more than 1
                        {
                                pb.graphics.beginFill(0xFFFFFF,.3);
                                
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; // tried making this non-selectable but it hasn't helped
                                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);

                        } else {
// will create a dot instead of a box containing text if it will otherwise be too small to render a roundrect
                                pb.graphics.beginFill(0xFFFFFF,.5);
                                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);
                        
                        scrollableBase.addChild(pb);
                }
                
                private function pbMouseOverListener(e:MouseEvent):void
                {
mfTextField.text = e.target.rolloverText; // mfTextField is a textfield within a mousefollower trace (e.target); // traces simpleTextField if over a movieclip with a simpletextfield in otherwise traces movieclip trace (e.target.rolloverText); // gives error when over a simpletextfield but works properly when over a movieclip without, eg where the dates are too close and a dot is rendered instead
                        mouseFollower.visible = true;
                }

because the movieclip isn't always the target (even tho i've set the mouseevent on the movieclip), i can't consistently get a reading from rolloverText (because it's trying to find the variable rolloverText in the pbText SimpleTextField)

can anyone explain why this is and what i can do to get around it please?

thanks a lot
a

Allandt Bik-Elliott
thefieldcomic.com
e [EMAIL PROTECTED]

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to