as3关闭html页面,How to Display HTML in Flash AS3

2 Select Actions

Select "Actions" from the "Window" menu on the main Flash menu bar to open the ActionScript 3 editor.

Position your mouse cursor on the first line of the ActionScript 3 editor. Click your mouse button, and type in the code below to create and place a TextField on the flash stage that has a width of 1,000 pixels and a height of 1,000 pixels:

var displayText:TextField = new TextField(); displayText.width = 1000 displayText.height = 1000 displayText.multiline = true; var tf:TextFormat = new TextFormat(); tf.size = 20; tf.font = "Times New Roman"

The TextField will also support text on multiple lines and display the text with a 20 point Times Roman font.

Type the following code into the ActionScript 3 editor starting on the next line:

displayText.htmlText = "

Formatted in Plain Text

Formatted in Bold Text

Formatted in Italic Text

the equation\n\nV= 1_PI_1²

120px-Cycnus_Picart-detail.jpg

"

This code stores the HTML formatted text on the right-hand side of the equals sign in the displayText TextField variable.

Type the following code in the next line of the ActionScript 3 editor:

displayText.setTextFormat(tf); addChild(displayText);

This applies the text formatting to the displayText TextField, and places the displayText TextField on the Flash stage.

Copy and paste the following code, if you did not type in the preceding code already, or replace the code you already typed, to ensure that there are no syntax errors and the AS3 HTML rendering program runs correctly.

var displayText:TextField = new TextField(); displayText.width = 1000 displayText.height = 1000 displayText.multiline = true; var tf:TextFormat = new TextFormat(); tf.size = 20; tf.font = "Times New Roman"

displayText.htmlText = "

Formatted in Plain Text

Formatted in Bold Text

Formatted in Italic Text

the equation\n\nV= 1_PI_1²

120px-Cycnus_Picart-detail.jpg

"

displayText.setTextFormat(tf); addChild(displayText);

Click "TestMovie" option within the "Control" menu to play the Flash AS3 HTML rendering program. Observe that the text is displayed and formatted in plain, bold and italic text, that the XML character is rendered as the superscript 2, the text is in 20 point Times Roman format and that the picture at the WikeMedia Common's URL is rendered.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值