below is a sample code . how I can create a variable which is accessible in all functions like init(), next(), back() but now outside to "SlideStreamer"++++++++++++++++def ("SlideStreamer") ({ init: function(url){
var0 = url; // globle variable
this.var1 = url; //public variable
var var2 = url; //private to init only. cannot use it in next() function
}, next: function(){
alert("Public function..\nvar0 = " + var0); //"timing.xml"
alert("Public function..\nvar1 = " + this.var1); //"timing.xml"
alert("Public function..\nvar2 = " + var2); // var2 undefined here, How Can i get var2 here ???
}
});var mySlideshow = new SlideStreamer("timing.xml");
mySlideshow.next();
alert("Outside..\nvar0 = " + var0); //"timing.xml" ?? It means, var0 becomes a global variable !!
alert("Outside..\nvar1 = " + var1); // var1 undefined here
alert("Outside..\nvar2 = " + var2); // var2 undefined here
alert("Outside..\nvar0 = " + mySlideshow.var0); // var0 undefined here
alert("Outside..\nvar1 = " + mySlideshow.var1); // "timing.xml" !! It means this is a public variable
alert("Outside..\nvar2 = " + mySlideshow.var2); // var2 undefined here.
var0 = url; // globle variable
this.var1 = url; //public variable
var var2 = url; //private to init only. cannot use it in next() function
}, next: function(){
alert("Public function..\nvar0 = " + var0); //"timing.xml"
alert("Public function..\nvar1 = " + this.var1); //"timing.xml"
alert("Public function..\nvar2 = " + var2); // var2 undefined here, How Can i get var2 here ???
}
});var mySlideshow = new SlideStreamer("timing.xml");
mySlideshow.next();
alert("Outside..\nvar0 = " + var0); //"timing.xml" ?? It means, var0 becomes a global variable !!
alert("Outside..\nvar1 = " + var1); // var1 undefined here
alert("Outside..\nvar2 = " + var2); // var2 undefined here
alert("Outside..\nvar0 = " + mySlideshow.var0); // var0 undefined here
alert("Outside..\nvar1 = " + mySlideshow.var1); // "timing.xml" !! It means this is a public variable
alert("Outside..\nvar2 = " + mySlideshow.var2); // var2 undefined here.
No comments:
Post a Comment