| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 592 人关注过本帖
标题:flash as程序问题:如何实现从数据库中载入图片时,自动缩放成325*245像素大 ...
只看楼主 加入收藏
非常九加十
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-3-5
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
flash as程序问题:如何实现从数据库中载入图片时,自动缩放成325*245像素大小
请高手帮忙解决flash as程序问题(新手上路,分不多,全给你了,感谢!):
   这是一个网页flash新闻图片轮播。如何实现从数据库中载入图片时,缩放成325*245像素大小(小图片放大,大图片缩小),然后显示出来。
附flash as 程序:
【【【【第一帧程序】】】】:
function fixImage(tar)
{
    var _loc3 = tar._width;
    var _loc2 = tar._height;
    var _loc5 = 325;
    var _loc4 = 246;
    if (_loc3 > _loc5 || _loc2 > _loc4)
    {
        var _loc7 = _loc3 / _loc5;
        var _loc6 = _loc2 / _loc4;
        if (_loc7 > _loc6)
        {
            tar._width = _loc5;
            tar._height = tar._height / _loc7;
        }
        else
        {
            tar._height = _loc4;
            tar._width = tar._width / _loc6;
        } // end else if
        tar._x = -tar._width * 5.000000E-001;
        tar._y = -tar._height * 5.000000E-001;
    }
    else
    {
        tar._x = -_loc3 * 5.000000E-001;
        tar._y = -_loc2 * 5.000000E-001;
    } // end else if
} // End of the function
function loadInfoBMP(bmpa, n)
{
    var _loc4 = new flash.display.BitmapData(410, 246, true, 4.294967E+009);
    _loc4.copyChannel(bmpa, bmpa.rectangle, new flash.geom.Point(0, 0), 1, 8);
    info_array[n] = _loc4;
    for (var _loc2 = n + 1; _loc2 < info_array.length; ++_loc2)
    {
        if (info_array[_loc2].indexOf(".jpg") >= 0)
        {
            bmpList.getBMP(info_array[_loc2], loadInfoBMP, this, _loc2);
            return;
        } // end if
    } // end of for
    nextFrame ();
} // End of the function
function bmpObject()
{
    this.tp_bmp = new flash.display.BitmapData(410, 246);
    this.load_mc = tp_load_mc.mc.mc;
    this.myLoad = new MovieClipLoader();
    this.loadObj = {_parentObj: this};
    this.loadObj.onLoadInit = function ()
    {
        this._parentObj.drawBMP();
        this._parentObj.loadOK();
    };
    this.loadObj.onLoadError = function ()
    {
        this._parentObj.reLoad();
    };
    this.bmp_object = {};
    this.myLoad.addListener(this.loadObj);
    this.getBMP = function (url, runFun, obj)
    {
        this.reLoad_num = 10;
        this.runFun = runFun;
        this.runObj = obj;
        this.paramArray = arguments.splice(3, arguments.length - 3);
        this.url = url;
        if (this.bmp_object[url] != undefined)
        {
            this.loadOK();
        }
        else
        {
            this.load();
        } // end else if
    };
    this.load = function ()
    {
        this.myLoad.loadClip(this.url, this.load_mc);
    };
    this.reLoad = function ()
    {
        if (--this.reLoad_num > 0)
        {
            this.load();
        }
        else
        {
            this.loadOK(true);
        } // end else if
    };
    this.drawBMP = function ()
    {
        this.bmp_object[url] = new flash.display.BitmapData(410, 246);
        this.bmp_object[url].draw(this.load_mc._parent._parent);
    };
    this.loadOK = function (noLoad)
    {
        this.paramArray.unshift(noLoad ? (this.tp_bmp) : (this.bmp_object[url]));
        this.runFun.apply(this.runObj, this.paramArray);
    };
} // End of the function
stopTime = Math.max(Number(stopTime), 4000);
var image_array = image.split("|");
var url_array = url.split("|");
var info_array = info.split("|");
image_width = 325;
image_height = 246;
tp_load_mc._visible = false;
new Color(tp_load_mc.mc).setTransform({ab: 0, aa: 100, bb: 255, ba: -100, gb: 255, ga: -100, rb: 255, ra: -100});
var bmpList = new bmpObject();
var i = 0;
while (i < info_array.length)
{
    if (info_array[i].indexOf(".jpg") >= 0)
    {
        bmpList.getBMP(info_array[i], loadInfoBMP, this, i);
        stop ();
        break;
    } // end if
    ++i;
} // end while


【【【【第二帧程序】】】】:
function drawSM(bmp, n)
{
    var _loc4 = this["mc" + n].up_mc._width;
    var _loc3 = this["mc" + n].up_mc._height;
    this["mc" + n].mc.attachBitmap(bmp, 0);
    this["mc" + n].mc._width = _loc4;
    this["mc" + n].mc._height = _loc3;
    this["mc" + n].loading_mc._visible = false;
    this["mc" + n].n = n;
    this["mc" + n].onRollOver = function ()
    {
        gotoMouse(this.n);
        timeMove = false;
    };
    this["mc" + n].onRollOut = this["mc" + n].onReleaseOutside = function ()
    {
        gotoMouse();
        timeMove = true;
        mouse_mc.prevFrame();
    };
    this["mc" + n].onPress = function ()
    {
        mouse_mc.nextFrame();
    };
    this["mc" + n].onRelease = function ()
    {
        bmpList.getBMP(image_array[this.n], drawBIG, _root, this.n);
        mouse_mc.prevFrame();
    };
    if (n == 0)
    {
        drawBIG(bmp, n);
        onEnterFrame = timeEnterFrame;
    } // end if
    if (n == 5)
    {
        return;
    } // end if
    bmpList.getBMP(image_array[n + 1], drawSM, this, n + 1);
} // End of the function
function drawBIG(bmp, n)
{
    if (nonce_n == n)
    {
        return;
    } // end if
    photo_mc.info = info_array[n];
    trace (photo_mc.info);
    prev_bmp = nonce_bmp;
    nonce_bmp = bmp;
    nonce_n = n;
    photo_mc.mc1.attachBitmap(nonce_bmp, 0);
    photo_mc.mc0.attachBitmap(prev_bmp, 0);
    photo_mc.gotoAndPlay(2);
    gotoMouse(n, true);
} // End of the function
function gotoMouse(n, gd)
{
    n = n == undefined ? (mouse_mc.an) : (n);
    mouse_mc.ay = this["mc" + n]._y;
    if (gd)
    {
        mouse_mc.an = n;
    } // end if
    this["mc" + n].up_mc.onEnterFrame = function ()
    {
        this._alpha = this._alpha - 10;
        if (this._alpha <= 0)
        {
            this._alpha = 0;
            delete this.onEnterFrame;
        } // end if
    };
    if (mouse_mc.prev_n != n)
    {
        this["mc" + mouse_mc.prev_n].up_mc.onEnterFrame = function ()
        {
            this._alpha = this._alpha + 10;
            if (this._alpha >= 100)
            {
                this._alpha = 100;
                delete this.onEnterFrame;
            } // end if
        };
    } // end if
    mouse_mc.onEnterFrame = function ()
    {
        this._y = this._y + (this.ay - this._y) / 7.500000E+000;
    };
    mouse_mc.prev_n = n;
} // End of the function
stop ();
new Color(tp_load_mc.mc).setTransform({ab: 0, aa: 100, bb: 0, ba: 100, gb: 0, ga: 100, rb: 0, ra: 100});
bmpList.getBMP(image_array[0], drawSM, this, 0);
photo_mc.onRelease = function ()
{
    if (nonce_n != undefined)
    {
        getURL(url_array[nonce_n], "_blank");
    } // end if
};
var time = getTimer();
var timeMove = true;
timeEnterFrame = function ()
{
    if (timeMove)
    {
        t_txt = getTimer() - time;
        if (getTimer() - time >= stopTime)
        {
            n = (nonce_n + 1) % 6;
            bmpList.getBMP(image_array[n], drawBIG, _root, n);
            time = getTimer();
        } // end if
    }
    else
    {
        time = getTimer();
    } // end else if
};
搜索更多相关主题的帖子: 新手上路 function flash 数据库 新闻图片 
2011-03-05 22:58
gupiao175
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:40
帖 子:1787
专家分:7527
注 册:2007-6-27
收藏
得分:20 
很复杂,不好意思,AS不太会,虽然语法和JAVASCRIPT类似。但是区别还是比较大的。帮你顶,期待高手!

Q:1428196631,百度:开发地 即可找到我,有事请留言!
2011-03-07 14:15
快速回复:flash as程序问题:如何实现从数据库中载入图片时,自动缩放成325*245 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013002 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved