PDA

View Full Version : variable access


gosiaisean
05-27-2010, 03:30 PM
How to access var from one function and use it in the other. Example:

function onee(){
var i:int = nodeXml.node.length();
}


And now trace it in here:

trace(i);

I know that if you have a packages you can use public or sth like that, but it doesnt work with the code on the actions frame.

Thanx

sparX
05-27-2010, 08:32 PM
var i:int;

function onee ():void {
i = nodeXml.node.length();
}

function twoe ():void {
trace(i);
}

or

function onee ():void {
var i:int = nodeXml.node.length();
twoe(i);
}

function twoe (i:int):void {
trace(i);
}

or

function onee ():int {
var i:int = nodeXml.node.length();
return i;
}

function twoe ():void {
var i:int = onee();
trace(i);
}

gosiaisean
05-27-2010, 08:43 PM
Thank you. You are very helpfull to me lately.