有些flash小游戏网站,玩过游戏后,得到的积分可以提交到网站上,获得排名或者积分,换取一些东西等等 不知道这个积分是如何提交上去的?自己的网站如何实现这种提交? 有没有什么教程? 谢谢各位大虾的帮助

解决方案 »

  1.   

    这个涉及到flash与后台的交互,如与asp asp.net php的交互,flash里的actionscript主要是通过loadvars和xml两个类进行交互的,你可以看看flash的帮助文档
      

  2.   

    楼上说的很清楚了
    主要是flash对用户数据进行提交
      

  3.   

    在flash中写个方法把积分传送到指定的页面处理存到数据库。
    AS代码:function SaveScore()
    {
    var Score = new LoadVars();
    Score.score = 123;//积分值
    var num:Number = Math.random()*10;
    Score.sendAndLoad("http://www.xxxgame.com/SaveScore.aspx?score=" + num, Score, "POST");
    Score.onLoad = function(success)
    {
    if (success)
    {
    msg.text = "保存积分成功!";
    } else
    {
    msg.text = "保存积分失败!";
    }
    };
    }
    服务端用Request["score"]得到传上来的值,然后保存clickBtn.onRelease = function()
    {
    msg.text = "正在保存积分……"
    SaveScore();
    };
      

  4.   

    刚好做了一个这样的flash积分,只要你提供2个url就行了,第一个url是传用户标识给flash,第二个url是保存积分的url,flash返回你提供的用户标识和积分,程序接收,写入数据库
      

  5.   

    SetUserId.ashx代码:
    namespace BBS
    {
        /// <summary>
        /// Summary description for $codebehindclassname$
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        public class SetUserId : IHttpHandler , System.Web.SessionState.IRequiresSessionState
        {        public void ProcessRequest(HttpContext context)
            {
                context.Response.Buffer = true;
                context.Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
                context.Response.Expires = 0;
                context.Response.CacheControl = "no-cache";
                context.Response.ContentType = "text/plain";
                if (Mode.Global.CurrentUser != null)
                    context.Response.Write("UserID=" + Mode.Global.CurrentUser.Id.ToString() + "&Result=OK&");
            }        public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
      

  6.   

    获取积分的url:GetIntegral.ashx
    namespace BBS
    {
        /// <summary>
        /// Summary description for $codebehindclassname$
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        public class GetIntegral : IHttpHandler,System.Web.SessionState.IRequiresSessionState
        {
            long userid;
            int integral;
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
                context.Response.Buffer = true;
                context.Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
                context.Response.Expires = 0;
                context.Response.CacheControl = "no-cache";
                context.Response.ContentType = "text/plain";
                long.TryParse(context.Request.Form["UserID"], out userid);
                int.TryParse(context.Request.Form["Score"], out integral);
                if (this.integral <= 30)
                {
                    try
                    {
                        DataAccess.UserInfoDataAccess.AddFlashGameIntegral(this.userid, this.integral);
                        context.Response.Write("Result=OK&");
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }        public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }