| AzagThoth |
12.05.2010 03:04 |
Обработчик события System.onStatus() не работает
Выдержка из хелпа по CS5.
Код:
onStatus event handler
public onStatus = function(infoObject:Object) {}
Player version: Flash Player 6
Event handler: provides a super event handler for certain objects.
The LocalConnection, NetStream, and SharedObject classes provide an onStatus event handler that uses an information object for providing information, status, or error messages. To respond to this event handler, you must create a function to process the information object, and you must know the format and contents of the returned information object.
In addition to these specific onStatus methods, Flash also provides a super function called System.onStatus, which serves as a secondary error message handler. If an instance of the LocalConnection, NetStream, or SharedObject class passes an information object with a level property of "error", but you have not defined an onStatus function for that particular instance, then Flash uses the function you define for System.onStatus instead.
Note: The Camera and Microphone classes also have onStatus handlers but do not pass information objects with a level property of "error". Therefore, System.onStatus is not called if you don't specify a function for these handlers.
Parameters infoObject:Object — A parameter defined according to the status message.
Example
The following example shows how to create a System.onStatus function to process information objects when a class-specific onStatus function does not exist:
// Create generic function
System.onStatus = function(genericError:Object){
// Your script would do something more meaningful here
trace("An error has occurred. Please try again.");
}
The following example shows how to create an onStatus function for an instance of the NetStream class:
// Create function for NetStream object
videoStream_ns.onStatus = function(infoObject:Object) {
if (infoObject.code == "NetStream.Play.StreamNotFound") {
trace("Could not find video file.");
}
}
Допустим делаю так как в примере:
Код AS1/AS2:
System.onStatus = function(genericError:Object){
// Your script would do something more meaningful here
trace("An error has occurred. Please try again.");
}
Запускаю ролик на исполнение в среде разработки.
В параметрах флешки запрещаю сохранение данных на диск.
После чего по кнопке в ролике выполняется например такой скрипт:
Код AS1/AS2:
but.onRelease=function():Void{
var sh_obj:SharedObject=SharedObject.getLocal("user_name");
sh_obj.data.proverka=true;
sh_obj.data.name="Винни-Пух";
sh_obj.flush();
}
Выскакивает сообщение о том чтобы разрешить сохранение данных на диск. Нажимаю - "Запретить". Вот тут должен сработать обработчик System.onStatus(), но к сожалению - ничего не происходит.
PS: Если я беру и описываю onStatus для SharedObject, то он работает.
|