  | | | Scoping problem within Class: passing result of onLoad event to pr | Scoping problem within Class: passing result of onLoad event to pr 2004-03-14 - By L A I V E R D
Back Hi everybody,
I'm trying to create an online status check for a standalone application. Assuming the best (let alone a third party app) solution would be to actually retrieve a file, this is what I have:
class Test{ private var online:Boolean; private var onlineURL:String = "http://www.laiverd.com/groundzero/online/online.txt"; // constructor function Test() { appIsOnline = checkOnline(); // return value from checkOnline never arrives } // functions public function checkOnline() { var onlineCheck_lv:LoadVars = new LoadVars(); var success:Boolean; onlineCheck_lv.onLoad = function(success) { if (success) { trace("success = " + success); // trace is correct return true; } else { trace("success = " + success); // trace is correct return false; } // delete success; // delete this; }; onlineCheck_lv.load(onlineURL + "?nocacheVar=" + Math.random()); // probably some way of returning the onLoad event should appear here, but how so that it is within the scope of the function? } // setters function set appIsOnline(val:Boolean) { online = val; } // getters function get appIsOnline() { return online; } }
The property 'online' never gets set using its setter appIsOnline. The problem I think is somewhere in the fact that I am creating a new instance of the LoadVars object of which 'succes' is a property. That small part works. Question is; how do I get the value of 'success' passed on to the property online using the setter appIsOnline. I've also been trying to do things with onEnterFrame as the onLoad is asynchronous, but couldn't get that to work either. I am obviously missing some scoping knowledge, and as this has been bothering me for a couple of hours now, I hope you can free me from running in circles.
Thanks.
John
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Supported by Fig Leaf Software =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Be sure to check the archives and the wiki: http://chattyfig.figleaf.com/ =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106888 =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe send a blank e-mail to: Normal Mode: flashcoders-unsubscribe@(protected) Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|
 |