AE ENHANCERS

Expressions/Scripts/Presets
It is currently Sun Sep 14, 2014 6:59 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: indexOf with text
PostPosted: Mon May 26, 2008 1:33 pm 
Offline

Joined: Fri Apr 04, 2008 4:28 am
Posts: 4
me again. I'm trying to use a single text layer to create subtitles. The sourceText property has this code (there's a null object called Controller with a slider to control which title shows):

Code:
a = ["Title1", "Title2", "Title3 is a bit longer\r\nso it needs to wrap around"];
n = Math.floor(thisComp.layer("Controller").effect("TextNo")("Slider"));
a[n]

I now want to change the position of the text layer based on whether the text is wrapping to two lines or not. The obvious thing seems to be to use something like

Code:
v = thisComp.layer("TitleText").text.sourceText.indexOf("\r\n");

- if v isn't -1, it's on two lines. However, this doesn't seem to work: it comes out as 1 whether the text is on two lines or not. Any ideas?

EDIT: ...sourceText.indexOf("longer") seems to work for those examples (-1 for n=0 or n=1, 16 for n=2), so it's something to do with the \r\n part. I've tried enclosing that bit in single quotes - ' - and escaping the backslashes with another backslash, but that doesn't work...

Cheers

Nick


Top
 Profile  
 
 Post subject: Re: indexOf with text
PostPosted: Mon May 26, 2008 3:57 pm 
Offline

Joined: Sat Jun 05, 2004 7:59 am
Posts: 697
Location: London, UK
It works if you change "\r\n" to "\r"

Paul


Top
 Profile  
 
 Post subject: Re: indexOf with text
PostPosted: Mon May 26, 2008 4:19 pm 
Offline

Joined: Sat Jun 26, 2004 10:01 am
Posts: 307
Location: Folsom, CA
You can also do it this way:

thisComp.layer("TitleText").text.sourceText.indexOf(String.fromCharCode(13));

Dan

_________________
http://www.motionscript.com


Top
 Profile  
 
 Post subject: Re: indexOf with text
PostPosted: Tue May 27, 2008 12:46 pm 
Offline

Joined: Fri Apr 04, 2008 4:28 am
Posts: 4
Cheers fellas!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group