Jump to content
Search Community

Flex, null object reference [SOLVED]

vincent test
Moderator Tag

Recommended Posts

Hi there,

 

I have created a Flex project and I want use the transform manager but I have a probleme when I have tried to move object.

 

	var manager:TransformManager = new TransformManager();
       // instance a new mxml canvas object
var cont:IObject = new SimpleCanvas() as IObject;
anotherCanvas.addChild(cont as DisplayObject);
manager.addItem(cont as DisplayObject);

 

The simpleCanvas (an image in my example) is displayed but when a event occurs : (matrix is null)

 

public static function getDirectionX($m:Matrix):Number {
    var sx:Number = Math.sqrt($m.a * $m.a + $m.b * $m.;

Main Thread (Suspended: TypeError: Error #1009: Cannot access a property or method of a null object reference.)	
gs.transform.utils::MatrixTools$/getDirectionX	
gs.transform::TransformManager/renderSelection	
gs.transform::TransformManager/setOrigin	
gs.transform::TransformManager/centerOrigin	
gs.transform::TransformManager/updateSelection	
gs.transform::TransformManager/onSelectItem	
flash.events::EventDispatcher/dispatchEventFunction [no source]	
flash.events::EventDispatcher/dispatchEvent [no source]	
gs.transform::TransformItem/set selected	
gs.transform::TransformManager/onMouseDownItem	
flash.events::EventDispatcher/dispatchEventFunction [no source]	
flash.events::EventDispatcher/dispatchEvent [no source]	
gs.transform::TransformItem/onMouseDown	

 

Any help will be really appreciate

 

Thanks

Link to comment
Share on other sites

Hum, but my SimpleCanvas is a mxml canvas :

 

and when I read the canvas documentation, the Inheritance tree show me that DisplayObject is present.

http://livedocs.adobe.com/flex/3/langre ... anvas.html

 

To be sure, I make the previous test without any cast (IObject)

 

 var manager:TransformManager = new TransformManager();
       // instance a new mxml canvas object
  var cont:DisplayObject = new SimpleCanvas();
  anotherCanvas.addChild(cont);
  manager.addItem(cont);

 

The problem persists.

 

Thanks

Link to comment
Share on other sites

cont.transform.matrix is always null. But matrix3D is set !

 

If the matrix property is set to a value (not null), the matrix3D property is null. And if the matrix3D property is set to a value (not null), the matrix property is null.
For all three-dimensional objects, a Matrix3D object is created automatically when you assign a z value to a display object.

 

I have removed a property on my mxml and now it's works !!

 

Thanks for your help

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...