zoukankan      html  css  js  c++  java
  • 在Flash中结合webservice 实现无缝滚动效果

    以下是action script 2 代码:
    stop();
    import mx.services.WebService;
    import mx.services.PendingCall;
    import flash.external.ExternalInterface;
    
    Stage.scaleMode = "noScale";
    Stage.align = "TL";
    var _this:MovieClip = this;
    //web服务的服务说明地址
    var WSDL:String = "articleservice.asmx?WSDL";
    //Param是WEB服务方法中的参数值
    var Param:Object = {
    	pageSize:-1, 
    	pageIndex:1, 
    };
    //分页数据信息
    var CurrentPageSize:Number = 0;
    var PageSize:Number = 10;
    var PageIndex:Number = 1;
    var RecordCount:Number = 0;
    var PageCount:Number = 0;
    //图片数组和按钮数组
    var Articles:Array = new Array();
    var article_pos:Number = 0;
    //新闻滚动框
    var view_box:MovieClip = _this.createEmptyMovieClip("view_box",_this.getNextHighestDepth());
    with(view_box)
    {
    	_x = 100;
    	_y = 90;
    }
    //新闻滚动框遮罩
    var view_mask:MovieClip = _this.createEmptyMovieClip("view_mask",_this.getNextHighestDepth());
    with(view_mask)
    {
    	beginFill(0xFF0000);
    	movieTo(0,0);
    	lineTo(210,0);
    	lineTo(210,30);
    	lineTo(0,30);	
    	endFill();
    	_x = 100;
    	_y = 90;
    }
    view_box.setMask(view_mask);
    //加载loading效果动画
    var loading:MovieClip = view_box.attachMovie("loading","loading",view_box.getNextHighestDepth());
    with(loading)
    {
    	_x = (view_mask._width - _width)/2;
    	_y = (view_mask._height - _height)/2;
    }
    //新闻标题样式
    var title_format:TextFormat = new TextFormat();
    title_format.color = 0xab996f;
    function LoadArticles(psize:Number) {
    	Param["pageSize"] = psize;
          //创建web服务对象
    	var service:WebService = new WebService(WSDL);
          //调用web服务提供的方法GetPager,返回一个PendingCall对象
    	var articleCall:PendingCall = service.GetPager(
    			Param["pageSize"], 
    			Param["pageIndex"]
    	);
    	articleCall.onResult = function(result) {
    		//加载完成后,移除loading动画
    		loading.removeMovieClip();
    		RecordCount = result.Count;
    		PageCount = Math.ceil(RecordCount/PageSize)
    		var list:Array = result.ListData;
    		var p1:MovieClip = view_box.createEmptyMovieClip("p1",view_box.getNextHighestDepth());
    		var p2:MovieClip = view_box.createEmptyMovieClip("p2",view_box.getNextHighestDepth());
    		with(p1)
    		{
    			_x = 0;
    		}
    		for (var i = 0; i<list.length; i++) {
    			var info:Object = list[i];
    			var m:Object = title_format.getTextExtent(info.Title);
    			//创建p1
    			var _article:MovieClip = p1.createEmptyMovieClip("article_info",p1.getNextHighestDepth());
    			with(_article)
    			{
    				_x = article_pos;
    				_y = 0;
    			}
    			_article.url = info.Url;
    
    			_article.onRelease = function ()
    			{
    				trace(this.url);
    				getURL(this.url,"_blank");
    			}
    			_article.onRollOver = function ()
    			{
    				clearInterval(_interval);
    			}
    			_article.onRollOut = function ()
    			{
    				AutoPlay();
    			}
    			var _textbox:TextField = _article.createTextField("article_info",_article.getNextHighestDepth(),0,0,m.width,20);
    			_textbox.autoSize = true;
    			_textbox.text = info.Title;
    			_textbox.setTextFormat(title_format);
    			
    			//创建p2
    			var _article_2:MovieClip = p2.createEmptyMovieClip("article_info",p2.getNextHighestDepth());
    			with(_article_2)
    			{
    				_x = article_pos;
    				_y = 0;
    			}
    			_article_2.url = info.Url;
    
    			_article_2.onRelease = function ()
    			{
    				trace(this.url);
    				getURL(this.url,"_blank");				
    			}
    			_article_2.onRollOver = function ()
    			{
    				clearInterval(_interval);
    			}
    			_article_2.onRollOut = function ()
    			{
    				AutoPlay();
    			}
    			var _textbox:TextField = _article_2.createTextField("article_info",_article_2.getNextHighestDepth(),0,0,m.width,20);
    			_textbox.autoSize = true;
    			_textbox.text = info.Title;
    			_textbox.setTextFormat(title_format);
    			
    			article_pos += m.width + 12;			
    
    			Articles.push(_article);
    		}
    		p2._x = article_pos;
    		AutoPlay();
    	};
    	articleCall.onFault = function(fault) {
    		trace(fault);
    	};
    }
    _this.LoadArticles(PageSize);
    
    var _interval = null;
    function AutoPlay()
    {
    	_interval = setInterval(BeginPlay,30);
    }
    function BeginPlay()
    {
    	view_box._x -= 1;
    	if(-view_box._x >= view_box._width / 2)
    	{
    		view_box._x = 0;
    	}
    }
    
  • 相关阅读:
    Python爬虫开源项目代码,爬取微信、淘宝、豆瓣、知乎、新浪微博、QQ、去哪网等 代码整理
    python ---split()函数讲解
    常见的操作系统及linux发展史
    第五次作业
    第四次软件工程作业
    软件工程——第三次作业
    软件工程--第二次作业
    软件工程--第一次作业
    在SQL Server中调用.NET程序集
    c#中使用ABCpdf处理PDF,so easy
  • 原文地址:https://www.cnblogs.com/dreamcat/p/flash_and_webservice_marquee.html
Copyright © 2011-2022 走看看