我是一个flash新手。我按照本教程进行操作。这是网址 virtualhacker.wikispaces.com/file/view/funci%C3%B3n+para+el+bot%C3%B3n+Siguiente.pdf/156572951/funci%C3%B3n%20para%20el%20bot%C3%B3n %20Siguiente.pdf
是一个图片库。
我在 AS2 中实现了代码,它运行得很好。教程中缺少此代码
The code to center the images
sput_mc._x=(500-233)/2;
sput_mc._y=(250-50)/2;
和if条件语句代码去图片编号1,
if (npictures==5){ npictures=1
}
没有上面的代码会给你这个错误
Error opening URL 'file:/gal/Gallery/undefined'
这是完整的 AS2 代码:
var npictures:Number=1
var images:Array=new Array()
images[1]="images/image_01.jpg"
images[2]="images/image_02.jpg"
images[3]="images/image_03.jpg"
images[4]="images/image_04.jpg"
// TO CENTER THE IMAGE
sput_mc._x=(500-233)/2;
sput_mc._y=(250-50)/2;
number_txt.text=npictures
sput_mc.loadMovie(images[npictures])
neut_btn.onPress=function(){
npictures=Number(number_txt.text)
sput_mc.loadMovie(images[npictures])
}
prev_btn.onPress=function(){
npictures--
number_txt.text=npictures
sput_mc.loadMovie(images[npictures])
}
//remember the If statement to avoid the error
forw_btn.onPress=function(){
npictures++
if (npictures==5){ npictures=1
}
number_txt.text=npictures
sput_mc.loadMovie(images[npictures])
}
有经验的flash AS3 代码高手能看懂AS3 中的代码吗?请帮忙!
///////////////////////////////////////// //////////////////////////////////////// ///////////////////////////////////////// ////////////////////
谢谢你们
我在阅读此as3 参考资料后做到了
http://www.actionscript.org/forums/showthread.php3?p=989392 http://www.flashandmath.com/howtos/imgload/
这是一个好方法还是不需要toString的东西或null,addChild?
var npictures:Number=1
//the addChild null
var sput_mc:sput_mc=new sput_mc();
this.addChild(sput_mc);
var images:Array = new Array(
'pic1.jpg',
'pic2.jpg',
'pic3.jpg',
'pic4.jpg');
sput_mc.x=130;
sput_mc.y=90;
//toString
number_txt.text=npictures.toString();
sput_mc.load(new URLRequest(images[npictures]));
neut_btn.addEventListener(MouseEvent.CLICK,onEntClick);
function onEntClick(e:MouseEvent):void
{
number_txt.text=npictures.toString();
sput_mc.load(new URLRequest(images[npictures]));
}
forw_btn.addEventListener(MouseEvent.CLICK,onForwClick);
function onForwClick(e:MouseEvent):void
{
npictures++
if (npictures==4){ npictures=0
}
}
prev_btn.addEventListener(MouseEvent.CLICK,onBacklick);
function onBackClick(e:MouseEvent):void
{
//
npictures--
if (npictures==4){ npictures=0
}
// toString()
number_txt.text=npictures.toString();
sput_mc.load(new URLRequest(images[npictures]));
}