PDA

View Full Version : What am I missing?



Didi32
August 30th, 2008, 02:46 PM
Hi, could someone please explain me why this listener does not work for the following function - I guess there is something I do not understand about listeners - how do you listen to a function to know when it has been completed? It works properly if I call the login() function from the end of the applyNumbers function. :(



var numbersLoader = applyNumbers(deck[i].name,i);
numbersLoader.addEventListener(Event.COMPLETE, login);
function applyNumbers(vary,i) {
if (vary == cardNumber[1]) {
fstNum = theDeck.symbol[i];
}

if (vary == cardNumber[2]) {
sndNum = theDeck.symbol[i];
}

if (vary == cardNumber[3]) {
thdNum = theDeck.symbol[i];
}

if (vary == cardNumber[4]) {
fothNum = theDeck.symbol[i];
}

if (vary == cardNumber[5]) {
fthNum = theDeck.symbol[i];
}

if (vary == cardNumber[6]) {
sixNum = theDeck.symbol[i];
}

if (vary == cardNumber[7]) {
seventhNum = theDeck.symbol[i];
}
}

function login(e:Event):void {
// THIS DOESN'T LOAD
}
Thanks!

Pier25
August 30th, 2008, 02:59 PM
You can't add event listeners to a function...

To call another function when it has finished execution just call it at the end...



function my_funk(){
// bla bla bla do your stuff

my_other_funk();
}

function my_other_funk(){
trace("james brown is in the house");
}