flash背包系统,就是物品能拖拽,物品数量的变量随之而转移的。

作者&投稿:惠武 (若有异议请与网页底部的电邮联系)
我要用flash做个背包系统~~~~~~

那你写吧。你不会让别人给你做好吧。

4*5就是20个MC了。把xml读出来。内容存入数组。
然后把数组的内容显示在你指定的MC。就可以了。

呵呵
首先 你先把这36张照片做到一个影片剪辑元件中,该元件第一帧停止

然后把这个元件拖到舞台上,命名为mc

然后在第一帧加入如下代码

var speed:Number=0.1;//速度参数,修改次参数可以调整速度
var long:int=mc.totalFrames;//总帧数
var newX:Number;
var frame:Number=mc.currentFrame;//当前是第几帧
stage.addEventListener(MouseEvent.MOUSE_DOWN,mdown);
stage.addEventListener(MouseEvent.MOUSE_UP,mup);
function mdown(e:MouseEvent):void {
newX=e.stageX;
stage.addEventListener(MouseEvent.MOUSE_MOVE,mmove);
}
function mup(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE,mmove);
}
function mmove(e:MouseEvent):void {
if ((frame+(e.stageX-newX)*speed)>=1) {
frame=((frame+(e.stageX-newX)*speed)-1)%long+1;
} else if ((frame+(e.stageX-newX)*speed)>0) {
frame=long+frame+(e.stageX-newX)*speed;
} else {
frame=long-Math.abs(frame+(e.stageX-newX)*speed)%long;
}
newX=e.stageX;
mc.gotoAndStop(int(frame));
}

这个是AS3的代码 如果是AS2的话再补充,如果元件的实例名不方便为mc的话,可以改成别的,不过代码中的所有mc都要替换成新的名称

其实像做这种3D的东西,如果楼主代码基础好的话,可以参考下PV3D的资料,功能非常强大!

我不是复制,这个是我自己的答案!

购物,出售物品,使用物品,装备物品,那是一个比较大的块儿,下面代码给你参照呗。

/*----------------------背包系----------------------------*/
///
var wuarr:Array = new Array();
var Zbeiarr:Array = new Array();
var paix = new Array(0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6);
var paiy = new Array(0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5);
var beix = new Array(490, 327, 327, 327, 484, 430, 376);
var beiy = new Array(18, 18, 66, 114, 330, 330, 330);
//whichwu[i]本身就是一个值了,而不是一个组,因为前面用的push.
function gowu() {
for (i=0; i<whichwu.length; i++) {
this.baoguo_mc.attachMovie(whichwu[i], "wu"+i, i);
var mc = this.baoguo_mc["wu"+i];
wuarr[i] = mc;
ueswu(i);
if (whichwu[i].substr(2, 2) == 17) {
wuarr[i].wupinn_txt.text = wunum[0];
} else if (whichwu[i].substr(2, 2) == 16) {
wuarr[i].wupinn_txt.text = wunum[1];
} else if (whichwu[i].substr(2, 2) == 15) {
wuarr[i].wupinn_txt.text = wunum[2];
} else if (whichwu[i].substr(2, 2) == 14) {
wuarr[i].wupinn_txt.text = wunum[3];
} else if (whichwu[i].substr(2, 2) == 13) {
wuarr[i].wupinn_txt.text = wunum[4];
} else if (whichwu[i].substr(2, 2) == 12) {
wuarr[i].wupinn_txt.text = wunum[5];
} else if (whichwu[i].substr(2, 2) == 11) {
wuarr[i].wupinn_txt.text = wunum[6];
} else if (whichwu[i].substr(2, 2) == 27) {
wuarr[i].wupinn_txt.text = wunum[7];
} else if (whichwu[i].substr(2, 2) == 26) {
wuarr[i].wupinn_txt.text = wunum[8];
} else if (whichwu[i].substr(2, 2) == 25) {
wuarr[i].wupinn_txt.text = wunum[9];
} else if (whichwu[i].substr(2, 2) == 24) {
wuarr[i].wupinn_txt.text = wunum[10];
} else if (whichwu[i].substr(2, 2) == 23) {
wuarr[i].wupinn_txt.text = wunum[11];
} else if (whichwu[i].substr(2, 2) == 22) {
wuarr[i].wupinn_txt.text = wunum[12];
} else if (whichwu[i] == "wu21") {
wuarr[i].wupinn_txt.text = wunum[13];
} else if (whichwu[i].substr(2, 2) == 28) {
wuarr[i].wupinn_txt.text = wunum[14];
} else if (whichwu[i].substr(2, 2) == 29) {
wuarr[i].wupinn_txt.text = wunum[15];
} else if (whichwu[i].substr(2, 3) == 212) {
wuarr[i].wupinn_txt.text = wunum[16];
} else if (whichwu[i].substr(2, 3) == 215) {
wuarr[i].wupinn_txt.text = wunum[17];
} else if (whichwu[i].substr(2, 3) == 210) {
wuarr[i].wupinn_txt.text = wunum[18];
} else if (whichwu[i].substr(2, 3) == 211) {
wuarr[i].wupinn_txt.text = wunum[19];
} else if (whichwu[i].substr(2, 3) == 213) {
wuarr[i].wupinn_txt.text = wunum[20];
} else if (whichwu[i].substr(2, 3) == 214) {
wuarr[i].wupinn_txt.text = wunum[21];
} else if (whichwu[i].substr(2, 3) == 312) {
wuarr[i].wupinn_txt.text = wunum[22];
} else if (whichwu[i].substr(2, 3) == 311) {
wuarr[i].wupinn_txt.text = wunum[23];
} else if (whichwu[i].substr(2, 3) == 310) {
wuarr[i].wupinn_txt.text = wunum[24];
} else if (whichwu[i].substr(2, 2) == 39) {
wuarr[i].wupinn_txt.text = wunum[25];
} else if (whichwu[i].substr(2, 2) == 38) {
wuarr[i].wupinn_txt.text = wunum[26];
} else if (whichwu[i].substr(2, 2) == 37) {
wuarr[i].wupinn_txt.text = wunum[27];
} else if (whichwu[i].substr(2, 2) == 36) {
wuarr[i].wupinn_txt.text = wunum[28];
} else if (whichwu[i].substr(2, 2) == 35) {
wuarr[i].wupinn_txt.text = wunum[29];
} else if (whichwu[i].substr(2, 2) == 34) {
wuarr[i].wupinn_txt.text = wunum[30];
} else if (whichwu[i].substr(2, 2) == 33) {
wuarr[i].wupinn_txt.text = wunum[31];
} else if (whichwu[i].substr(2, 2) == 32) {
wuarr[i].wupinn_txt.text = wunum[32];
} else if (whichwu[i] == "wu31") {
wuarr[i].wupinn_txt.text = wunum[33];
} else if (whichwu[i] == "wujp0") {
wuarr[i].wupinn_txt.text = wunum[34];
} else if (whichwu[i] == "wujp1") {
wuarr[i].wupinn_txt.text = wunum[35];
} else if (whichwu[i].substr(1, 1) == 3) {
wuarr[i].wupinn_txt.text = wunum[36];
} else if (whichwu[i].substr(1, 1) == 2) {
wuarr[i].wupinn_txt.text = wunum[37];
} else if (whichwu[i] == "b1") {
wuarr[i].wupinn_txt.text = wunum[38];
} else if (whichwu[i].substr(1, 1) == 0) {
wuarr[i].wupinn_txt.text = wunum[39];
} else if (whichwu[i].substr(1, 1) == 5) {
wuarr[i].wupinn_txt.text = wunum[40];
} else if (whichwu[i].substr(1, 1) == 4) {
wuarr[i].wupinn_txt.text = wunum[41];
} else if (whichwu[i].substr(1, 1) == 6) {
wuarr[i].wupinn_txt.text = wunum[42];
} else if (whichwu[i].substr(1, 1) == 7) {
wuarr[i].wupinn_txt.text = wunum[43];
} else if (whichwu[i].substr(1, 1) == 8) {
wuarr[i].wupinn_txt.text = wunum[44];
} else if (whichwu[i].substr(1, 1) == 9) {
wuarr[i].wupinn_txt.text = wunum[45];
} else if (whichwu[i].substr(1, 2) == 11) {
wuarr[i].wupinn_txt.text = wunum[46];
} else if (whichwu[i].substr(1, 2) == 10) {
wuarr[i].wupinn_txt.text = wunum[47];
}
}
}
function gowuxy() {
for (i=0; i<whichwu.length; i++) {
wuarr[i]._x = paix[i]*37+21;
wuarr[i]._y = paiy[i]*37+62;
}
}
function ueswu(mlapi) {
wuarr[mlapi].onPress = function() {
this._parent.xuandin_mc._x = this._x;
this._parent.xuandin_mc._y = this._y;
wuyu(mlapi);
};
}
function getwu() {
for (i=0; i<wuarr.length; i++) {
if (wuarr[i].hitTest(this.baoguo_mc.xuandin_mc)) {
if (whichwu[i].substr(2, 1) == 0) {
backmmB(0, i);
} else if (whichwu[i].substr(2, 1) == 5) {
backmmB(1, i);
} else if (whichwu[i].substr(2, 1) == 6) {
backmmB(2, i);
} else if (whichwu[i].substr(2, 1) == 7) {
backmmB(3, i);
} else if (whichwu[i].substr(2, 1) == 8) {
backmmB(4, i);
} else if (whichwu[i].substr(2, 1) == 9) {
backmmB(5, i);
} else if (whichwu[i].substr(2, 1) == 4) {
backmmB(6, i);
} else {
this.baoguo_mc.tisiz_mc.play();
}
}
}
}
function Zbei() {
for (i=0; i<Zbeiwu.length; i++) {
wup++;
this.zuangtai_mc.attachMovie(Zbeiwu[i], "zwu"+wup, wup);
var zmc = this.zuangtai_mc["zwu"+wup];
Zbeiarr[i] = zmc;
}
}
function Zbeixy() {
for (i=0; i<7; i++) {
Zbeiarr[i]._x = beix[i];
Zbeiarr[i]._y = beiy[i];
}
}
//有加载就有删除一定要的
function suaxin() {
for (i=0; i<42; i++) {
wuarr[i].removeMovieClip();
}
wuarr.splice(0, wuarr.length);
}
//颖是深度问题。
function backmmB(subnum, dota) {
wuarr[dota].removeMovieClip();
wuarr.splice(dota, 1);
if (Zbeiwu[subnum]<>"") {
whichwu.push(Zbeiwu[subnum]);
save.data.whichwu = whichwu;
save.flush();
owgowu = true;
Zbeiwu[subnum] = whichwu[dota];
save.data.Zbeiwu = Zbeiwu;
save.flush();
} else if (Zbeiwu[subnum] == "") {
Zbeiwu[subnum] = whichwu[dota];
save.data.Zbeiwu = Zbeiwu;
save.flush();
}
whichwu.splice(dota, 1);
}
function buywus(cost, cnum, wus:String) {
if (whichwu.length<42) {
if (jinqian>cost) {
if (wunum[cnum] == 0) {
whichwu.push(wus);
wunum[cnum]++;
save.data.wunum = wunum;
} else {
wunum[cnum]++;
save.data.wunum = wunum;
}
save.data.whichwu = whichwu;
save.flush();
owgowu = true;
jinqian -= cost;
save.data.jinqian = jinqian;
} else {
this.gouwuqindan2_mc.tisib_mc.play();
this.gouwuqindan3_mc.tisib_mc.play();
this.gouwuqindan4_mc.tisib_mc.play();
}
} else {
this.gouwuqindan2_mc.tisim_mc.play();
this.gouwuqindan3_mc.tisim_mc.play();
this.gouwuqindan4_mc.tisim_mc.play();
}
}


珠山区13883634237: flash中怎样把一个物体拖到另一个物体上,并有是否相碰的提示
蔡所钻山: 1、新建一个 flash 文档,在舞台上绘制一个圆形.选中圆形并按F8将它 转换为影片剪辑,起名:圆 .这样就在舞台上创建了一个圆的实例. 2、选中此实例,为它起一个名字,此例起名为:yuan 3、选择文字工具,并选择文字类型为“动态文...

珠山区13883634237: FLASH as2.0怎么实现点中后拖动物体? -
蔡所钻山: flash 里面都自带有脚本助手的.只是只有当你写入了关键词时,脚本助手才会激活,才能帮你写脚本,这脚本助手只是帮助修改脚本是比较方便,而还不适用于自己编写脚本,如果自己编写的话,还是情愿用flash的代码提示,而更加快捷,也可以加深自己对脚本的编写,

珠山区13883634237: 在玩网页游戏时,点鼠标右键使用背包内物品时,突然弹出一个对话框...
蔡所钻山: 一般FLASH游戏 右键不会开设功能.. 你试下 双击左键或者选择物品 然后点击使用按钮 如果不行 那就没办法了

珠山区13883634237: 请问背包在哪?
蔡所钻山: ...在界面的右下角有个像袋子形状的就是背包,如果系统提示背包已满,你可以点进去左击拖动物品扔掉.

珠山区13883634237: 奇迹来了的背包功能 -
蔡所钻山: 【背包系统】 玩家1级进入游戏后,点击主界面的“背包”按键,可打开奇迹来了背包界面. 背包中最上方为物品分类,点击分页可查看分类物品. 中部为背包中的物品,背包中位置有限.可通过在线时间或消耗钻石增加背包位.每开启一个...

珠山区13883634237: 手机主板上的Flash是什么东西 -
蔡所钻山: Adobe Flash Player(Flash播放器)是一种广泛使用、专有的多媒体播放器,flash播放器最新版本下载成为适合开发创造丰富型互联网应用程序、流视频音频的工具.Flash Player使用向量图形的技术来最小化文件的大小以及创造节省网络带宽和下载时间的文件,因此Flash成为嵌入网页中的小游戏、动画以及图形用户界面常用的格式.flash播放器插件与flash播放器的区别在于flash插件是一个网页ActiveX控件,而flash播放器是一个exe的可执行程序.前者用于播放网页中的flash动画,而后者用于播放本地swf格式文件.

珠山区13883634237: 假定有一个模块,在其中定义一个公共变量,正确的是 - 上学吧普法考试
蔡所钻山: 飞行背包根据飞机发动机的的工作原理而做成,主要有两种,一种是涡轮发动机,一种是涡扇发动机 涡扇发动机的工作原理:涡扇发动机是喷气发动机的一个分支,从血缘关系上来说涡扇发动机应该算得上是涡喷发动机的变种.从结构上看,涡扇发动机只不过是在涡喷发动机之前(之后)加装了风扇而已.然而正是这区区的几页风扇把涡喷发动机与涡扇发动机严格的区分开来. 涡扇发动机的诞生就是为了顺应人们对航空发动机越来越高的推力要求而诞生的.因为提高喷气发动机的推力最简单的办法就是提高发动机的空气流量.

珠山区13883634237: flash技术 -
蔡所钻山: 把对象做成影片剪辑.放置到场景中.上面加入脚本: onClipEvent(mouseDown){if(this.hitTest(_xmouse,_ymouse,true){ startDrag("this",false); } } onClipEvent(mouseUp){ stopDrag(); } 以上是拖拽部分 触动动画部分 做一个剪辑作为感应区.将感应区剪辑命名mc1,刚才拖动的剪辑命名mc.主场景中加脚本 if(mc1.hitTest(mc._x,mc._y,true)){nextFrame();play(); } 下一帧做触发的动画

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网