I'm having some frustrating problems with scope in trying to author some classes. Basically, how do I get a value which is nested in a function, returned to update the value of a given property? I've got several functions nested inside a public function which includes function literals. In the following code I just want to be able to have the returnBW function update the value of the vidQuality property. But I can't figure out how to return it? Any knowledge?

thanks.

class classes.CheckBW {
        var nc:NetConnection;
        var ns:NetStream;
        var whichServer;
        var counter;
        var vidQuality:String;
        public function bwCheck(whichServer):Void{
                nc = new NetConnection();
                nc.onStatus = function(info) {
                        trace("Level: "+info.level+" Code: "+info.code);
                        NetConnection.prototype.onBWDone = function(p_bw) {
                                trace("onBWDone: "+p_bw);
                                if (p_bw != undefined) {
                                        returnBW(p_bw);
                                }
                        };
                        function returnBW(p_bw) {
                                trace("returnBW called");
                                if (p_bw>=400) {
vidQuality = "_med";
                                } else if (p_bw<400 && p_bw>=150) {
vidQuality = "_low";
                                } else if (p_bw<150) {
vidQuality = "_low";
                                }
                        }
                        NetConnection.prototype.onBWCheck = function() {
                                return ++counter;
// Serverside, just ignore any return value and return the call count
                        };

                };
                nc.connect(whichServer);
                nc.call("checkBandwidth", null);


        }

}

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to