主题:  各位高手请指教:变量怎麽传递!!!

不要笑我

职务:普通成员
等级:1
金币:0.0
发贴:20
注册:2002/7/24 17:20:42
#12002/10/24 15:04:17
on exitFrame me
go the frame
end
on mouseDown
put the mouseh into loc1
put the mousev into loc2
moveleft
end mouseDown
上面的变量loc1和loc2怎样才能传递到下面的程序中
on startmovie
puppetSprite 1, TRUE
puppetSprite 2, TRUE
puppetSprite 3, TRUE
puppetSprite 4, TRUE
puppetSprite 5, TRUE
puppetSprite 6, TRUE
end
on moveleft
put the locH of sprite 6 into oldH
set the locH of sprite 6 to (oldh-1)
put the locv of sprite 6 into oldv
set the locv of sprite 6 to (oldv-1)
updateStage
end moveleft



不要笑我

职务:普通成员
等级:1
金币:0.0
发贴:20
注册:2002/7/24 17:20:42
#22002/10/25 9:46:06
昨天写错了,应该是以下

on exitFrame me
go the frame
end
on mouseDown
put the mouseh into loc1
put the mousev into loc2
moveleft
end mouseDown
上面的变量loc1和loc2怎样才能传递到下面的程序中
on startmovie
puppetSprite 1, TRUE
puppetSprite 2, TRUE
puppetSprite 3, TRUE
puppetSprite 4, TRUE
puppetSprite 5, TRUE
puppetSprite 6, TRUE
end
on moveleft
put the loc1 into oldH
set the locH of sprite 6 to (oldh-1)
put the loc2 into oldv
set the locv of sprite 6 to (oldv-1)
updateStage
end moveleft
以上两段程序属于不同的cast member。当我一运行程序,就弹出“script error: property not found put the loc1 into oldh #loc1”的出错警告框。请各位高手帮帮小弟,万分感谢!!!



jackycool

职务:普通成员
等级:1
金币:0.0
发贴:3
注册:2002/12/5 16:53:03
#32002/12/6 17:58:52
on startmovie
puppetSprite 1, TRUE
puppetSprite 2, TRUE
puppetSprite 3, TRUE
puppetSprite 4, TRUE
puppetSprite 5, TRUE
puppetSprite 6, TRUE
end
改为
on startmovie
repeat with i = 1 to 6
puppetSprite i, TRUE
end repeat
end
不是简单多了吗~

你声明过全局变量LOC1和LOC2了吗
"Global loc1, loc2"
所有用到LOC1和LOC2的地方都要"Global loc1, loc2"



jzhiqing

职务:普通成员
等级:1
金币:0.0
发贴:17
注册:2002/11/7 22:07:38
#42002/12/25 14:50:50
是的,声明一个全局变量可以传递的!



HolyKnight

职务:普通成员
等级:1
金币:1.0
发贴:175
注册:2002/12/25 12:38:14
#52003/1/8 16:20:18
global 变量名
在其它脚本就可以使用他了