View Full Version : Matrix code

09-04-2003, 11:37 AM
I've looked around but i didn't find anything satisfying so i'm posting here.

I'd like to make something as close to the matrix code as possible.
I thought about attachmovie in order to generate several lines of code. But i also need to generate random letters/numbers for each lines, and then i need to make then fall.
I don't know how to do this, could you help me?


09-04-2003, 11:48 AM
Search for "matrix effect" in these forums and you'll get a ton of hits. I looked as some of them and found some pretty good ones. I don't know how much better a version you're looking for.

09-04-2003, 04:53 PM
what i see is that people try to "kind of imitate the Matrix code", but it is too far from what i need. Because basically i'm trying to make a matrix site (this is serious, it's the main project of my graphic design school).

I need the line to fall (and not letters going down giving the illusion the line is falling). I need that the letters are generated randomly and some letters of the line change continually. the letter at the bottom must be of a brighter color, you know all that.

My problem is that i don't know how i can mix random generation of letters, Duplicate movie or attachmovie, i don't know how i'm gonna make several lines that physically fall down (but without motion tweening)!

I hope someone can help or help me find a good .fla coz i couldn't find it in the forum.


09-04-2003, 05:03 PM
I need the line to fall (and not letters going down giving the illusion the line is falling).

Not sure what you mean? You want the MC that contains the dynamic text to fall?

The problem with the matrix effect is that it requires alot of movieClips to be on stage and can eat up system resources real quick. That is the reason it is simulated probably.


09-05-2003, 04:10 AM
When you watch the matrix movie, you can see lines of maybe 10 letters that "rain"....you can see the top and the bottom - that is the whole line/block of letters.

I don't know if i have to make an mc for the block itself

I thought there are flash movies more complicated than the Matrix code so i thought maybe with actionscript i could manage it.

Is it too much if i put several MCs or dynamic text fields in another MC for a fluid animation?

My idea was to make one line and then use movieClip or something to generate all the other.
But my problem is how to generate other lines with random letters.

09-05-2003, 07:04 AM
Are you looking for somthing like this,

09-05-2003, 12:26 PM
or search from http://www.kirupa.com i think he has the matrix code there :D

09-05-2003, 12:42 PM
here is a version JGizmo did.. check it out very cool stuff.



09-05-2003, 03:11 PM
Well thank you for your feedback but maybe the closest thing i was looking for is:

Still, my aim is to understand better how to make such a script and that one is too complicated for my noob level.

So i wondered if someone could help me in making my own code.
Like how to think right.

Could you tell me if a very short script can dramatically slow down a computer (of course i'm not talking about silly scripting)?
Does a long script necessary slow down a pc?

09-05-2003, 03:58 PM
the script has little effect on the processor, it is the manipulations that are done to the stage that causes the processor to flunk. Think about it this way, look at the screen and think about all of the different points, and colors and objects that flash must render say 12 times per second. If it is a bunch of black boxes, pretty simple. 4 points, one solid fill shouldn't be too processor intensive. However if you have a bunch of jpg images of skylines and clouds with hundreds, even thousands of colors, it will take some processing to move all those objects around and display them on screen.

and that effect looks like just like the one JGizmo did, that I posted in my comment above.

09-06-2003, 07:28 AM

i'm saying that because i found some matrix code flash animations were pretty laggy, whereas there had so few MCs and more scripts that anything else.

Another question:
if i duplicate an MC with a random script, will i get the same result every time it is duplicated or is it possible to have a new random result?

I tried once and i only got copies of the first result.

If you see what I mean.

09-06-2003, 07:31 AM
btw, does using a lot of random() slow down the animation?

last question:
if we can type :


what's the use of typing:


Is there a drawback in the first one?

09-08-2003, 09:42 AM
Hey, I know you are looking to do it in actionscript, but if all else fails I used Combustion 2 to achieve the code effect.

If you have access, Combustion has the Matrix code in a Particle library, and there is a tutorial somewhere on the net (Computer Arts I think) showing how to manipulate it.

The output is in .avi or quicktime, so if you're using MX you can import it in.

Dunno if that helps at all, but thats how i got around it when i was putting together a competition to win the matrix ost.

Good luck!

09-08-2003, 12:42 PM
spyny, no drawback, u would have to use random about a hundred times in a frame to notice a major speed decrease. The only fall back of the first one compared to the second one is that the first one will return the random number times ten. A random number generated by Math.random() is between 0 and 1 (0.435234234) is an example of a random number generated by Math.random().

so the first one might return a random number like:


this will not work if we need to use the whole number and not the decimal places. Using Math.round(Math.random()*10); will return a number more like



09-09-2003, 04:17 AM
I would like a textfield to display a number (from 0 to 9) every second, for example :

onClipEvent (enterFrame) {
function cool(){
coolID=setInterval (cool, 1000);
_root.text = ran;

doesn't work as i want...

09-09-2003, 10:14 AM
spyny, that is wrong.. using that will make an interval with each passing frame. Use (load) instead..

onClipEvent(load) {
function cool(){
_root.randomNumber.text = ran;
coolID = setInterval(cool,1000);

The load event only fires once,..when the clip is loaded. So the interval is only set once.

Also make note of the change I made to your random code. I did some reading through some of senoculars posts and got some good insight on random. Using the method you provided only the number 9 50% less chance of becoming a random digit because your Math.random()*9; will never generate a number from 9.01 to 9.49 which would be rounded to 9. So using Math.floor() will give increase 9's chances..also realize that the (n)number included with Math.random()*n; will not be output by the random code when using floor, so go one number up.

And to recap on what I said about random(n) vs Math.random()*n; (thanks to some insight from senocular) random() is said to be depreciated by MM and Math.random() should be used instead, however random() is much faster.

Here is the post I was reading.. hopefully it will give you a better understanding as it did for me.



09-09-2003, 05:56 PM
that's fine, i'll try that tomorrow.

09-16-2003, 11:57 AM
i tried ur code, with a lil modification, coz i didn't really understand the

// _root.createTextField("randomNumber",1,100,100,100,100);

line, or make it work anyway.

So i managed to have something, but the animation is not smooth on my PC, sometimes, it slows down like hell and it puzzles me coz it so simple a script.

Or is there to many random numbers in a short time?

//onClipEvent (load) {
function cool() {
_root.ran = Math.ceil(Math.random()*9);
coolID = setInterval(cool, 100);

should i just make it count from 0 to 9?

09-18-2003, 10:21 AM
It is not slowing down, it is producing the same number as it just produced so you don't see an update. Trace the number and see.


09-18-2003, 11:31 AM

09-21-2003, 05:36 PM
I got onto this matrix code thing a while ago and never really finished it.. however i found some cool amtrix fonts and created a random letter thingy... heres the fla i used if anyone wants to take a look!