C # program with flash interface

xiaoxiao2021-03-06  89

With reference to SourceForge's open source project, data transmission uses WDDX methods to serialize objects and its attributes, and the receiving end is subjected to serialization of the corresponding data.

Pre {Font-Family: "Courier New", Courier, Arial; font-size: 12px;}

. galan {color: # 000000;

. readyword {color: # 993300;

.IDENTIFIER {color: # 000087;

.properties {color: # 000087;

{Color: # 000087;

.LINECMMMENT, .BLOCKCOMMENT {Color: # 808080;

. String {color: # 0000ff;}

// ******************************************************** *****************************

// ______

// .- "" -.

// / aol /

// | |

// |, .-. .-., |

// |) (__ / / __) (|

// | / // / |

// (@_ (_ ^^ _)

// _) / _______ / __ | iiiiii | __ / _________________________

// (_) @ 8 @ 8 {} <________ | - / iiiiii / - | __________________________>

//) _ / / /

// (@ `--------` aol flash studio.

// ******************************************************** *****************************

@FileName Sharpflash.as

@Package sharpflash

@Description C # Program with Flash Interaction Interface, using Singleton mode, only one interface is allowed

@Author AOL

@Email jeremy1982@21cn.com

@Create 2004.10.10

@Lastchange 2004.10.11

@History

// ******************************************************** *****************************

Class Sharpflash.Sharpflash

{

Private static var _INstance: Sharpflash

Public static function get instance (): Sharpflash

{

// trace (_instance);

IF (_Instance == null)

{

_INSTANCE = New Sharpflash ();

}

Return_INSTANCE;

}

///

Private var_data: string;

PRIVATE VAR WATCH: FUNCTION;

Private var wddx: wddx;

Private var callbacklist: array; // Constructor

Private function sharpflash ()

{

WDDX = New WDDX ();

this.watch ("Data", OnData);

}

// Attribute DATA, assigns a value by C #, Flash monitors its value change

Public Function Get Data (): String

{

Return_Data;

}

Public Function SET DATA (Value: String): Void

{

_DATA = VALUE;

}

// Data change process method

Function OnData (Prop: String, OldVal: String, NewVal: String)

{

// _Root.Result.text = newval;

VAR XML: XML = New XML ();

Xml.Parsexml (NewVal);

Var response_xml: XMLNode = Xml.firstchild.FirstChild;

// Tune function ID

VAR TMP: XMLNode = response_xml.childnodes [0] .firstchild;

// Callback function There is one or two parameters in this node

/ / Can derive the number of parameters by resolving the Arg node of the package sent from the C # side

Var argcount: Number = response_xml.childNodes [1] .childnodes.length

// _Root.Result.text = argcount;

Switch (argcount)

{

Case 1:

Var arg1_wddx_xml: XML = New XML ();

Arg1_wddx_xml.parsexml (response_xml.childnodes [1] .childnodes [0] .firstchild);

Var funcargs = new array (1);

Funcargs [0] = WDDX.DSERIALIZE (arg1_wddx_xml);

// carried out

Callbacklist [TMP] .callback.Apply (CallbackList [TMP]. Scope, Funcargs);

// debug code:

// _Root.Result.text = "1 arg results: [0] =" funcargs [0];

Break;

Case 2:

Var arg1_wddx_xml: XML = New XML ();

Arg1_wddx_xml.parsexml (response_xml.childnodes [1] .childnodes [0] .firstchild);

Var arg2_wddx_xml: XML = New XML ();

Arg2_wddx_xml.parsexml (response_xml.childnodes [1] .childnodes [1] .firstchild);

Var funcargs: array = new array (2);

Funcargs [0] = WDDX.DSERIALIZE (arg1_wddx_xml);

Funcargs [1] = WDDX.DSERIALIZE (arg2_wddx_xml);

// carried out

Callbacklist [TMP] .callback.Apply (CallbackList [TMP]. Scope, Funcargs);

// debug code:

//_root.result.text = "2 arg results: [0] =" funcargs [0] "/ n [1] =" funcargs [1];

DEFAULT:

Break;

}

}

}

A small example, by C # derive the path where the current program is located.

转载请注明原文地址:https://www.9cbs.com/read-108126.html

New Post(0)