AS3 HTML 标签使用

来源:互联网 发布:思念去世的父亲 知乎 编辑:程序博客网 时间:2024/04/30 03:04

Flash CS3里可用的HTML标签和注意事项
Adobe Flash播放器支持一组标准HTML标签, 例如<p>和<li>, 你可以把它们放在动态或输入框文本区内来格式化文字.

Flash播放器版本7和后续版本也支持<img>标签. 你可以在文本区嵌入图片(JPEG,GIF,PNG)和SWF文件.

Flash播放器自动把文字环绕在图片周围, 就像浏览器显示HTML页面时把文字环绕在图片周围那样.


Adobe Flash Player supports a subset of standard HTML tags such as <p>and<li>, which you can use to style text in any dynamic or input textfield.Text fields in Flash Player 7 and later also support the <img>tag, whichlets you embed image files (JPEG, GIF, PNG), SWF files, and movieclips in atext field. Flash Player automatically wraps text around imagesembedded in textfields in much the same way that a web browser wraps textaround embedded imagesin an HTML page.

HTML tags supported by Adobe Flash CS3 Professional
The following HTML tags are supported by Adobe Flash CS3 Professional.Optionaltag attributes appear in brackets.

引用内容

Anchor:<ahref="/support/flash/ts/documents/url">
Bold: <b>
Font: < font [color="#xxxxxx"] [face="Type Face"][size="TypeSize"]>
Italic: <I>
Paragraph:<p[align="left"|"right"|"center"]>
Underline: <u>
Break: <br>
Image: <img src="http://images.cnblogs.com/flash/dogs.jpg"/>The<img> tag lets you embed external image files (JPEG, GIF, PNG), SWFfiles,and movie clips inside text fields and TextArea component instances.
List Item: <li>



ordered and unordered lists (<ol> and <ul> tags) are notrecognizedby Flash Player, so they do not modify how your list is rendered. Alllistitems use bullets.
Span: The <span> tag is available only for use with CSS text styles.
TextFormat: The <textformat> tag lets you use a subset ofparagraphformatting properties of the TextFormat class within HTML textfields,including line leading, indentation, margins, and tab stops. You cancombine<textformat> tags with the built-in HTML tags.

 引用内容

Additionally, Flash Player supports HTMLentities:

< < (less than)
> > (greater than)
& & (ampersand)
" " (double quotes)
&apos; ' (apostrophe, single quote)

 

 程序代码


如何使用Flash MX 2004所支持的HTML标签: 
第一步:新建一个FLASH文档,在舞台上插入一个动态文本框,并命名为 my_txt 。 
第二步:在第一帧加入AS代码: 
my_txt.html = true; //指定该文本字段为HTML文本字段。 
my_txt.htmlText="<a href=’http://www.flash8.net’ target=’_self’>闪吧</a>"; 
//引用HTML的超链接标签。 
Flash MX 2004所支持的HTML标签: 
<a> 超链接标签
  属性:href: 链接地址
  target: 目标窗口 可取值为_blank,_parent,_self,_top。
  例:
  my_txt.htmlText="<ahref=’http://www.flash8.net’target=’_self’>闪吧</a>"; 
<b> 粗体标签
  例:
  my_txt.htmlText="<b>闪吧</b>"; 
<br> 换行标签
  例:
  my_txt.htmlText="闪吧<br>"; 
<font> 字体标签
  属性:color:字体颜色,格式#RRGGBB。
  face:字体,可以是单个字体或字体列表。
  size:字体大小,单位像素。
  例:
  my_txt.htmlText="<fontcolor=’#ff0000’face=’Arial’ size=’12’>闪吧</font>"; 
<i> 斜体标签
  说明:
  例:
  my_txt.htmlText="<i>闪吧</i>"; 
<li> 列表项标签
  例:
  my_txt.htmlText="Sports:<li>新手区</li> <li>教程区</li><li>资源区</li>";
  注意,文本框要选中“多行”。 
<p> 段落标记
  属性:align:对其方式,可取值left,right,center。 
class:应用一个css样式类。
  例:
  my_txt.htmlText="<palign=’right’class=’title’>align right</p><p align=’left’class=’body’>alignleft</p>";
  注意,文本框要选中“多行”。本例假设css类title和body已存在。 
<span> 标签
  说明:对位于该标签内所有文本应用css样式,只有在定义了css对象后有效。
  属性:class:应用一个css样式类。
  例:
  my_txt.htmlText="<spanclass=’body’>闪吧</span>"; 
  注意,本例假设css类body已存在。 
<u> 下划线标签
  例:
  my_txt.htmlText="<u>闪吧</u>"; 
<img> 图像标签
  说明:这个标签的功能不仅仅是在文本框中插入图片,还可以插入SWF和MovieClip。
  属性:src: 要加载的JPG或SWF的URL,或是MC的链接ID,这个属性是必要的,其他属性则可选。
  注意:Flash不支持progressive格式的JPG。
  id : 指定嵌入了JPG,SWF或MovieClip的电影剪辑的名称。
  width: 图片/动画宽度。 
  height: 图片/动画高度。
  align: 对其方式,可取值:left,right,默认为left。
  hspace: 文本环绕图时水平方向上与图片的空隙。
  vspace: 文本环绕图时垂直方向上与图片的空隙。
例: 
my_txt.htmlText="<src=’my.swf’ width=’100’height=’80’align=’left’>"; 
<textformat> 文本格式标签
  说明:这个标签可以让你直接应用一些TextFormat对象的属性到文本中。
  属性:blcokIndent: 段落缩进大小,单位像素。
  indent: 段落首行缩进大小,单位像素。
  leading: 文本行间距,单位像素。
  leftmargin: 文本左边距,单位像素。
  rightmargin: 文本右边距,单位像素。
  tabstops: 表格划分,单位像素。
  注意:关于属性tabstops:它的值是一个数组,用来表示表格的列划分情况。
  在文本中用转义字符 将输出位置移动到下一个制表位。
  例:
  tabField="<b>nameSexAge </b><br>";
  tabRecord1="rongsheng20Male <br>";
  tabRecord2="zjq21Female <br>";
  txt="<textformattabstops=’[50,150,150]’>"+tabField+tabRecord1+tabRecord2+"</textformat>";