Search Tutorials
Now I can explain how we are going to make this work. If the movie starts we are going to fill the textboxes with the bits. We do this by setting the variables _root.BitLine0..9, then we are going to scroll the movie down until the top text is reaching the top of our window. If this is the case we must set our movie back to the original position, and swap bits from the first 5 lines to the last 5 lines. On the first 5 lines we can create some new random bits. So there will scroll an endless stream of bits down. Got it? Anyway, it will become clearer during the progress of creating the rest of our movie. Select Layer 1 and choose Modify->Convert to Symbol. Name it BitField and choose for bahavior Movie clip. Now we are going to add some actions to our movieclip. Rename Layer 1 to 'BitField' and create a new layer 'Actions' and copy the following code in your Actions Layer:
function MakeBitLine() {
var s = ''
for (i=0; i<15; i++) {
s += Math.round(random(2))
}
return s
}
function FillBitField() {
BitLine0 = MakeBitLine()
BitLine1 = MakeBitLine()
BitLine2 = MakeBitLine()
BitLine3 = MakeBitLine()
BitLine4 = MakeBitLine()
BitLine5 = MakeBitLine()
BitLine6 = MakeBitLine()
BitLine7 = MakeBitLine()
BitLine8 = MakeBitLine()
BitLine9 = MakeBitLine()
}
function SwapBitField() {
BitLine5 = BitLine0
BitLine6 = BitLine1
BitLine7 = BitLine2
BitLine8 = BitLine3
BitLine9 = BitLine4
BitLine0 = MakeBitLine()
BitLine1 = MakeBitLine()
BitLine2 = MakeBitLine()
BitLine3 = MakeBitLine()
BitLine4 = MakeBitLine()
}
In the function MakeBitLine() we return a random string of zeros and ones. This string is 15 characters long, because 15 characters fills the width of the window.
The function FillBitField() we only need when we load our movie, it just fills the ten variables of our textboxes with random bits using the MakeBitLine() function. The function SwapBitField() we use when our movie is moving back to its original top position. We must set the bottom 5 lines to the top 5 lines to let the scroll move on where it was. We create new bits on the 5 top lines that are positioned outside the window. Now the only thing left to do, is to let the BitField movieclip scroll down and move up again. Select the BitField movieclip and give it these actions:
onClipEvent(load) {
_root.FillBitField()
}
onClipEvent(enterFrame) {
_y += 10
if (_y == 90) {
_root.SwapBitField()
_y = 0
}
}
When our movie loads we call the function FillBitField().
In the main loop of our movie we set the _y position every time 10 pixels up. You can make this 1 if you want a slower scroller or 30 if you want a faster scroller. If the _y position of our movie is 90 we must swap the bits and set _y back to the original position.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|