惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
博客园 - 【当耐特】
小众软件
小众软件
博客园 - Franky
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
雷峰网
雷峰网
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
Last Week in AI
Last Week in AI
博客园_首页
月光博客
月光博客
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
Stack Overflow Blog
Stack Overflow Blog
腾讯CDC
云风的 BLOG
云风的 BLOG
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Recent Commits to openclaw:main
Recent Commits to openclaw:main
D
Docker
The Last Watchdog
The Last Watchdog
有赞技术团队
有赞技术团队
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
DataBreaches.Net
S
Security @ Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
TaoSecurity Blog
TaoSecurity Blog
S
Security Affairs
Y
Y Combinator Blog
O
OpenAI News
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
K
Kaspersky official blog
Cloudbric
Cloudbric

博客园 - 布瓜去旅行

适时放手,是对自己的尊重 PhoneGap初试! 【转】Swift之 ? 和 ! 一场空欢喜 不要悲伤,我亲爱的好姑娘 更新证书错误:No matching provisioning profiles found CABasicAnimation的基本使用方法(移动·旋转·放大·缩小) ASP.NET中解决跨子域的Session共享 iPhone4S出现应用无法打开时的解决方案 [转] XCode 4.2 新功能 - Storyboard [摘] Objective-C的self.用法的一些总结 IE6中正确显示png图片 【转】DD_belatedPNG,解决IE6不支持PNG绝佳方案 IE6中margin值双倍的解决方案 [转] 弹性+固宽布局 Windows2003下配置PHP环境 去除Visual Studio .NET工程同SourceSafe的关联 遭遇价格欺诈 塑料瓶底的标志的含义!
C# winform 与 flash as 的交互通讯
布瓜去旅行 · 2011-08-24 · via 博客园 - 布瓜去旅行

出处:

http://blog.csdn.net/lifesoftware/article/details/5389265

http://www.cnblogs.com/naiking/archive/2009/01/14/1375771.html

1、添加组件
  打开VS2008,工具-选择工具箱项-COM组件,勾选Shockwave Flash Object,确定。

2、将Flash组件放入窗体中
  将工具箱中的Shockwave Flash Object组件拖放到窗体中,设置其属性。

3、as代码

import flash.external.ExternalInterface;//向C#发送数据
if (ExternalInterface.available)
{
    
var strResult:String = ExternalInterface.call("userValidate", userid, password);
}
//接收C#返回的结果
if (ExternalInterface.available)
{
    ExternalInterface.addCallback(
"userValidate", userValidate);
}
//根据C#返回的结果处理
public function userValidate(str:String):void
{
    trace(str);
}

4、c#代码

public mainForm()
{
    InitializeComponent();
    mainFlash.Movie 
= Application.StartupPath + "\\swf\\DayBook.swf";//设置flash地址
    mainFlash.Menu = false;
    mainFlash.FlashCall 
+= new AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEventHandler(mainFlash_FlashCall);
}
private void mainFlash_FlashCall(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEvent e)
{
    XmlDocument document 
= new XmlDocument();
    document.LoadXml(e.request);
    XmlAttributeCollection attributes 
= document.FirstChild.Attributes;// 获取函数名
    String command = attributes.Item(0).InnerText;// 获取参数
    XmlNodeList list = document.GetElementsByTagName("arguments");
    
int count = list[0].ChildNodes.Count;//参数数量
    string[] arr_paras = new string[count];
    
//处理参数
    for (int i = 0; i < count; ++i)
    {
        arr_paras[i] 
= list[0].ChildNodes[i].InnerText.ToString();
    }
switch (command)
    {
       
case "userValidate":
             userValidate(arr_paras, 
"userValidate");
             
break;
       
case "getPeopleList":
             getPeopleList(arr_paras, 
"getPeopleList");
             
break;
    
     }
}
//C#传给Flash的值
private void callFunction(string funName, string arg)
{
    
//funName:调用as中的函数
    
//arg:参数
    mainFlash.CallFunction("<invoke name=\"" + funName + "\" returntype=\"xml\"><arguments><string>" + arg + "</string></arguments></invoke>");
}
//登录验证
public void userValidate(string[] arr_data, string functionName)
{
    
string password = arr_data[1];
    password 
= OperClass.Encrypt(password, 1);
    
string sql = "select id,username from users where state='0' and userid=" + OperClass.str(arr_data[0]) + " and password=" + OperClass.str(password);
    DataSet ds 
= dbc.ExecuteSqlDsForAccess(sql, "info");string result = "";
    
if (ds != null && ds.Tables["info"].Rows.Count > 0)
    {
        result 
= ds.Tables["info"].Rows[0]["id"].ToString() + "" + ds.Tables["info"].Rows[0]["username"].ToString();
    }
    
else
    {
        result 
= "-1";
    }
    callFunction(functionName, result);
}