PDA

View Full Version : Extracting a variable


confused.com
08-12-2009, 10:08 AM
Hi,

Apologies as I'm very new to AS3 so this might be a daft question.

I have written code to find a user's bandwidth in a file called Client.as. The basis of this code is:

package CIS.FLVPlayer
{
class Client {
public function onBWCheck(... rest):Number {
return 0;
}
public function onBWDone(... rest):Number {
var p_bw:Number;

if (rest.length > 0)
{
p_bw = rest[0];
return p_bw;
} else {

return 0;
}
}
}

}

I want to basically return this value p_bw in my Main.as file and have used the following code to do this:

public var client:Client = new Client();
public function getCurrentBandWidth():Number
{
return client.onBWDone();
}

But when I call this in javascript, no bandwidth comes up. I checked using trace and I am getting a value through.

I have a feeling I might need to put p_bw outside of the function, because I think it only exists while onBWDone is being called...but how on earth do I do this?! All my attempts don't seem to work...

Thank you!

attunedesigns
08-12-2009, 01:17 PM
Youve done everything right, you just need to make the Client class public. If you dont specify, it is 'internal'. Try that!