我正在使用Flash Pro CS6。我已经构建了一个滚动文本字段,通过XML注入了htmltext。
我遇到的问题是maxScrollV似乎没有考虑到我的图像。我试图在html <img src='assets/images/test.png' height='330' width='330' />
中设置尺寸,但这似乎抛弃了wordwrap。
public class ScrollingTextField extends Sprite
{
private var myText:TextField;
private var myFormat:TextFormat;
private var bounds:Rectangle;
private var boundHeight:Number;
private var slider:SliderImage;
public function ScrollingTextField()
{
trace("ScrollingTextField added");
myText = new TextField();
myFormat = new TextFormat();
slider = new SliderImage();
myFormat.font = "Arial";
myFormat.color = 0x333333;
myFormat.size = 14;
addChild(myText);
myText.htmlText = "init";
myText.setTextFormat(myFormat);
myText.wordWrap = true;
myText.multiline = true;
myText.setTextFormat(myFormat);
myText.selectable = false;
this.addChild(slider);
slider.addEventListener(MouseEvent.MOUSE_DOWN, dragSlider);
addEventListener(Event.ENTER_FRAME, checkSlider);
}
private function dragSlider(evt:MouseEvent):void
{
slider.startDrag();
slider.removeEventListener(MouseEvent.MOUSE_DOWN, dragSlider);
slider.addEventListener(MouseEvent.MOUSE_UP, dropSlider);
addEventListener(MouseEvent.MOUSE_MOVE,moveSlider);
}
private function dropSlider(evt:MouseEvent):void
{
slider.stopDrag();
slider.removeEventListener(MouseEvent.MOUSE_UP, dropSlider);
slider.addEventListener(MouseEvent.MOUSE_DOWN, dragSlider);
removeEventListener(MouseEvent.MOUSE_MOVE,moveSlider);
}
private function moveSlider(evt:MouseEvent):void
{
evt.updateAfterEvent();
if (evt.buttonDown)
{
slider.startDrag(false,bounds);
}
else
{
slider.stopDrag();
}
}
private function checkSlider(evt:Event):void
{
myText.scrollV = ((slider.y - bounds.y)* (myText.maxScrollV)/boundHeight);
}
public function textToDisplay(txt:String):void
{
myText.htmlText = txt;
myText.setTextFormat(myFormat);
}
public function setDimensions(w:Number, h:Number):void
{
boundHeight = h - slider.height;
bounds = new Rectangle(w + 20,10,0,h - slider.height);
slider.x = w + 20;
slider.y = 10;
myText.width = w;
myText.height = h;
}
public function checkTextFieldSize():void
{
trace("numLines = " + myText.numLines);
trace("text height = " + myText.textHeight);
trace("height = " + myText.height);
if (myText.textHeight < myText.height)
{
slider.visible = false;
}
else
{
slider.visible = true;
}
}
}
}
答案 0 :(得分:0)
好吧,我最终做了一个廉价的解决方法。从网上搜索,似乎.maxScrollV只是不喜欢.htmltext。我会把它带到Adobe ......同时将<p> </p>
添加到html一段时间以充当图像空间,似乎可以解决问题。