Super SWF Tracker-skillfully using localconnection code _flash as

Source: Internet
Author: User
Trace in Flash can only be tracked in the Flash IDE, if you publish the SWF to the Internet, you can not see trace debugging information, this to the development of network Flash brought about the difficulties of debugging, there is no good way to solve this problem, regardless of the SWF published to where, Open a local SWF tracker to receive debug messages that would be nice, because I tried various methods, from the Sharedobject local object to the remote object to the LocalConnection method all tried again (using LocalConnection is from breeze A "secret" found in AddIn, feeling snow gave me a hint to discover the "mysteries" of which to use the following class in a SWF that needs 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 use of the method is very simple, that is jtracer.trace ("I will try!");
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 need to put a component textarea name Msg_ta, used to display tracking messages!

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.