ActionScript 1.0 Flash Player 8 以上可以使用ExternalInterface.addCallback(methodName:String, instance:Object, method:Function) : Boolean
js调用flash方法
ExternalInterface.call(methodName:String, [parameter1:Object]) : Object
flash调用js方法
 

解决方案 »

  1.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><body>
    <input type="button" onclick="scroller(document.getElementById('a'),1000);return false;">移动到a</input>
    <input type="button" onclick="scroller(document.getElementById('b'),1000);return false;">移动到b</input>
    <p>
    asdf<br>
    asdf<br>
    sadf<br>
    asdf<br>
    sadf<br>
    sadf<br>
    sadf<br>
    asdf<br>
    </p>
    <a id="a" href="#">我是a</a>
    <p>
    asdf<br>
    asdf<br>
    sadf<br>
    asdf<br>
    sadf<br>
    sadf<br>
    sadf<br>
    asdf<br>
    </p>
    <p>
    asdf<br>
    asdf<br>
    sadf<br>
    asdf<br>
    sadf<br>
    sadf<br>
    sadf<br>
    asdf<br>
    </p>
    <p>
    asdf<br>
    asdf<br>
    sadf<br>
    asdf<br>
    sadf<br>
    sadf<br>
    sadf<br>
    asdf<br>
    </p>
     <a id="b" href="#">我是b</a>
    <p>
    asdf<br>
    asdf<br>
    sadf<br>
    asdf<br>
    sadf<br>
    sadf<br>
    sadf<br>
    asdf<br>
    </p>
    <p>
    asdf<br>
    asdf<br>
    sadf<br>
    asdf<br>
    sadf<br>
    sadf<br>
    sadf<br>
    asdf<br>
    </p>
    </body>
    <script>
    function scroller(el, duration)
    {
        if(typeof el != "object")
        {
            el = document.getElementById(el);
        }
        if(!el)
        {
            return;
        }
        var z = this;
        z.el = el;
        z.p = getPos(el);
        z.s = getScroll();
        z.clear = function(){
            window.clearInterval(z.timer);z.timer = null;
        };
        z.t = (new Date).getTime();
        z.step = function (){
            var t = (new Date).getTime();
            var p = (t - z.t) / duration;
            if (t >= duration + z.t)
            {
                z.clear();
                window.setTimeout(function(){
                    z.scroll(z.p.y, z.p.x);
                }, 13);
             }
             else
             {
                st = ((-Math.cos(p * Math.PI) / 2) + 0.5) * (z.p.y - z.s.t) + z.s.t;
                sl = ((-Math.cos(p * Math.PI) / 2) + 0.5) * (z.p.x - z.s.l) + z.s.l;
                z.scroll(st, sl);
             }
         };
         z.scroll = function (t, l){window.scrollTo(l, t);};
         z.timer = window.setInterval(function(){z.step();}, 13);
    }function getPos(e) {
        var l = 0;
        var t = 0;
        var w = intval(e.style.width);
        var h = intval(e.style.height);
        var wb = e.offsetWidth;
        var hb = e.offsetHeight;
        while (e.offsetParent) {
            l += e.offsetLeft + (e.currentStyle ? intval(e.currentStyle.borderLeftWidth) : 0);
            t += e.offsetTop + (e.currentStyle ? intval(e.currentStyle.borderTopWidth) : 0);
            e = e.offsetParent;
        }
        l += e.offsetLeft + (e.currentStyle ? intval(e.currentStyle.borderLeftWidth) : 0);
        t += e.offsetTop + (e.currentStyle ? intval(e.currentStyle.borderTopWidth) : 0);
        return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
    }  function getScroll() {
        var t, l, w, h;
        if (document.documentElement && document.documentElement.scrollTop) {
            t = document.documentElement.scrollTop;
            l = document.documentElement.scrollLeft;
            w = document.documentElement.scrollWidth;
            h = document.documentElement.scrollHeight;
        } else {
            if (document.body) {
                t = document.body.scrollTop;
                l = document.body.scrollLeft;
                w = document.body.scrollWidth;
                h = document.body.scrollHeight;
            }
        }
        return {t:t, l:l, w:w, h:h};
    }function intval(v) {
        v = parseInt(v);
        return isNaN(v) ? 0 : v;

    </script>
    </html>
      

  2.   

    看 http://topic.csdn.net/u/20081029/10/f9e98c7e-eec9-4cc9-8277-20201620051c.html 你会更明白,一样的道理
      

  3.   

    顶,js和flash现在几经可以可以交互,可以去下个 flashobject.js 看看不复杂