flash 3.0 问题!!求帮忙
import com.greensock.TweenLite
import com.greensock.easing .*
import flash.display.Sprite;
import flash.events.MouseEvent;
var imagenum:int=5
var curentImage:Images
var imagew:Number =384.95
var imageh:Number =205
var imagedis:int=20
var curentIndex:int=0;
var cont:Sprite =new Sprite
var initp:Number =0
init()
function init(){
for(var i:int=0;i<imagenum;i++){
curentImage=new Images
curentImage.x=(500-imagew)/2+i*(imagew+imagedis)
curentImage.y=100
cont.addChild (curentImage)
}
var _bt:Bt=new Bt
_bt.x=274.3
_bt.y=185.35
this.addChild (cont)
this.addChild (_bt)
initp=cont.x
_bt.l.addEventListener(MouseEvent.CLICK,doclickl)
_bt.r.addEventListener(MouseEvent.CLICK,doclickr)
}
function doclickl(e:MouseEvent ){
curentIndex--
if(curentIndex<=0){
curentIndex=0
}
TweenByIndex(curentIndex)
}
function doclickr(e:MouseEvent ){
curentIndex++
if(curentIndex>=imagenum){
curentIndex=imagenum-1
}
TweenByIndex(curentIndex)
}
function TweenByIndex(index:int){
TweenLite.to (cont,0.25,{x:initp-index*(imagew+imagedis),ease:Cubic.easeInOut})
}
亲自手写忘采纳
不能隐藏旁边的吗?只显示按钮中间的图片?
你可以弄个影片剪辑 做给cont就行了撒!
cont.mask=你的那个影片
{
import flash.display.MovieClip;
import flash.events.Event;
public class Platform extends MovieClip
{
public function Platform()
{
addEventListener(Event.ADDED_TO_STAGE,onAddToStage);
}
private function onAddToStage(event:Event)
{
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
private function onEnterFrame(event:Event)
{
//MovieClip(root).checkCollisionWithMachine(this);
dispatchEvent(new Event("checkCW",true));
}
}
}
第二个:
package {
import flash.display.MovieClip;
public class Main extends MovieClip {
var backGround:BackGround;
public function Main() {
backGround=new BackGround();
stage.addChild(backGround);
stage.addEventListener("checkCW",onCheckCW_func);
}
private function onCheckCW_func(_evt:Event):void{
checkCollisionWithMachine(_evt.target);
}
public function checkCollisionWithMachine(platform:MovieClip)
{
Collision.block(backGround.machine,platform);
}
}
}
可以说明下吗?不是很明白