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

Finding return value for loop inside a function and combining

2004-03-19       - By L A I V E R D

 Back
Hi everybody,

Still working on a class that included a check for an online connection
using an online file. Although it works, I feel that the coding could be
far more efficient as now I use two methods to retrieve the value for
one property. On thing is that I am having a hard time to find a way to
return a value from a function that contains a loop in which a property
is set. Hmm; confusing? This is the setup

Private var online;

Public function checkOnlineStatus() // loads (or not) a textfile and
sets the property online; no return value (yet)
Public function pollOnline() // Polls for property online through a
getter and puts result in a textfield.

I would actually like to have one method in which the above two are
combined and that returns a value for the online status (through getter
appISOnline).

And here's the code:
/////////////////// CODE //////////////////////////////
  public function checkOnlineStatus():Void {
    var self:CDapplication = this;
    self.online = undefined;
    var onlineCheck_lv:LoadVars = new LoadVars();
    onlineCheck_lv.onLoad = function(success) {
      self.online = success;
      delete this;
    };
    onlineCheck_lv.load(onlineURL + "?nocacheVar=" +
Math.random());
  }
  public function pollOnline(displayArea:TextField):Void {
    var poll;
    var self:CDapplication = this;
    poll = setInterval(function () {
      if (self.appIsOnline) {
        self.showData(self.appIsOnline,
displayArea);
        clearInterval(poll);
      }
    }, 1000);
  }
///////////// END CODE /////////////////////////////////

Thanks for any input.

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:107443
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)