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

推荐订阅源

S
SegmentFault 最新的问题
Spread Privacy
Spread Privacy
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
腾讯CDC
P
Privacy International News Feed
Webroot Blog
Webroot Blog
J
Java Code Geeks
爱范儿
爱范儿
A
About on SuperTechFans
S
Secure Thoughts
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
DataBreaches.Net
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Latest
Security Latest
Forbes - Security
Forbes - Security
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
量子位
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
The Exploit Database - CXSecurity.com
Help Net Security
Help Net Security
V
Visual Studio Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 聂微东
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs

博客园 - 布瓜去旅行

适时放手,是对自己的尊重 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);
}