2 Replies Latest reply on Aug 24, 2010 5:56 AM by mkcerusky

    Accessing instances of a custom class that extend Box




      forgive me if I couldn't find an answr to my question with various searches in the forum, but I am not an expert and I have difficulties even in finding the right words for searching.


      Here is the problem:


      I created a class (named LAlgExpression) that extends the class Box. Instances of the class are added into a Box, and I tried to access such instances using mouse events.

      Now, I can actually access the instances of my custom class using the target and currentTarget properties of events, but unfortunately they are seen as belonging to the class Object and not to the class LAlgExpression which make impossible to use all the methods I defined for LAlgeExpression because the compiler tell me that I am trying to use on an Object a method that is not defined for the class Object. What is funny is that  at runtime when I try "event.target is LAlgExpression" it returns true, but I don't know how to convince the compiler   .It is as if the instance I have on the screen is both an Object and a LAlgExpression but the compiler won't let me treat as LAlgExpression but only as Object and I do not understand why.


      is there a way to force the compiler to see as LAlgExpression something that it sees as an Object?



      Thanks very much in advance for your help