i should probably mention that the same object is used for several
instances but it's just the one that doesn't use the elCreditFormat
TextFormat that fails to scroll
thanks
a
On 30 Jun 2008, at 15:10, Allandt Bik-Elliott (Receptacle) wrote:
i really hope someone can help me here
i have a textfield that is set up with a defaultTextFormat and has
several setTextFormats applied to type within it but when i try to
overflow it and add a scrollbar, i get no scroll result.
I've looked into it and it seems that no matter how much type goes
in (either more or less), it shows that there are 4 lines (using
TextField.numLines) in it.
i've included the method below and commented where the issue is -
note that there is a textformat that is applied if the elCredit
property is set that is the thing that seems to be the problem:
when it is added, the numLines traces to the actual number of lines
(and the scrollbar works) but when it doesn't get used, numLines is
4 regardless of content and the scrollbar doesn't work
please help as i'm really stumped on this issue
thankyou
a
private function createBase():void
{
elBase = new Sprite();
elBase.graphics.beginFill(commonGrey, 1);
elBase.graphics.drawRect(0, 0, elWidth, elHeight);
elBase.x = elX;
elBase.y = elY;
var dropShadow:DropShadowFilter = new
DropShadowFilter();
dropShadow.color = 0x000000;
dropShadow.blurX = 10;
dropShadow.blurY = 10;
dropShadow.angle = 135;
dropShadow.alpha = .5;
dropShadow.distance = 10;
var filtersArray:Array = new Array(dropShadow);
elBase.filters = filtersArray;
var close_btn:Sprite = new Sprite();
close_btn.buttonMode = true;
close_btn.graphics.lineStyle(1, 0x333333, 1);
close_btn.graphics.beginFill(0xFFFFFF);
close_btn.graphics.drawRect(0, 0, 10, 10);
close_btn.addEventListener(MouseEvent.CLICK,
closeBtnListener);
close_btn.x = elWidth -15;
close_btn.y = 5;
var popupNotice_txt:String = "Click image to zoom
in/out.";
var popupNotice:SimpleTextField = new SimpleTextField(0xFFFFFF,
12, headingFont, 5, 2, textWidth, textHeight, popupNotice_txt, true);
var txt:String = elTitle +"\n";
txt += elDate +"\n";
txt += elText +"\n";
if (elCredit != "\nPicture credit: ") txt += elCredit;
textWidth -= 15;
// this is the textfield
var elTextField:SimpleTextField = new SimpleTextField(0x000000,
12, mainFont, textX, textY, textWidth, textHeight, txt);
elTextField.wordWrap = true;
elTextField.multiline = true;
var eltfScrollbar:UIScrollBar = new UIScrollBar();
eltfScrollbar.scrollTarget = elTextField;
eltfScrollbar.move(elTextField.x+elTextField.width,
elTextField.y);
eltfScrollbar.height = elTextField.height;
var titleFormat:TextFormat = new TextFormat();
titleFormat.font = headingFont;
titleFormat.size = 16;
titleFormat.leading = 0;
titleFormat.color = 0xFFFFFF;
var dateFormat:TextFormat = new TextFormat();
dateFormat.font = subheadingFont;
dateFormat.size = 14;
dateFormat.leading = 6;
dateFormat.color = 0xFFFFFF;
var creditFormat:TextFormat = new TextFormat();
creditFormat.size = 9;
creditFormat.color = 0x333333;
var titleItalicFormat:TextFormat = new TextFormat();
titleItalicFormat.font = headingItalicFont;
var bodyItalicFormat:TextFormat = new TextFormat();
bodyItalicFormat.font = mainItalicFont;
var titleLength:int = int(elTitle.length) +1;
var dateLength:int = int(elDate.length) + titleLength
+1;
var totalLength:int = int(txt.length);
var textLength:int = totalLength -
int(elCredit.length);
elTextField.setTextFormat(titleFormat, 0, titleLength);
elTextField.setTextFormat(dateFormat, titleLength,
dateLength);
// NOTE when the if statement is taken off this line so that the
format is always set, this textfield behaves properly
if (elCredit != "\nPicture credit: ") elTextField.setTextFormat
(creditFormat, textLength, totalLength);
for (var i:String in italicArray)
{
var entry:String =
italicArray[i];
var entryLength:Number = entry.length;
var entryPos:Number =
elTextField.text.indexOf(entry);
if (entryPos >= 0) elTextField.setTextFormat(bodyItalicFormat,
entryPos, entryPos+entryLength);
}
imageContainer = new Sprite();
imageContainer.addChild(image);
addChild(elBase);
elBase.addChild(popupNotice);
elBase.addChild(close_btn);
elBase.addChild(elTextField);
elBase.addChild(eltfScrollbar);
elBase.addChild(imageContainer);
imageContainer.scaleX = .5;
imageContainer.scaleY = .5;
imageContainer.x = marginWidth;
imageContainer.y = topmarginHeight;
imageContainer.buttonMode = true;
imageContainer.addEventListener(MouseEvent.CLICK,
clickListener);
// traces 4 when the creditFormat line noted above is false
trace(elTextField.numLines);
}
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders