I made an fxg file using Inkscape and the fxg plugin. It is called BugattiVeyron.fxg
I also created AS3 project using flex sdk 4.6 and FlashDevelop 4 and import this file using the import statement like this
import BugattiVeyron;
and instantiate it like this
private var bugatti:BugattiVeyron = new BugattiVeyron ();
Using the build button in FD4 does not give any errors, but when i run it I get this error although when I dismiss all the errors the file is beign imported well and I can add events to it.
the error:
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]
so i get this error but the file is imported after I dismiss the errors.
what could be the problem, any idea?
I struggled with this issue myself and finally figured out how to get it working. There are two ways.
Your FXG file needs to be in the same directory as your Main.as in order to call it like this:
import BugattiVeyron;
But or course if you have your image assets in another folder you will have to set a class path in your project in order to reference the FXG file. Obviously we can't access the FXG file in another directory like this:
import ../lib/BugattiVeyron
If you right click on your project in FlashDevelop and click on Properties from the context menu you will be able to add your directory of choice as a classpath in order to access your FXG file. In my case I added lib as a classpath for the project. This enabled me to import my asset like you previously tried doing.
import BugattiVeyron;
public class Main extends Sprite {
var bugatti:BugattiVeyron = new BugattiVeyron();
..some code here...
}
Hope this helps, I struggled for a week trying to figure this out.