Kuma
11-20-2004, 06:06 PM
Hi,
I'm having a little trouble with setting a variable via a getter and setter.
Basically I want to store a reference to my current selection, so that I can reset it to a previous state later in the code
But for some reason my lastSelection is always returning undefined
Could someone explain what is going on and how I could fix it please?
Thanks.
var currSelection;
var lastSelection;
function getSelectionData(){
var selected = fl.getDocumentDOM().selection[0];
if(selected!=undefined && (fl.getDocumentDOM().selection.length == 1)){
if(getLastSelection() != undefined){
resetSymbol();
}
// store reference to current selection
setCurrSelection(selected);
setLastSelection(selected);
}
// I have omitted the rest of the code
}
//
// ------------------------------------------------
// GETTERS AND SETTERS
// ------------------------------------------------
//
function setLastSelection(val){
lastSelection = val;
fl.trace("setLastSelection("+val+")")
}
//
function getLastSelection(){
fl.trace("getLastSelection(): "+lastSelection)
return lastSelection;
}
//
// ------------------------------------------------
//
function setCurrSelection(val){
currSelection = val;
}
//
function getCurrSelection(){
return currSelection;
}
I'm having a little trouble with setting a variable via a getter and setter.
Basically I want to store a reference to my current selection, so that I can reset it to a previous state later in the code
But for some reason my lastSelection is always returning undefined
Could someone explain what is going on and how I could fix it please?
Thanks.
var currSelection;
var lastSelection;
function getSelectionData(){
var selected = fl.getDocumentDOM().selection[0];
if(selected!=undefined && (fl.getDocumentDOM().selection.length == 1)){
if(getLastSelection() != undefined){
resetSymbol();
}
// store reference to current selection
setCurrSelection(selected);
setLastSelection(selected);
}
// I have omitted the rest of the code
}
//
// ------------------------------------------------
// GETTERS AND SETTERS
// ------------------------------------------------
//
function setLastSelection(val){
lastSelection = val;
fl.trace("setLastSelection("+val+")")
}
//
function getLastSelection(){
fl.trace("getLastSelection(): "+lastSelection)
return lastSelection;
}
//
// ------------------------------------------------
//
function setCurrSelection(val){
currSelection = val;
}
//
function getCurrSelection(){
return currSelection;
}