I have 2 classes, Display holds the currently selected Component:
public class Display
{
public static var selectedComponent:Component;
}
Component has an ID string and the selectedComponent variable is set on click:
public class Component extends MovieClip
{
public var id:String;
addEventListener(MouseEvent.CLICK, function() {
Display.selectedComponent = this;
});
}
I now want to be able to set the ID using Display.selectedComponent.id = "test";
The problem I have is a conversion error:
TypeError: Error #1034: Type Coercion failed: cannot convert global@4693041 to Component.
Removing the selectedComponent variable type so it reads public static var selectedComponent; removes the conversion error and seems to change the ID variable but it appears to only be a copy of the object.
Any suggestions?
Thanks