使用从右到左的文本时出现 PaperVision 错误
我的代码生成以下错误(它应该使用 PaperVision 制作 3D 从右到左的文本动画):
[Fault]异常,信息=TypeError:错误#1009:无法访问空对象引用的属性或方法。
但是,仅当我输入从右到左
方向的文本时才会出现此错误。当我使用英文文本时,我没有收到任何错误。
这是我的代码:
package {
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.scenes.Scene3D
import org.papervision3d.view.Viewport3D
import org.papervision3d.cameras.Camera3D
import org.papervision3d.render.BasicRenderEngine
import org.papervision3d.typography.Font3D
import org.papervision3d.typography.fonts.HelveticaBold
import org.papervision3d.typography.Text3D
import org.papervision3d.materials.special.Letter3DMaterial
import flash.text.engine.FontDescription
import flash.text.engine.ElementFormat
import flash.text.engine.TextElement
import flash.text.engine.TextBlock
import flash.text.engine.TextLine
/* @author vahid */
public class Main extends Sprite {
private var fd:FontDescription
private var ef:ElementFormat
private var te:TextElement
protected var st:String;
private var scene:Scene3D
private var view:Viewport3D
private var camera:Camera3D
private var render:BasicRenderEngine
private var vpWidth:Number = stage.stageWidth;
private var vpHeight:Number = stage.stageHeight;
private var text3d:Text3D
private var font3d:Font3D
//private var font:HelveticaBold
private var textMaterial:Letter3DMaterial
private var text:String
public function Main():void {
if (stage)
init();
else
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// rtl block
fd = new FontDescription ()
ef = new ElementFormat (fd)
te = new TextElement ("?????? ?????? ???? ?????? ?? papervision", ef)
text = te.text
//3d block
scene = new Scene3D ()
view = new Viewport3D (vpWidth,vpHeight,true,true,false,false)
camera = new Camera3D ()
render = new BasicRenderEngine()
addChild (view)
this.addEventListener (Event.ENTER_FRAME , renderThis)
textMaterial = new Letter3DMaterial(0xFF0000,1)
font3d = new HelveticaBold()
text3d = new Text3D (text, font3d, textMaterial)
scene.addChild (text3d)
}
protected function renderThis(e:Event):void
{
text3d.rotationY +=5
render.renderScene(scene,camera,view)
}
}
}
如果相关的话:我正在使用 FlashDevelop。
关于可能导致此问题的原因,或者我如何解决它,有什么想法吗?
My code is generating the following error (it is supposed to make a 3D right-to-left text animation with PaperVision):
[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.
However, this error only appears when I enter right-to-left
oriented text. When I use English text, I get no error.
Here is my code:
package {
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.scenes.Scene3D
import org.papervision3d.view.Viewport3D
import org.papervision3d.cameras.Camera3D
import org.papervision3d.render.BasicRenderEngine
import org.papervision3d.typography.Font3D
import org.papervision3d.typography.fonts.HelveticaBold
import org.papervision3d.typography.Text3D
import org.papervision3d.materials.special.Letter3DMaterial
import flash.text.engine.FontDescription
import flash.text.engine.ElementFormat
import flash.text.engine.TextElement
import flash.text.engine.TextBlock
import flash.text.engine.TextLine
/* @author vahid */
public class Main extends Sprite {
private var fd:FontDescription
private var ef:ElementFormat
private var te:TextElement
protected var st:String;
private var scene:Scene3D
private var view:Viewport3D
private var camera:Camera3D
private var render:BasicRenderEngine
private var vpWidth:Number = stage.stageWidth;
private var vpHeight:Number = stage.stageHeight;
private var text3d:Text3D
private var font3d:Font3D
//private var font:HelveticaBold
private var textMaterial:Letter3DMaterial
private var text:String
public function Main():void {
if (stage)
init();
else
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// rtl block
fd = new FontDescription ()
ef = new ElementFormat (fd)
te = new TextElement ("?????? ?????? ???? ?????? ?? papervision", ef)
text = te.text
//3d block
scene = new Scene3D ()
view = new Viewport3D (vpWidth,vpHeight,true,true,false,false)
camera = new Camera3D ()
render = new BasicRenderEngine()
addChild (view)
this.addEventListener (Event.ENTER_FRAME , renderThis)
textMaterial = new Letter3DMaterial(0xFF0000,1)
font3d = new HelveticaBold()
text3d = new Text3D (text, font3d, textMaterial)
scene.addChild (text3d)
}
protected function renderThis(e:Event):void
{
text3d.rotationY +=5
render.renderScene(scene,camera,view)
}
}
}
In case it is pertinent: I am using FlashDevelop.
Any ideas as to what might be causing this issue, or how I can get around it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,我认为 helvetica-bold 并不包含您要显示的 unicode 字符。刚刚偶然发现这篇文章< /a>,还没有深入检查它,但如果没有阿拉伯语 Font3D 扩展,这个想法似乎很有趣......
I reckon helvetica-bold doesn't unfortunately contain the unicode characters you're trying to show. Just stumbled on this post, haven't checked it in depth but the idea seems interesting in case there is no arabic Font3D extension ...