做个东西,会到了一点小问题
为了简化问题,我举个小例子说明,希望各位予以解答
舞台上:一个图片MC(名字为"showimg",width=50,height=40),一个影片按钮,名字为control
目的:
是单击control以后,图片缓冲变到width=470,height=300,同时变大后的图片能受鼠标移动而移动(象展示产品全景一样)。
问题:
本来的效果是单击control,图片会连续累加宽高值,以达到缓冲变大效果,可执行后却发现是press一次,图片宽高加一点,就是不连续,无赖之下,我删除_root.onEnterFrame=function()里面的changeshow()函数,能够连续变大,而且我也试图把changeshow()函数写在onEnterFrame外边,还是不行,初步怀疑是因为changeshow()函数里也在用_root.onEnterFrame,两个同时用发生了冲突,想请问一下有什么解决办法
好,看_root代码(着重看我标注红色的地方,至于自定义函数changeshow(),_root.onEnterFrame内部的代码就不用看了,相信不是他们的问题)
control.onPress=function(){
_root.onEnterFrame=function(){
showimg._width+=(470-showimg._width)/10
showimg._height+=(300-showimg._height)/10
changeshow()
}
}
function changeshow(){
showimg._x=0
showimg._y=0
_root.onEnterFrame=function(){ left=0
right=470
up=0
down=300
if(_root._xmouse>left&&_root._xmouse<right&&_root._ymouse>up&&_root._ymouse<down){
showimg._x-=(_root._xmouse-right/2)/10
showimg._y-=(_root._ymouse-down/2)/10
if(showimg._x>left){
showimg._x=left
}
if(showimg._y>up){
showimg._y=up
}
if(showimg._x<right-showimg._width){
showimg._x=right-showimg._width
}
if(showimg._y<down-showimg._height){
showimg._y=down-showimg._height
}
}
} //end enterframe
}
[ 本帖最后由 SUNXINZHE 于 2008-5-21 03:04 编辑 ]