Flash 板


LINE

以下范例,我使用 mxml 制作,请参考符合你需求的部分使用即可 <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" minWidth="800" minHeight="600" layout="vertical" creationComplete="application1_creationCompleteHandler(event)"> <mx:Script> <![CDATA[ import mx.events.ColorPickerEvent; import mx.events.FlexEvent; import mx.events.ListEvent; [Bindable] private var sizeList:Array = [12, 16, 20, 24, 30, 36]; [Bindable] private var fontList:Array = ["Arial", "Courier New", "Times New Roman"]; private var _txt:TextField; protected function application1_creationCompleteHandler(event:FlexEvent):void { _txt = new TextField(); _txt.width = 400; _txt.height = 300; _txt.border = true; _txt.background = true; _txt.backgroundColor = 0xffffff; _txt.type = TextFieldType.INPUT; _txt.multiline = true; ta.addChild(_txt); } protected function cbSize_changeHandler(event:ListEvent):void { fontFormatChanged(); } protected function cbFont_changeHandler(event:ListEvent):void { fontFormatChanged(); } protected function colorPicker_changeHandler(event:ColorPickerEvent):void { fontFormatChanged(); } private function fontFormatChanged():void{ var tf:TextFormat = _txt.defaultTextFormat; tf.size = cbSize.selectedLabel; tf.font = cbFont.selectedLabel; tf.color = colorPicker.selectedColor; _txt.defaultTextFormat = tf; _txt.setTextFormat(tf); } ]]> </mx:Script> <mx:ComboBox id="cbSize" dataProvider="{sizeList}" change="cbSize_changeHandler(event)" /> <mx:ComboBox id="cbFont" dataProvider="{fontList}" change="cbFont_changeHandler(event)" /> <mx:ColorPicker id="colorPicker" change="colorPicker_changeHandler(event)" /> <mx:UIComponent id="ta" /> </mx:Application> ※ 引述《s00390 (Ally)》之铭言: : 目前做的是 影片字幕 : 字幕我是用XML汇入FLASH : 在SWF档里 可以任选字的颜色或者是大小和字型 : mFLV.addEventListener(MetadataEvent.CUE_POINT,readFLV); : function readFLV(e:MetadataEvent):void : { : word_txt.text = e.info.name; : font_cb.dataProvider = new DataProvider( : ["Arial", "Courier New", "Times New Roman"] : ); : size_cb.dataProvider = new DataProvider( : [12,16,20,24,30,36] : ); : size_cb.selectedIndex = 1; : size_cb.editable = true; : size_cb.textField.restrict = "0-9"; : size_cb.textField.maxChars = 2; : font_cb.addEventListener(Event.CHANGE, fontChange); : size_cb.addEventListener(Event.CHANGE, fontChange); : picker.addEventListener(Event.CHANGE, fontChange); : function fontChange(e:Event):void { : // var begin:int = word_txt.selectionBeginIndex; : // var end:int = word_txt.selectionEndIndex; : // if (begin>=word_txt.text.length || end==0) { : // return; : // } : // var format:TextFormat; : switch (e.target.name) { : case 'font_cb' : : //format = new TextFormat(font_cb.value); : break; : case 'size_cb' : : word_txt.size = size_cb; : //format = new TextFormat(null, size_cb.value); : break; : case 'picker' : : word_txt.textColor = picker.selectedColor; : //format = new TextFormat(null, null, picker.selectedColor); : } : // word_txt.setTextFormat(format, begin, end); : //showHtmlText(null); : } : word_txt.alwaysShowSelection = true; : 主要是要改 : switch (e.target.name) { : case 'font_cb' : : //format = new TextFormat(font_cb.value); : break; : case 'size_cb' : : word_txt.size = size_cb; : //format = new TextFormat(null, size_cb.value); : break; : case 'picker' : : word_txt.textColor = picker.selectedColor; : //format = new TextFormat(null, null, picker.selectedColor); : color的部分是已经改好的 : 注解//是代表之前的程式码 之前的程式码是要选取字 才能改变 : 想请问 font 字型 和 size 大小 那里要改成什麽 才会向color那样 : 不用选取 按一下他就会整个都改变 谢谢~~~~~ --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.147.239.66







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Gossiping站内搜寻

TOP