#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2006
    Posts
    18
    Rep Power
    0

    Getting a class' variables from another class


    I need to access a variable that exists in class B from class A.

    For example:

    Code attached to frame 1:
    Code:
      import ClassA.as;
      var Person = new ClassA();
    
      Person.FirstName = "Franz";
      Person.NoNeed.init("Ferdinand");
    ClassA:
    Code:
      var FirstName:String;
      var NoNeed = new ClassB();
    ClassB:
    Code:
      var FullName:String;
      public function init(Surname:String){
        FullName = ClassA.FirstName + " " + Surname;
      }
    The problem lies at ClassB.init() - FullName = ClassA.FirstName + " " + Surname

    How do I access ClassA.FirstName from ClassB.init()?
    FullName = _parent.Person.FirstName + " " + Surname does not work.

    Any ideas?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2006
    Posts
    18
    Rep Power
    0
    Found the answer on another page

    FullName = _root .Person.FirstName + " " + Surname does work.

IMN logo majestic logo threadwatch logo seochat tools logo