Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-15-2007, 03:19 PM   #1
mikec44
Registered User
 
Join Date: Nov 2006
Posts: 25
Default type writer effect with sound

hi everyone, i was trying to figure out how to link sound to each character while appearing on screen using the type writer effect here is my as.

var s:Sound = new Sound ();
s.attachSound("mySound");
s.setVolume(100);
s.start()

var tf_reference = _root.tf_instance; // a reference to your text field

// typewriter effect
var runTypeWriter = function(tf, text) {
if(text.lenght < 1) return; // nothing to type
var chr_per_second = 100; // characters per second
// now the effect
tf.text = ''; // cleaning the text field
var c_int;
var c_char = 0;
var add_chr = function() {
tf.text += text.charAt(c_char);
c_char++;
if(c_char >= text.length) clearInterval(c_int); // effect done
}
c_int = setInterval(add_chr, Math.round(1000/chr_per_second));
}

// load the text
var c_load = new LoadVars();
c_load.onData = function(raw) {
if(raw == undefined) {
// could not load the file, printing error instead
runTypeWriter(tf_reference, 'File could not be loaded!');
} else {
runTypeWriter(tf_reference, raw);
}
}
c_load.load('pastor.txt');

the problem is that the sound just plays at start and not throughout the effect. any help would be appriciated
mikec44 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting data type of an object at run time J. Grady Broyles ActionScript 2.0 8 01-08-2007 10:06 PM
object position effect the panning of attached sound 00lewis ActionScript 1.0 (and below) 2 04-19-2005 04:59 AM
Dos type effect spyny Simple Stuff (Newbies) 6 09-15-2003 05:21 PM
event sound between scenes larussell Other Flash General Questions 4 07-24-2003 07:42 PM


All times are GMT. The time now is 06:42 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.