2

Inkscapeとfxgプラグインを使用してfxgファイルを作成しました。それはBugattiVeyron.fxgと呼ばれています

また、flex sdk4.6とFlashDevelop4を使用してAS3プロジェクトを作成し、次のようなimportステートメントを使用してこのファイルをインポートします。

import BugattiVeyron;

このようにインスタンス化します

private var bugatti:BugattiVeyron = new BugattiVeyron ();

FD4でビルドボタンを使用してもエラーは発生しませんが、実行するとこのエラーが発生しますが、すべてのエラーを閉じると、ファイルは正常にインポートされ、イベントを追加できます。

エラー:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::updateCallbacks()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7345]
at mx.core::UIComponent/set nestLevel()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:4189]
at spark.core::SpriteVisualElement/http://www.adobe.com/2006/flex/mx/internal::addingChild()[E:\dev\4.y\frameworks\projects\spark\src\spark\core\SpriteVisualElement.as:2247]
at spark.core::SpriteVisualElement/addChild()[E:\dev\4.y\frameworks\projects\spark\src\spark\core\SpriteVisualElement.as:2211]
at resources::BugattiVeyron_Text_2126220941/createText()
at resources::BugattiVeyron_Text_2126220941()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at mx.core::FlexSprite()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\FlexSprite.as:61]
at spark.core::SpriteVisualElement()[E:\dev\4.y\frameworks\projects\spark\src\spark\core\SpriteVisualElement.as:88]
at resources::BugattiVeyron()[resources\BugattiVeyron-generated.as:10]

したがって、このエラーが発生しますが、エラーを閉じた後にファイルがインポートされます。

何が問題になるのでしょうか、何か考えはありますか?

4

2 に答える 2

3

私は自分でこの問題に苦労し、最終的にそれを機能させる方法を見つけました。2つの方法があります。

FXGファイルは、次のように呼び出すために、Main.asと同じディレクトリにある必要があります。

import BugattiVeyron;

ただし、もちろん、画像アセットが別のフォルダーにある場合は、FXGファイルを参照するためにプロジェクトにクラスパスを設定する必要があります。明らかに、次のような別のディレクトリにあるFXGファイルにアクセスすることはできません。

import ../lib/BugattiVeyron

FlashDevelopでプロジェクトを右クリックし、コンテキストメニューから[プロパティ]をクリックすると、FXGファイルにアクセスするために、選択したディレクトリをクラスパスとして追加できます。私の場合、プロジェクトのクラスパスとしてlibを追加しました。これにより、以前に試したようにアセットをインポートできました。

import BugattiVeyron;
public class Main extends Sprite {
  var bugatti:BugattiVeyron = new BugattiVeyron();
..some code here...
}

これがお役に立てば幸いです。私はこれを理解しようとして1週間苦労しました。

于 2012-10-24T01:00:24.603 に答える
0

<RichText>特に、FlashDevelopでAS3のみのプロジェクト(MXMLなし)からのテキスト(要素)を含むFXGをインスタンス化しようとしたときに、同じ問題が発生しました。リッチテキストを含まない他のFXGファイルを問題なくインポートして使用することができました。

正確な詳細については少しぼんやりしていますが、Flexライブラリが純粋なAS3アプリケーション用に初期化されていないため、createText()(あなたの場合は)への呼び出しの結果としてエラーが発生するようです。resources::BugattiVeyron_Text_2126220941/createText()最も簡単な解決策は、AS3ではなくMXMLでアプリケーションを定義することです。

<?xml version="1.0" encoding="utf-8"?>
<s:Application 
  xmlns:fx="http://ns.adobe.com/mxml/2009" 
  xmlns:s="library://ns.adobe.com/flex/spark" 
  xmlns:bv="*"
>
<bv:BugattiVeyron/>
</s:Application>

それ以外の

import BugattiVeyron;
public class Main extends Sprite {
  var bugatti:BugattiVeyron = new BugattiVeyron();
}

(これについては、関連する質問で詳しく説明します。[ MXMLを使用せずにFlex Framework /コンポーネントを使用できますか?。「Flex4に必要な更新」セクションを探してください。)

または、Flexライブラリの実行時のオーバーヘッドが必要ない場合は、FXGを編集してテキストをパスに変換できます。これはAS3のみのプロジェクトで機能するはずですが、同様の問題が発生した他のFXG機能があったとしてもそれほど驚かないでしょう。

于 2015-05-25T06:08:25.833 に答える