加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flash 移除ScrollPane的时候报endDrag错误的解决方法

发布时间:2020-12-15 17:55:28 所属栏目:百科 来源:网络整理
导读:import fl.containers.ScrollPane; import flash.display.Loader; import flash.net.URLRequest; import flash.display.Sprite; import fl.events.ScrollEvent; import flash.events.MouseEvent; function upLoaderEvent(event:MouseEvent) { ?if(!isMove) ?

import fl.containers.ScrollPane;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.display.Sprite;
import fl.events.ScrollEvent;
import flash.events.MouseEvent;


function upLoaderEvent(event:MouseEvent)
{
?if(!isMove)
?{
??trace("sdfdfsdfsfsfs");
?}
?isMove = false;
}
var isMove:Boolean = false;
function onMove(event:MouseEvent)
{
?if(event.buttonDown)
? ?isMove = true;
}


btnClear.addEventListener(MouseEvent.CLICK,ClearScrollPane);
btnAdd.addEventListener(MouseEvent.CLICK,AddScrollPane);

function AddScrollPane(event:MouseEvent)
{
?var sp:ScrollPane=new ScrollPane();
?sp.name="sp";
//sp.horizontalScrollPolicy ="OFF";
//sp.verticalScrollPolicy="OFF";
?sp.setSize(500,500);
?sp.move(0,5);
?sp.scrollDrag=true;
?sp.horizontalLineScrollSize=4;
?sp.verticalLineScrollSize=4;
?
?sp.addEventListener(MouseEvent.MOUSE_MOVE,onMove);
?addChild(sp);
??
?var sprite:Sprite=new Sprite();
?sprite.graphics.lineStyle(1,0x000000);
?sprite.graphics.beginFill(0xff0000);
?sprite.graphics.drawRect(0,1024,600);
?sprite.graphics.endFill();
???
?var loader:Loader=new Loader();
?loader.load(new URLRequest("1_3.jpg"));
?sprite.addChild(loader);

?sp.source=sprite; ? ?var upLoader:Loader = new Loader(); ?upLoader.load(new URLRequest("tv1.png")); ?upLoader.addEventListener(MouseEvent.CLICK,upLoaderEvent); ?sprite.addChild(upLoader); ??? } ? function ClearScrollPane(event:MouseEvent) { ?if(this.getChildByName("sp")!=null)? ?{ ??ScrollPane(this.getChildByName("sp")).scrollDrag=false; ??//加上此句清除ScrollPane的时候就不会报endDrag的错误了 ??//错误信息:无法访问空对象引用的属性或方法。at fl.containers::ScrollPane/endDrag() ??ScrollPane(this.getChildByName("sp")).drawNow();?? ??this.getChildByName("sp").removeEventListener(MouseEvent.MOUSE_MOVE,onMove); ??this.removeChild(this.getChildByName("sp")); ?? ?} ??? }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读