# Matrix effect not working in MX 2004

**URL:** <https://forum.kirupa.com/t/matrix-effect-not-working-in-mx-2004/194410>\
**Category:** flash\
**Created:** [July 23, 2006, 2:25am UTC](https://forum.kirupa.com/t/matrix-effect-not-working-in-mx-2004/194410 "2006-07-23T02:25:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fishman9](https://avatars.discourse-cdn.com/v4/letter/f/e19adc/32.png) [@fishman9](https://forum.kirupa.com/u/fishman9)\
**Post date:** [July 23, 2006, 2:25am UTC](https://forum.kirupa.com/t/matrix-effect-not-working-in-mx-2004/194410/1 "2006-07-23T02:25:12Z")

</div>

**Update** \*\* I partially figured out what was causing this not to working MX 2004. See code changes below. Flash 7 did not know how to handle the undefined variables (+this.dep, this.dep++) or (+i,i++) in the createEmptyMovieClip. Had to change then to this.getNextHighestDepth(). However this is causing the color change routine not to work since there is no true depth number assigned. Setting up a trace to view color change the color change returns undefined. The script does not seem to know which instance of the MC to apply the color change to since there are multiple dynamic MC’s

If someone knows how to correct this it would be a big help!!

* * *

I have been playing with the different examples of the Matrix code effect when I found the one created by Ilyas USAL (pom) who I see posts to this forum in the past. So I am hoping POM sees this or someone who know POM will let him or her know I could use some advice on how to get this to work with MX 2004.

Here is the original code:  
Layer 1 Frame 1

// To make it run smoother  
\_quality = “MEDIUM”;

// String containing all the characters available in the font  
letters\_str = “abcdefghijkl1234567890,;:!?./$” ;  
length\_num = letters\_str.length ;

Layer 2 Frame 1

/\*\*\* Functions \*\*\*/  
// fade out and remove clip when \_alpha inferior to 10 - no parameters  
function fadeToBlack(){  
this.\_alpha -= 5;  
if (this.\_alpha \< 10){  
delete this.onEnterFrame;  
this.removeMovieClip();  
}  
};  
// color fade from white to the original color  
function whiteToGreen(){  
this.\_alpha -= 3;  
if (this.rb \< 2 && this.gb \< 2 && this.bb \< 2){  
this.rb = this.gb = this.bb = 0;  
delete this.onEnterFrame;  
}  
else {  
this.rb \*= .9;  
this.gb \*= .9;  
this.bb \*= .9;  
}  
var trans = {rb:this.rb , gb:this.gb , bb:this.bb};  
this.col.setTransform(trans);  
};  
// Create a new clip with a letter in it  
// x: \_x position ; y: \_y position ; size: size of the letter  
MovieClip.prototype.createLetter = function (x,y,size){  
// Create and position the new clip  
[COLOR=Blue]//var mc = this.createEmptyMovieClip(“letter”+this.dep,this.dep++); old code [/COLOR]  
[COLOR=Red] var mc = this.createEmptyMovieClip(“letter”,this.getNextHighestDepth()); New code[/COLOR]  
mc.\_x = x;  
mc.\_y = y;  
// Create a new TextField in the clip  
mc.createTextField(“t”,0,0,0,size,size);  
// Choose a random letter  
var myChar = letters\_str.charAt(random(length\_num));  
mc.t.text = myChar;  
// Create the TextFormat, format the text and embed the font  
var tf = new TextFormat();  
tf.size = size;  
tf.font = “Katakana”;  
tf.selectable = false;  
tf.color = “0x00ff00”;  
mc.t.setTextFormat(tf);  
mc.t.embedFonts = true;  
// Letter goes from white to green  
mc.rb = mc.gb = mc.bb = 255;  
mc.col = new Color (mc) ;  
mc.col.setTransform({rb:255 , gb:255 , bb:255});  
mc.onEnterFrame = whiteToGreen;  
};  
// Create a trail of letters  
function createTrail(){  
// Create new clip and position it randomly  
[COLOR=Blue]//var clip = this.createEmptyMovieClip(“trail”+i,i++); old code[/COLOR]  
[COLOR=Red] var clip = this.createEmptyMovieClip("trail"this.getNextHighestDepth()); new code[/COLOR]  
clip.\_x = Math.round(random(Stage.width)/10)\*10;  
clip.\_y = clip.y = -10;  
// Choose a random size for the letters, and set the spacing  
var size = random(10)+15;  
clip.spacing = size ;  
// onEnterFrame, create a new letter that will wade out.  
// if we’re at the bottom of the screen, fade out the whole trail  
clip.onEnterFrame = function(){  
this.y += this.spacing;  
this.createLetter(0,this.y,size);  
if (this.y \> Stage.height) this.onEnterFrame = fadeToBlack;  
};  
};

Layer 3 Frame 1

// Create a new trail every 100 milliseconds  
setInterval(this,“createTrail”,100);

I like the simplicity of the code and I have a good understanding of how it is working. I have even made changes to get different effects and have embedded it in other flash movies I have played with to see if I could.

The problem is as follows. If I set my publish environment to Flash player 6 and actionscript 1.0 everything works fine. If I change the publish environment to Flash player 7 and actionscript 1.0 or 2.0 then the effect no longer functions correctly. There appears to be some variable or element that needs to be change. The Flash 7 compiler does not seem to parse the code in the same way the Flash 6 compiler is.

I get random single characters but no trailing characters. I slowed the timing down so I could see what was happening and everything but the colored characters is appearing. Stepping through the code revealed that the function whiteToGreen() does not appear to be working correctly or being called correctly.

Looking for someone with more knowledge in this than me. Hopefully the author will see this and know how to correct it.

Thanks  
Fishman9
