RSS订阅优然探索
你的位置:首页 » 技术笔记 » 正文

Flash加载外部图片,并控制图片的大小和位置

选择字号: 超大 标准 发布时间:2008-9-10 20:53:54 | 作者:admin | 0个评论 | 人浏览

//#######################################################

//通过参数 MeIshow 设置图片是否显示

//通过参数 MeIw 设置图片宽度

//通过参数 MeIh 设置图片高度

//通过参数 MeIsrc 设置图片地址

//编写人: 2008-7-15

//正式使用的时候,注释掉下面5行,这样才能从外部接受到信息

/*

var MeIshow, MeIw, MeIh, MeIsrc, MeIa, MeIv;

MeIshow = 0;

MeIw = 778;

MeIh = 152;

MeIsrc = "1.jpg";

*/

//MeIa = "left";

//MeIv = "bottom";

//#######################################################

var i;

i = 99;

//getNextHighestDepth();

//取得场景的深度

//本功能不建立MovieClip直接在场景上放了mcpic

//var mcpic:MovieClip = createEmptyMovieClip("mcpic", i);

//_root.mcpic.swapDepths(i);

if (MeIshow == 0) {

         //这里该加载图片的y位置

         var mcLoader:MovieClipLoader = new MovieClipLoader();

         mcLoader.addListener(this);

         mcLoader.loadClip(MeIsrc, mcpic);

}

//#######################################################               

//设置图片的动画效果,本功能使用alpha效果控制

//其它效果可以在这里通过程序控制

//#######################################################

var mpicx, mpicy;

var b = false;

function onLoadInit(mcpic:MovieClip) {

         mcpic._alpha = 0;

         //trace(mcpic._alpha);

         mcpic.onEnterFrame = function() {

                  //trace(this._alpha);

                  //#####################################################################################

                   mpicx = mcpic._width;

                   mpicy = mcpic._height;

                   if (mpicx>0) {

                            if (b == false) {

                                     if (MeIa == "left") {

                                              mcpic._x = (-(((int(MeIw))/2)))+1;

                                     } else if (MeIa == "right") {

                                              mcpic._x = (((int(MeIw)/2-mpicx)))+1;

                                     } else {

                                              mcpic._x = (-(mpicx/2))+1;

                                     }

                                     if (MeIv == "top") {

                                              mcpic._y = (-(((int(MeIh))/2)))+1;

                                     } else if (MeIv == "bottom") {

                                              mcpic._y = (((int(MeIh)/2-mpicy)))+1;

                                     } else {

                                              mcpic._y = (-(mpicy/2))+1;

                                     }

                                     b = true;

                            }

                   }

                  //#####################################################################################

                  this._alpha += 5;

                   if (this._alpha>=95) {

                            this._alpha = 100;

                            //gotoAndPlay(2);

                            delete this.onEnterFrame;

                   }

         };

}
 

标签:Flash  

发表评论

必填

选填

选填

必填,不填不让过哦,嘻嘻。

记住我,下次回复时不用重新输入个人信息

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。