Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
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)