-
[RESOLVED] Loop Question
Hello,
What would be a better loop solution? Its some flickering thing, 40 fps.
I cant tell the difference, or benefits..
This:
Code:
import flash.filters.*;
import com.greensock.*;
rm.addEventListener(Event.ENTER_FRAME, ram);
function ram(e:Event):void{
if (this.currentFrame == 1)
{ for (var i:int=1; i<=40; i++)
var br1 = (Math.floor(Math.random() * .85 + .65)) ;
TweenMax.to(rm, .6, {colorMatrixFilter:{index:1, brightness:.3 + br1, contrast:.55 + br1}});
}
}
Or this:
Code:
import flash.filters.*;
import com.greensock.*;
rm.addEventListener(Event.ENTER_FRAME, ram);
function ram(e:Event):void{
if (this.currentFrame == 1)
{
var br1 = (Math.floor(Math.random() * .85 + .65)) ;
TweenMax.to(rm, .6, {colorMatrixFilter:{index:1, brightness:.3 + br1, contrast:.55 + br1},
onComplete:ram});
}
}
Thanks
-
Neither.
The first one just does the same thing 40 times, and each time overwrites what it did before. Doing it once is better than doing it 40 times and throwing away 39 of them.
In the second, you have an onComplete. In both versions, ram will be called once per frame. In the second, it will ALSO be called every time the tween completes. You cannot see a tween in less than a frame, so what's the point in creating a new tween every frame? Or more than one per frame?
You do have the check for the frame number in there, but then why have it be an enter_frame listener in the first place?
-
Hm, yes, right..
Im so new in this..
It just need Mc to flicker randomly.
So I should replace ENTER_FRAME with just "ram();"...?
Sorry, beginers are borring I know..
-
It depends on what you're trying to do, which I couldn't really tell from the original code.
If you want to just transition from one random color to the next, then something like the second version is good, but just call ram instead of setting it as an enter_frame listener. You may have to adjust the signature of ram, depending on what TweenMax passes to the onComplete function.
-
Yes, I see.
Its just some flickering bulb, randomly changing brightness and contrast..silly maybe, but I didnt know how to make it other way.. Yes definetly You helped me to understand my mistakes!
Thanks my friend!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|