我的代码生成以下错误(它应该使用PaperVision制作3D从右到左的文本动画):
[Fault] exception,information = TypeError:错误#1009:无法访问空对象引用的属性或方法。
但是,只有在我输入right-to-left
面向文本时才会出现此错误。当我使用英文文本时,我没有错误。
这是我的代码:
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。
关于可能导致此问题的原因,或者我如何解决这个问题的任何想法?
答案 0 :(得分:1)
我认为helvetica-bold不幸地包含了你想要展示的unicode角色。刚刚偶然发现this post,没有深入检查它,但如果没有阿拉伯语Font3D扩展,这个想法似乎很有意思......