垂直滚动新闻或公告栏制作
Flash 动画:
=================================
MovieClip.prototype.drawrect = function(pos_x, pos_y, w, h) {
// --
this.px = pos_x;
this.py = pos_y;
this.an = w;
this.al = h;
// --
with (this) {
beginFill(0x66ffff, 80);
moveTo(px, py);
lineTo(px+an, py);
lineTo(px+an, py+al);
lineTo(px, py+al);
lineTo(px, py);
endFill();
}
};
var bgclick:Boolean;
bg.onPress=function(){
startDrag(this);
bgclick=true;
}
bg.onRelease=function(){
stopDrag();
bgclick=false;
}
var a:MovieClip=_root.createEmptyMovieClip("a",_root.getNextHighestDepth());
var b:MovieClip=_root.createEmptyMovieClip("b",_root.getNextHighestDepth());
b.drawrect(0,0,bg._width-8,bg._height-28);
a._x=b._x=bg._x+4;
a._y=b._y=bg._y+4;
var myformat:TextFormat=new TextFormat();
myformat.align="center";
myformat.underline=true;
for(var i=0;i<20;i++){
var aa:MovieClip=a.createEmptyMovieClip("ab"+i+"_mc",i+10);
aa._y=22*i;
aa.id=i;
aa.createTextField("ab_txt",1,0,0,180,22);
aa.ab_txt.text="测试文字--"+i;
aa.ab_txt.selectable=false;
aa.ab_txt.setTextFormat(myformat);
aa.onPress=function(){
trace(this+".id="+this.id);
_root.t.text="你选择了:第"+this.id+"条新闻";
}
aa.onRollOver=function(){
this.ab_txt.textColor="0xff0000";
clearInterval(id);
}
aa.onRollOut=function(){
this.ab_txt.textColor=null;
id=setInterval(scrollit,50,a,b);
}
}
a.setMask(b);
// -- 滚动定义
function scrollit(myclip,mk) {
myclip._y-=1;
updateAfterEvent();
//trace(myclip._y);
if (!myclip.hitTest(mk)) {
myclip._y = mk._y+mk._height;
}
if(bgclick){
a._x=b._x=bg._x+4;
a._y=b._y=bg._y+4;
}
};
id=setInterval(scrollit,50,a,b);
Flash 动画:
=================================
MovieClip.prototype.drawrect = function(pos_x, pos_y, w, h) {
// --
this.px = pos_x;
this.py = pos_y;
this.an = w;
this.al = h;
// --
with (this) {
beginFill(0x66ffff, 80);
moveTo(px, py);
lineTo(px+an, py);
lineTo(px+an, py+al);
lineTo(px, py+al);
lineTo(px, py);
endFill();
}
};
var bgclick:Boolean;
bg.onPress=function(){
startDrag(this);
bgclick=true;
}
bg.onRelease=function(){
stopDrag();
bgclick=false;
}
var a:MovieClip=_root.createEmptyMovieClip("a",_root.getNextHighestDepth());
var b:MovieClip=_root.createEmptyMovieClip("b",_root.getNextHighestDepth());
b.drawrect(0,0,bg._width-8,bg._height-28);
a._x=b._x=bg._x+4;
a._y=b._y=bg._y+4;
var myformat:TextFormat=new TextFormat();
myformat.align="center";
myformat.underline=true;
for(var i=0;i<20;i++){
var aa:MovieClip=a.createEmptyMovieClip("ab"+i+"_mc",i+10);
aa._y=22*i;
aa.id=i;
aa.createTextField("ab_txt",1,0,0,180,22);
aa.ab_txt.text="测试文字--"+i;
aa.ab_txt.selectable=false;
aa.ab_txt.setTextFormat(myformat);
aa.onPress=function(){
trace(this+".id="+this.id);
_root.t.text="你选择了:第"+this.id+"条新闻";
}
aa.onRollOver=function(){
this.ab_txt.textColor="0xff0000";
clearInterval(id);
}
aa.onRollOut=function(){
this.ab_txt.textColor=null;
id=setInterval(scrollit,50,a,b);
}
}
a.setMask(b);
// -- 滚动定义
function scrollit(myclip,mk) {
myclip._y-=1;
updateAfterEvent();
//trace(myclip._y);
if (!myclip.hitTest(mk)) {
myclip._y = mk._y+mk._height;
}
if(bgclick){
a._x=b._x=bg._x+4;
a._y=b._y=bg._y+4;
}
};
id=setInterval(scrollit,50,a,b);
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}