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

www.zhiqu.org     时间: 2024-06-15
购物,出售物品,使用物品,装备物品,那是一个比较大的块儿,下面代码给你参照呗。

/*----------------------背包系----------------------------*/
///
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();
}
}

我要用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的资料,功能非常强大!

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


#澹石封# 背包显示不正常 -
(13267712839): 正常现象,关闭网页重新进入,不行重启电脑,还不行就修复FLASH,可能版本低了

#澹石封# 回溯法用约束函数在扩展结点处剪去不满足约束的子树 - 上学吧普法考...
(13267712839): flash 里面都自带有脚本助手的.只是只有当你写入了关键词时,脚本助手才会激活,才能帮你写脚本,这脚本助手只是帮助修改脚本是比较方便,而还不适用于自己编写脚本,如果自己编写的话,还是情愿用flash的代码提示,而更加快捷,也可以加深自己对脚本的编写,

#澹石封# 策略型网游中,有没有可以修改背包物品数量的程序/修改器(例如:背包内物品数量对调之内)求程序! -
(13267712839): 先将库里的元件(你的物品)输入连接链.代码用,attachMove方式,到你的背包.背包格子用Array()开组. 祥细Q:

#澹石封# 01背包问题,程序求解 -
(13267712839): 把这一句:int f[maxn],t[maxn],v[maxn]; 放到main()的前面去,或者定义后就立即赋值为0.因为局部变量初始化的值是不确定的,但保证全局变量都被初始化为0.还有你最后:cout

#澹石封# 《激战2》背包系统种类及用途详细攻略
(13267712839): 《激战2》(Guild Wars 2)是由网游业界巨头NCSOFT旗下的北美子公司ArenaNet开发... 8格背包20格背包普通的背包只提供不同数量的物品格子,没什么好说的了,接下来...

#澹石封# 花千骨丹炉怎么升级天炉仙丹系统玩法介?花千骨丹炉怎么升级天炉仙丹
(13267712839): 花千骨丹炉怎么升级 天炉仙丹系统玩法介绍 花千骨新增系统-天炉仙丹,丹炉怎么升级?一起来看看天炉仙丹系统的玩法介绍吧. 天炉仙丹系统 1. 天炉炼丹—丹炉总共分...

#澹石封# 为什么别人的空间flash模块按住鼠标可以随意拖动,而我的不行呢,怎么调整模块的大小啊?
(13267712839): 点击版式/布局,选择自由布局就可以移动或者调整模块的大小了.