1.UI层,FLASH件:
var param1:String;
var URLpreFix:String;
//设置服务器URL文件,根据实际自定义
URLpreFix = "http://localhost:5689/flashtext/WebForm1.aspx";
bt.onRelease = function() {
//LoadVars 类是 loadVariables() 函数的替代方法,用于在 Flash 应用程序和服务器之间传输变量。
var myLoadVars = new LoadVars();
_root.onEnterFrame = function() {
if (_root.yuan.hitTest(_root.juxing)) {
txt = "<workflow></workflow>";
}
else
{
txt = "";
}
}
//txt是场景里面的一个文本变量
//把txt变量的值传给LoadVars类对象
myLoadVars.txt = txt;
//发送给服务器,可使用HTTP 协议的 GET 或 POST 方法。
myLoadVars.sendAndLoad(URLpreFix, myLoadVars, "post");
_root.lb.text="正在加载数据...";
//得到服务器是否成功返回数据,success是成功标志,成功时返回true
myLoadVars.onLoad = function(success) {
//如果成功把lb的文本换成服务器返回的变量值
if (success) {
_root.lb.text = this.txt;
} else {
_root.lb.textt = "异常错误!";
}
};
};
2.DLL层,ASPX文件:新建一“asp.net web 应用程序”,位置为http://localhost/flashtext/,然后把转到HTML设计介面,把HTML代码删除掉,只保存以下这行代码(ASP.NET是采用codebehind设计,默认VS会自动产生一些HTML代码),
3.DLL层,ASPX.cs文件:点开WebForm1.aspx.cs设计类文件,输入代码,用于Request FLASH送过来的数据而提交商业逻辑层处理,完整如下:
@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="flashtext.WebForm1" %>
这个很重要,因为如果没有删除,等一下运行,服务器会返回这些HTML代码给UI层,使之产生错误。
namespace flashtext
{/**//// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{private void Page_Load(object sender, System.EventArgs e)
{// 在此处放置用户代码以初始化页面
string txt=Request["txt"];
testClass test=new testClass();
Response.Write("&&txt=" + test.getData(txt));
}
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
// InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{ this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
4.DLL层,运行商业逻辑:新建一个新类,名为testClass.cs,用于整个demo简单的商业逻辑处理(在此你可以完全去处理与数据库相关处理等等),只返回一行数据,代码如下:
namespace flashtext
{/**//// <summary>
/// testClass 的摘要说明。
/// </summary>
public class testClass
{public testClass()
{//
// TODO: 在此处添加构造函数逻辑
// }
//方法getData()可以取得数据 public String getData(string param1)
{//假设这里去读数据了
return "这是来自aspx返回的数据:"+param1;
}
}
}




最新回复