  | | Re: [Flashcoders] Scoping problem within Class: passing result of
onLoad event | Re: [Flashcoders] Scoping problem within Class: passing result of
onLoad event 2004-03-14 - By Helen Triolo
Back See this: http://chattyfig.figleaf.com/flashcoders-wiki/index.php?ScopingCallbacksAS2 (thanks to Jonas)
Helen
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Owner, i-Technica (http://i-technica.com) Web Design, Flash for Websites & CD's, Web Database Applications ph: 301.424.6037, fax: 305.723.8546, email: info@(protected) Flash resource site: http://actionscript-toolbox.com
L A I V E R D wrote:
>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) > > > >
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- 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:106890 =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe send a blank e-mail to: Normal Mode: flashcoders-unsubscribe@(protected) Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|
 |