Super SWF tracker-code for clever use of LocalConnection
Source: Internet
Author: User
The trace in FLASH can only be tracked and seen in flash ide. If you publish SWF to the Internet, you will not be able to see the trace debugging information, which makes debugging difficult for the Development Network FLASH, is there a good way to solve this problem? No matter where SWF is published, it is not good to open a local SWF tracker to receive debugging messages, because I tried various methods, the method from the local object of mongodobject to the remote object to LocalConnection is tried again (using LocalConnection is a "secret" found from Breeze AddIn, I feel SNOW gave me a prompt, find the "mystery"), and use the following class in the SWF to be debugged:
Class fj. util. JTracer {
Public static var debug: Boolean = true;
Private static var _ instance: JTracer;
Private var _ lc: LocalConnection;
Private function JTracer (){
This. _ lc = new LocalConnection ();
This. _ lc. allowDomain = function (domain: String): Boolean {
Return true;
}
}
Public static function trace (msg: Object): Void {
If (! JTracer. debug ){
Return;
}
If (JTracer. _ instance = undefined ){
JTracer. _ instance = new JTracer ();
}
JTracer. _ instance. traceMsg (msg );
}
Private function traceMsg (msg: Object): Void {
Trace (msg );
This. _ lc. send ("localhost: trace", "trace", this. _ lc. domain (), msg );
}
}
The method is simple, that is, JTracer. trace ("let me try it! ");
The code in the SWF tracker is as follows:
Import fj. util. JDelegate;
Class view. JDebug {
Private var _ ui: MovieClip;
Private var _ lc: LocalConnection;
Function JDebug (ui ){
This. _ ui = ui;
This. init ();
}
Private function init (){
This. _ lc = new LocalConnection ();
This. _ lc. allowDomain = function (domain): Boolean {
Return true;
}
This. _ lc. connect ("trace ");
This. _ lc. trace = JDelegate. create (this, onTrace );
}
Private function onTrace (domain: String, msg: Object ){
This. _ ui. msg_ta.text + = domain + ":" + msg + "\ n ";
}
}
This requires a component named msg_ta, TextArea, to display tracing messages!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.