I've been playing around trying to create a little text slider effect, that
takes a string splits it up into an array based on a character limit, and
then animates through them in a loop.

Now, I have got the animation down (could probably be improved, but it
works) but I'm having a few problems with my javascript. The string splits
on the amount of characters, but the resulting array is not in the correct
order. So all the text gets displayed in a random order.

I've attached the comp, but here is the troublesome javascript.

function (__structure stringResult) main (__number charLimit, __string
terms)
{
var result = new Object();
 var termsArray = new Array();
var stringLength = 0;
 var stringArray = new Object();
var stringInc = 0;
 termsArray = terms.split(" ");
 for(var i in termsArray) {
 stringLength += termsArray[i].length + 1;
if (stringLength > charLimit) {
 stringLength = 0;
stringInc += 1;
 }
 if (stringArray[stringInc] == null) {
stringArray[stringInc] = termsArray[i];
 } else {
stringArray[stringInc] += " "+termsArray[i];
 }
}
 result.stringResult = stringArray;
return result;
}

I would prefer it if the string was constrained by it's rendering width,
rather than just a character limit. It would also be good to be able to put
in the text markers where the text should or shouldn't break.

Thanks in advance.
Charlie

Attachment: text_flip_new.qtz
Description: Binary data

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      (Quartzcomposer-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to