flsg
Member
|
kk there's lots of ways to make a piece of code to execute multiple times. the for loops you used in the code was one one them. But that loop executes the code 50 times(i=0; i<50), and only render the image at the end of all the 50 executions. onEnterFrame is another kind of loop, which update the screen immediately after it runs the code once, the delay between each run is dertermined by the frame per second(FPS) you must associate the onEnterFrame with a movieclip: mc1.onEnterFrame=function(){
_root.ball._x+=2
} this code makes the ball mc to move a little bit to the right every 1/12 second(the default FPS is 12) in your case, you do: t.onEnterFrame=function(){
this._alpha+=2
} you could choose any number for the increase value then you simply add a if() statement after _alpha line to check every time if the alpha has reached a certain value. If it does, then start decreasing the alpha value. To do this you must set a variable: (the complete code) t.alphaValue=2
t._alpha=50//start at 50 transparency
t.onEnterFrame=function(){
this._alpha+=this.alphaValue
if(this._alpha>=100||this._alpha<50){
this.alphaValue*=-1//inverse the alphaValue to increase transparency
}
} BTW, ina onEnterFrame, "this" is the mc on which you put the onEnterFrame
< Message edited by flsg -- 3/14/2008 12:37:28 >
_____________________________
My flash gallery my game thread flsg, proud old member of AQ(still playing :O)
|