在flash中点击图片出现文字怎么做
闲来无事帮你做好!有些细节还是自己调!
package ClickToDisplay {
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import flash.text.TextField;
import com.greensock .TweenLite;
import com.greensock .easing.*;
import flash.events.Event;
import flash.display.Shape;
public class OneMc extends Sprite {
private var iamgepath:String ="";
private var iamgeName:String =""
private var textCont:Sprite
private var iamgeloader:Loader =new Loader
public function OneMc($path:String ,$name:String ) {
// constructor code
iamgepath=$path;
iamgeName=$name;
textCont=new Sprite
AddTo();
}
private function AddTo(){
iamgeloader.load (new URLRequest (iamgepath));
this.addChild (iamgeloader)
iamgeloader.contentLoaderInfo .addEventListener (Event.COMPLETE,loadiamgecom)
}
private function loadiamgecom(e:Event ){
iamgeloader .addEventListener(MouseEvent.CLICK,clicktheloader);
iamgeloader.addEventListener (MouseEvent.MOUSE_OUT,outmouse);
this.addChild (textCont)
textCont.y =-30;
}
public function get getName():String {
return iamgeName;
}
private function clicktheloader(e:MouseEvent ){
var textf:TextField =new TextField
textf.textColor =0XFF0000;
textf.text =iamgeName;
textCont.addChild (textf)
TweenLite.to (textCont,0.25,{y:0})
}
private function outmouse(e:MouseEvent ){
TweenLite.to (textCont,0.25,{y:-30});
}
}
}
主文件:、、、、
import ClickToDisplay.OneMc;
var nums:int=9
var rownum:int=3;
init()
function init(){
var path:String ="Image/page1.jpg"
for(var i:int=0;i<nums;i++){
var tmpone:OneMc =new OneMc(path,"Name"+i)
tmpone.x=i%rownum*(350+5)
tmpone.y=Math.floor (i/rownum)*(218+5)
this.addChild (tmpone)
}
}
2024-07-20 广告
在帧上写命令:
a.stop
b.stop
c.stop
d.stop
e.stop
f.stop
g.stop
h.stop
a.OnRelease{a.gotoAndStop(2)}
b.OnRelease{b.gotoAndStop(2)}
c.OnRelease{c.gotoAndStop(2)}
d.OnRelease{d.gotoAndStop(2)}
e.OnRelease{e.gotoAndStop(2)}
f.OnRelease{f.gotoAndStop(2)}
g.OnRelease{g.gotoAndStop(2)}
h.OnRelease{h.gotoAndStop(2)}
a.OnRelease{a.gotoAndStop(2)}
b.OnRelease{b.gotoAndStop(2)}
c.OnRelease{c.gotoAndStop(2)}
.....
这一段输入之后有语法错误啊
因为你是直接复制的,回车并没有复制下来,所以你要对照着网页把代码中的回车加好。
怎么定义数组啊?
2014-04-12