0
我試圖完成第8課Adobe 3.0專業版的ActionScript 3.0 CS5,但已經發現一些困難:我輸入了書中所示的所有代碼,但 沒有得到結果,我認爲問題是我使用Adobe Flash CS 6, ,因爲部分文件在CS 6中未正確打開。下面是第8課 的代碼以及我需要做什麼來完成本課程?如何完成課程?
import fl.text.TLFTextField;
import fl.controls.UIScrollBar;
var t:TLFTextField = new TLFTextField();
var tf:TextFormat = new TextFormat();
t.width = 500;
t.height = 600;
t.background = true;
t.paddingTop = 20;
t.paddingLeft = 20;
t.paddingRight = 20;
addChild(t);
var textLoad:URLLoader = new URLLoader();
textLoad.addEventListener(Event.COMPLETE, textLoaded);
textLoad.load(new URLRequest("sample.txt"));
function textLoaded(e:Event):void
{
var txt:String = URLLoader(e.target).data as String;
t.text = txt;
tf.color = 0x336633;
tf.font = "Arial";
tf.size = 14;
t.setTextFormat(tf);
}
var formatClip:Formatter = new Formatter();
var showFormat:Boolean = true;
stage.addEventListener(KeyboardEvent.KEY_DOWN, showFormatter);
function showFormatter(e:KeyboardEvent):void
{
if (e.keyCode == 70)
{
if (showFormat)
{
addChild(formatClip);
formatClip.x = t.width;
formatClip.addEventListener(MouseEvent.MOUSE_DOWN, drag);
showFormat = false;
}
else
{
formatClip.removeEventListener(MouseEvent.MOUSE_DOWN, drag);
removeChild(formatClip);
showFormat = true;
}
}
}
function drag(e:Event):void
{
formatClip.startDrag();
formatClip.addEventListener(MouseEvent.MOUSE_UP, noDrag);
}
function noDrag(e:Event):void
{
formatClip.stopDrag();
}
formatClip.fontList.addEventListener(Event.CHANGE, setFont);
formatClip.fontSizer.addEventListener(Event.CHANGE, setFontSize);
formatClip.colorPicker.addEventListener(Event.CHANGE, setColor);
formatClip.columnNum.addEventListener(Event.CHANGE, setColumns);
function setFont(e:Event):void
{
tf.font = e.target.selectedItem.label;
t.setTextFormat(tf);
}
function setFontSize(e:Event):void
{
tf.size = e.target.value;
t.setTextFormat(tf);
}
function setColor(e:Event):void
{
tf.color = e.target.selectedColor;
t.setTextFormat(tf);
}
function setColumns(e:Event):void
{
t.columnCount = e.target.value;
}
var scroller:UIScrollBar = new UIScrollBar();
scroller.move(t.x + t.width, t.y);
scroller.height = t.height;
scroller.scrollTarget = t;
addChild(scroller);
scroller.visible = false;
formatClip.addEventListener(MouseEvent.CLICK, setScrollbar);
function setScrollbar(e:Event):void
{
if (t.textHeight > scroller.height)
{
scroller.visible = true;
}
else
{
scroller.visible = false;
}
t.scrollV = 1;
}
我得到這個SWF:
但需要得到這個SWF: 謝謝 約扎斯Vitkus
第8課?書?你在說什麼?! –