|
User Details |
message
|
|
Timothy Hall
post date:
2007-11-30 17:19:56
|
I want to use Creative TextFX to display text that will be imported OnLoad.
I have seen your example file "How_to_apply_effects_on_dynamic_text.fla", and learned how to import text using that method.
However, I am trying to create something where the remote text file will have a variable number of elements, and am trying to determine the number of elements (as if in an array) using the following method..
this.createTextField("my_txt", 10, 10, 10, 300, 100);
my_txt.autoSize = "left";
my_txt.border = false;
my_txt.multiline = true;
my_txt.wordWrap = true;
var remote_text:LoadVars = new LoadVars();
remote_text.onLoad = function (success:Boolean):Void {
if (success) {
my_parsing_txt.text = remote_text.textVar;
my_parsing_array = my_parsing_txt.split("::");
my_txt.text = my_parsing_array.length;
} else {
my_txt.text = "Unable to load external file.";
}
}
/* contents of uni.468x60.txt:
textVar=Effect for button 3::Effect for button 2::Effect for button 1
*/
remote_text.load("http://www.flobeds.com/whatsthebest/uni.468x60.txt");
I intend to loop through the array, each time calling a function the invokes TextFX.
There are already problems here, and I hope you can give me a little advise.
The line above "my_txt.text = my_parsing_array.length;" returns "Undefined" instead of the number of values in the my_parsing_array. I was expecting a value of 3.
Admittedly, I am not much of an Actionscript programmer - can you please tell me what I am doing wrong?
I would greatly appreciate your assistance.
Then, I will need to complete the script so that as it loops through each element of the array it will trigger Creative TextFX with the current value of the array as the text to act upon; and will do so in a way that it will allow the effect to finish before either going on to the the next iteration of the loop - or, if it just finished with the last element in the array , will exit the loop.
|
|
|
Monica Chitu [Extend Studio]
post date:
2007-12-03 07:38:45
|
Hello Timothy,
In order for us to be able to help you, it would be best if you could also send us the .fla you are working on.
Regards,
Monica Chitu.
|
|
|
Timothy Hall
post date:
2007-12-03 12:31:48
|
|
Thank you - I just sent it in an email.
|
|
|
Monica Chitu [Extend Studio]
post date:
2007-12-04 05:57:27
|
Hello Timothy,
We have just sent you an email with the file with the solution to your problem attached to it.
Best regards,
Monica Chitu.
|
|
|
Timothy Hall
post date:
2007-12-04 12:01:27
|
Thank you for this solution.
I thought I would post it here for all to see..
HERE IT IS ======
this.createTextField("my_txt",300,10,10,300,100);
my_txt.autoSize = "left";
my_txt.border = false;
my_txt.multiline = true;
my_txt.wordWrap = true;
var remote_text:LoadVars = new LoadVars();
remote_text.onLoad = function(success:Boolean):Void {
if (success) {
my_parsing_txt = remote_text.textVar;
my_parsing_array = my_parsing_txt.split("::");
my_txt.text = my_parsing_array.length;
reInit();
} else {
my_txt.text = "Unable to load external file.";
}
};
/* contents of uni.468x60.txt:
textVar=Effect for button 3::Effect for button 2::Effect for button 1
*/
remote_text.load("http://POINT_THIS_TO_YOUR_OWN_REMOTE_TEXT_FILE.txt");
//--------------------------------------------------------------------
initObj = new Object();
var counter:Number = 0;// this counter is used for going trough the array from above
function reInit() {
//component initialization
initObj = new Object();
initObj._effect = "bounce";
initObj.textParams = new Object();
initObj.effectParams = new Object();
initObj.effectParams.yMove = -100;
initObj.textParams.embed = true;
initObj.textParams.font = "Arial";
initObj.textParams.size = "12";
initObj.gradColors = new Object();
initObj.gradColors.color = ("#c62f38", "#5C407A");
initObj.gradColors.alpha = ("100", "100");
initObj.gradColors.ratio = "90";
initObj.spacing = 0;
initObj._duration = 50;
initObj._overlap = 90;
initObj._x = 15;
initObj._y = 25;
this.initObj.text = my_parsing_array[counter];
_global["bounceEffect"] = xtd.effects.text.bounceEffect;
this.attachMovie("Creative TextFX","te",10,_root.initObj);
te.initEffect();
te.startEffect();
//Counter test - this counter is responsible for telling which text from the array to display
if (counter < my_parsing_array.length-1) {
counter = counter+1;
} else {
counter = 0;
}
te.onEffectFinished = function() {
te.reverseEffect();
};
te.onReverseFinished = function() {
//removes the last instace to free up resources
removeMovieClip(_root.te);
//re initialization
reInit();
};
}
|
|
|
Timothy Hall
post date:
2007-12-04 12:25:28
|
THANK YOU SO MUCH - that was precisely what I needed.
One thing I forgot to ask about though..
Is there a parameter I can set to tell it to wait x-number of seconds before performing the reverse step?
And (probably the same method, but) is there a way to tell it to pause between elements in the array?
The idea here is this..
Since the length of the text will vary (within certain limits), I was thinking of writing something that would count the number of characters in each element of the text array, and then based on that text length would augment a minimum pause value by some factor - in other words, the longer the text, the longer the pause before the text reverses away; giving the reader time to absorb the longer text before the next text would come in.
A second (additional) argument would be needed to set a default wait period between the text elements.
I can write the additional code if you can tell me how to impose the waits.
And thank you for taking the time to explain this to me.
PS: I wanted to share this knowledge with other users in this forum, and posted your email reply here as well.
|
|
|
Monica Chitu [Extend Studio]
post date:
2007-12-05 08:17:19
|
Hello Timothy,
What you should do, is use the setInterval function (more about it you can find in the Flash help), it's a Flash function. You should put this function in onEffectFinished, in order to delay the reverse and onReverseFinished, in order to achieve a bigger pause.
Sincerely,
Monica Chitu.
|
|