Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

Class scope

 
Jump to:  
 
tegnegi
PostPosted: Fri Aug 22, 2008 2:18 pm    Post subject: Class scope
       
I just cant understand how can we retrieve the private variables of a class
through other class. To explain in detail i ve 2 class files Person and
Person2. Here is the code inside them.

Person.as class file

class Person {
private var fn:String;
private var ln:String;
function Person() {
fn = "myFirstName";
ln = "myLastName";
}
}



Person2.as class file

class Person2 {
private var root:MovieClip;
function Person2(mov) {
root = mov;
trace(root.pObj.fn);
}
}


The fla file that calls the class has this code on its first frame:

var pObj:Person=new Person()
trace(pObj.fn)
var p2:Person2=new Person2(this) //myFirstName


My question is how Person2 class can access Person class private variable.
 

 
kglad
PostPosted: Fri Aug 22, 2008 5:02 pm    Post subject: Re: Class scope
       
it can't. you haven't set it up for that.

person2 instances have no access to person instances and fn and ln are properties of person instances.
 

 
tegnegi
PostPosted: Wed Aug 27, 2008 5:23 am    Post subject: Re: Class scope
       
But if you take the code and try it does happen as i ve mentioned. Moreover
pObj is Person2 instance and not Person1 instance, but even then Person2
instance cant have access to its class private variables. Why is it happening
here? I ll suggest you to try it.
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

Kredyty Mieszkaniowe Banki Odzyskiwanie danych zaproszenia ślubne warszawa pierścionek zaręczynowy Pozycjonowanie