views:

142

answers:

1

Hi!

I am writing a simple application which communicates with web services a lot.

So I am listening for success and fault events very often. When service returns a fault, I show an alert to a user saying something like: "Sorry there was a problem with a service, we will try to call it later"

But there is a problem. When user didn't notice an alert, and service is still dead before the second call the alert will be shown again, and again and again (so There will be very many alert objects which is bad)

I want to make alert a kind of singleton. So I am trying to produce a class something like

import mx.controls.Alert;

public class SingleAlert extends Alert
{
 public static var count:Number = 0;

 public function SingleAlert()
 {
  super();
 }
 override public static function show():void
 {
  if(count = 0){
   super.show();
                            counter += counter;

  } 
 }
}

Actually I have few problems. And can't finish the class...

I don't understand how to call show function (e.g. how to pass a string to it), also how to check the situation when user closes alert box. In this case I should show a new one.

Please help me to implement the class. Thanks

A: 

Static methods are not inherited in ActionScript. Your best bet is to write a class which delegates to the Alert class' static methods. It can also have a private static var which holds the "current" Alert dialog instead of a "count" variable.

Also in your code you are confusing the assignment operator (single equal sign) with the equality operator (double equal sign).

cliff.meyers
Thanks. Agree. Already fixed locally
Oleg Tarasenko