Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

some scripting help..

Status
Not open for further replies.

coldfused

Technical User
Jan 27, 2001
2,442
US
guys i want to add this script into an mc but i'm not quite sure how to exactly..it is a typewriter effect using arrays..how would i input this into a mc and get it to work?

<form name=&quot;news&quot;>
<textarea name=&quot;news2&quot; cols=40 rows=4 wrap=virtual></textarea>
</form>

<script language=JavaScript>

//Typing Text (DHTML) v1 (Sunday, April 15th, 2001)
//Programmed by: Haitham M. Al-Beik
//Email: albeik99@netzero.net
//Visit for this script

var newsText = new Array();
newsText[0] = &quot;Typing Text JScript v1\nDeveloped on Sunday, April 15th, 2001...&quot;;
newsText[1] = &quot;This is a text-typing DHTML demo. \nScript featured on newsText[2] = &quot;Make sure you read the comments before you configure the script...&quot;;
newsText[3] = &quot;Programmed by: Haitham Al-Beik...\n\nCopyright (c) Haitham M. Al-Beik, 2001&quot;;
newsText[4] = &quot;
var ttloop = 1; // Repeat forever? (1 = True; 0 = False)
var tspeed = 50; // Typing speed in milliseconds (larger number = slower)
var tdelay = 1000; // Time delay between newsTexts in milliseconds

// ------------- NO EDITING AFTER THIS LINE ------------- \var dwAText, cnews=0, eline=0, cchar=0, mxText;

function doNews() {
mxText = newsText.length - 1;
dwAText = newsText[cnews];
setTimeout(&quot;addChar()&quot;,1000)
}
function addNews() {
cnews += 1;
if (cnews <= mxText) {
dwAText = newsText[cnews];
if (dwAText.length != 0) {
document.news.news2.value = &quot;&quot;;
eline = 0;
setTimeout(&quot;addChar()&quot;,tspeed)
}
}
}
function addChar() {
if (eline!=1) {
if (cchar != dwAText.length) {
nmttxt = &quot;&quot;; for (var k=0; k<=cchar;k++) nmttxt += dwAText.charAt(k);
document.news.news2.value = nmttxt;
cchar += 1;
if (cchar != dwAText.length) document.news.news2.value += &quot;_&quot;;
} else {
cchar = 0;
eline = 1;
}
if (mxText==cnews && eline!=0 && ttloop!=0) {
cnews = 0; setTimeout(&quot;addNews()&quot;,tdelay);
} else setTimeout(&quot;addChar()&quot;,tspeed);
} else {
setTimeout(&quot;addNews()&quot;,tdelay)
}
}

doNews()
</script>

<p><font face=&quot;arial&quot; size=&quot;1&quot;>This free script provided by</font><br>
<a href=&quot; face=&quot;arial,helvetica&quot; size=&quot;1&quot;>Website Abstraction</font></a></p>

e.gif


carlsatterwhite@endangeredgraphics.com
 
What's with this Carl? You into dhtml now?

;-)ldnewbie
 
into whatever i can learn how to do at the time old man..can i make this work in a mc?
e.gif


carlsatterwhite@endangeredgraphics.com
 
it uses an array to input text with the typewriter effect..it goes through each array typing the message..when it is done it moves to the next array and types that message..after talking with tulsajeff today i got to looking and now i am interested in learning how to use and set up some arrays in flash..just some more learning going on i guess..heres the link if ya wana have a look..i guess i could try to set up the arrays my self but i have never done that before..could probably set them up but not quite sure where to put the actions in reference to the mc or the timeline..does that make sense? does to me anyway..

here have a look..tell me what you think..


e.gif


carlsatterwhite@endangeredgraphics.com
 
Straight answer?
No, I don't think you can get this javascript to work as is in Flash! This is DHTML!
Other answer!
Yes! You could achieve the same effect in Flash! IMHO, even better and using arrays!
Questions?
Are you interested in this particular typewriter effect sort of thing, or do you just want to learn & play with arrays?
The basic of it is very simple, once you understand it!
An array holds elements:
myarray[0]= &quot;The TEK-TIPS forums are the best around!&quot;
myarray[1]= &quot;Nothing but gents around that RT!&quot;
myarray[2]= &quot;If you behave and don't go out of bound...&quot;
myarray[3]= &quot;You might even get invited to the party!&quot;
etc...ect...
You get the picture!
Now! In a print statement (this is just an example- no such print action exists!), rather than say print: &quot;You might even get invited to the party&quot;, you would say print: myarray[3], and it would print out the same line.

Here's another example:
In this case, my array contains 5 or 6 different mcs. This was done to insure you get a different welcome picture each time you visit that site. The actionscript generates a random number (between 1 & 5) and then calls the appropriate mc by it's index in the array and not by it's name. Get it?

The .fla is available if you want it!

;-)ldnewbie
 
the fla is not there did you post it? will be back tonight after work..
e.gif


carlsatterwhite@endangeredgraphics.com
 
got the fla..and yup i get it!!very cool stuff this whole array business..huh..learned something else today..

thanks..
e.gif


carlsatterwhite@endangeredgraphics.com
 
Hey oldnewbie,

I was wondering how you generated the random images in the above url....? I'm not too good at scripting!

Thanks,
Kitten ^_-
 
Is there a left function in Flash?...or a function to get 1 letter out of a string?...like get 1st letter, 2nd letter, etc?... ----------------------------------------
Luke WhiteTiger to the rescue!X-)
Oldnewbie: &quot;Luke, you must first learn to use the force...correctly.&quot;
Virt2001: &quot;Join the dark side&quot;%-(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top