Laan's steps..

Feed Rss

javascript for dragging

11.06.2008, flash, js, by .

Sometimes, we need to run the swf in page. At that time we can view the swf debug information. So I got a idea. When the swf is running in page, use the javascript to create a print panel. And then, the swf call javascript methods to show debug information.

The easiest way to do that is creating a class just for that. When  I need to show,  I can create a instance of that class. But firstly, I should to know how to create a panel, print text in that panel, and drag the panel.

About dragging, I had searched a page, witch done that well.

http://blog.sina.com.cn/s/blog_4a9b5035010009se.html

But, the code it shows can’t work. Once you want to drag a object, you should set the position property of that object to “absolute”, such as:<div id=”drag” style=”position:absolute”>drag me <div>

function createDrag(dv){
if (dv.style.position != “absolute”) {
dv.style.position = “absolute”;
}

dv.onmousedown=function(e){
var d = document;
e = e || window.event;

var x= e.layerX || e.offsetX;
var y= e.layerY || e.offsetY;

//设置捕获范围
if(dv.setCapture){
dv.setCapture();
}else if(window.captureEvents){
window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
}

dv.onmousemove = function(e){
e= e || window.event;
if(!e.pageX) e.pageX=e.clientX;
if(!e.pageY) e.pageY=e.clientY;

dv.style.left = e.pageX – x;
dv.style.top = e.pageY – y;
};

dv.onmouseup = function(){
//取消捕获范围
if(dv.releaseCapture){
dv.releaseCapture();
}else if(window.captureEvents){
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}

//清除事件
dv.onmousemove=null;
dv.onmouseup=null;
};
};
}

javascript for dragging 有 4 条回应

  1. Спасибо за текст! Очень понравилось

    回复
  2. RonaldLI :

    Спасибо за текст! Очень понравилось

    Ха ха

    谢谢你的文字!非常高兴 ——来自google翻译,俄语

    回复
  3. 2008-11-11 在 10:51 Terrence

    hello. nice to find ur site.
    You might want to take a look at Flash Tracer plugin in Firefox.
    It can debug flash nicely.

    回复
  4. thanks

    回复

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>