main content, site navigation, search

Two Color sIFR Take Two

Ed’s note: This is an outdated material. Please visit the article with a new version.

Here again Vanja reloads Two color sIFR technique—better, improved and easier to use. Here’s the article…

Based on the suggestions I’ve received, and on my own observations, I decided to revisit the topic. There are two issues that I was particularly ichy, and which I’ll try to scratch:

  • <span class="sifr-alt-color"> is not semantically correct, and it’s ugly too – thnx to Daniel Duriš
  • described technique relies on hacking source actionscript files every time a color needs to be changed. I’d like it to be a bit more flexible – thnx to Mark Wubben

Change <span> to <em>. Two things have to be done.

  1. Change the notation in html files, ie.
    <h2>This is <span class="sifr-alt-color">2 color</span> sIFR</h2>

    to

    <h2>This is <em>2 color</em> sIFR</h2>
  2. Modify javascript file (the following code exists in two locations in the javascript file, both of them have to be changed)
    } else if(oSearch.nodeName.toLowerCase() == "span" && oSearch.getAttribute("class") == "sifr-alt-color"){

    to

    } else if(oSearch.nodeName.toLowerCase() == "em"){

Part two of this session focuses on invocation part. I thought that it could be nice to be able to specify alternate color during the invocation phase. So I added another parameter to sIFR.replaceElement(). I added sAltColor after sHoverColor, so the list of parameters looks like:

function replaceElement(sSelector, sFlashSrc, sColor, sLinkColor, sHoverColor, sAltColor, sBgColor, nPaddingTop, nPaddingRight, nPaddingBottom, nPaddingLeft, sFlashVars, sCase, sWmode){

Couple of things need to be done in javascript file also. Change

function replaceElement(sSelector, sFlashSrc, sColor, sLinkColor, sHoverColor, sBgColor, nPaddingTop, nPaddingRight, nPaddingBottom, nPaddingLeft, sFlashVars, sCase, sWmode){

to

function replaceElement(sSelector, sFlashSrc, sColor, sLinkColor, sHoverColor, sAltColor, sBgColor, nPaddingTop, nPaddingRight, nPaddingBottom, nPaddingLeft, sFlashVars, sCase, sWmode){

then, after line

sHoverColor : function(value){ sHoverColor = value },

add line

sAltColor : function(value){ sAltColor = value },

and then, after line

if (sHoverColor != null){sVars += "&hovercolor=" + sHoverColor};

add line

if (sAltColor != null){sVars += "&altcolor=" + sAltColor};

That should take care of the javascript part.

The last thing we should do is handle the flash side. In the dont_customize_me.as, change:

if (placeholder.indexOf(colorDelimiter) > -1) {

to

if (altcolor != undefined && placeholder.indexOf(colorDelimiter) > -1) {

then

tempBlock += tempArray[0]+"<FONT COLOR=""+alternateColor+"">"+tempString+"</FONT>";

to

tempBlock += tempArray[0]+"<FONT COLOR=""+altcolor+"">"+tempString+"</FONT>";

and finally, reexport the movie.

You can download the uncompressed javascript source here, and actionscript file here. There is also demo page. I didn’t make the compressed version of the js file because of obvious reasons. This is by no means an attempt to fork off the main sIFR branch, it’s just a possible addition. If the guys behind sIFR decide to include the code in the next release, you’ll get the compressed version there. If not, and you still want to use this, then you’re probably into hacking yourself, and it’s not gonna be too much trouble to replace couple of spaces, cr’s and lf’s yourself : ).

28 shouts to “Two Color sIFR Take Two”

  1. Mark Wubben
    001—2005.03.16.13:38

    Sweet. There are some other things Vanja could change, though. Right now you are inserting the alternative color between the other colors. If somebody decides to switch to your code, but doesn’t use alternative colors everywhere, her old replace statements will break. If you add sAltColor as the latest argument, this won’t happen.

    Also, in the article, you forgot the “,” after the named argument mapping for sAltColor.

    Perhaps a better name for sAltColor would be sEmphasizeColor?

    I’ll discuss this with Mike to see if this is a useful addition to the main sIFR code. If that doesn’t happen, I’d like to encourage you to get this code into the compressed code of the final. And finally, there’s an RC4 out… so you might want to place a notice that your code still uses RC3. (We’re hoping to release the final soon, but I have exams coming up, so I’m not sure…)

    Again, great work.

  2. marko
    002—2005.03.16.13:48

    Mark, thanks for the “,” note. It was my mistake. I fixed it now : )

  3. dusoft
    003—2005.03.21.02:23

    Much nicer, indeed ;-) I am glad I gave some ideas.

  4. ben
    004—2005.03.29.08:14

    i just wanted to say thank you, i am using this technique on my website now.

  5. Ben Loggins
    005—2005.06.16.02:23

    It seems to break down when I export the movie. Does it matter which version of Flash?
    It works perfectly using the swf files on your site for the two color examples, but once I export a movie with the fonts I want to use it doesn’t work at all.
    I’ve downloaded the dont_customize_me.as file… what about the customize_me.as? does that remain unmodified from the original?

  6. Steve
    006—2005.06.18.11:12

    I am having the same problem as Ben…any solutions yet? I just get two “T”-s which change color and size when hovered…:(
    would be great if you could tell us what there is wrong…cheers!

  7. marko
    007—2005.06.18.11:47

    Steve and Ben, this is hack for sIFR 2.0 RC3, so it might not work with newer versions. The principle is the same, though.

  8. Steve
    008—2005.06.18.11:56

    Thx for the quick response…but I also tried it in RC3…same result…I opened a thread in the forum

    see:
    http://forum.textdrive.com/viewtopic.php?id=4181

  9. derek
    009—2005.06.23.16:36

    Cool technique.

    Is it possible to add a third color?

  10. marko
    010—2005.06.23.16:45

    derek, you can theoretically add as much colors as you want, but you’ll unfortunately have to figure it out by yourself. Vanja and I are currently out of time to try all requests we are receiving on a daily basis. After all, this was never meant to be plug᾿n’play solution, just a guidance which way to go if you want to expand sIFR’s functionality.

  11. derek
    011—2005.06.23.19:40

    Understandable.

    Just wondering.

  12. derek
    012—2005.06.23.20:17

    Quick question:

    For some reason the line:
    tempBlock += tempArray[0]+”<FONT COLOR=”"+altcolor+”">”+tempString+”</FONT>”;

    is giving me a syntax error when trying to change the ‘don’t_customize_me.as’ file

    any ideas why?

  13. graphix
    013—2005.07.15.19:17

    Has anyone figure this out on RC4 yet? I can’t seem to get it to work.

  14. joey
    014—2005.07.29.18:32

    Steve and others. The bug is in “dont_customize_me.as” hacked file on line “204″
    correct syntax is:
    colorDelimiter = “-”; // use &shy; character
    without the whitespace (!important)

  15. Jake Tracey
    015—2005.08.01.11:28

    Great technique, thanks a lot for this information. sIFR is really gaining some popularity now, which is great.

  16. eric
    016—2005.08.15.06:07

    i can’t seem to get this to work.
    It worked fine before i switched the code to the 2 color version. I took the new JS file and AS file from the links above ( i didn’t actually go through and change everyhing). But now it doesnt’ render my text anymore.

    i am not very good with code, but just need to know how to have 2 colors. Thanks for this great code.

    can’t wait to get it to work properly.

    Thanks

  17. eric
    017—2005.08.15.06:17

    you can get the link to my source files here

    http://www.palaquin.com/test/site.zip

    if anyone has the time to look. That would be of tremendous help.

    Thanks again.

  18. eric
    018—2005.08.16.08:11

    so i got it to work, but can’t get different colors, and
    tag does not work anymore…. HELP.

  19. arsart
    019—2005.09.26.13:37

    I`m trying to implement two-colors:
    1. Cant force flash to parse correctly with new dont_customize.as
    2. Same bug, as posted above: only one letter “T” appears on a page. I saw Joe`s comment about bug in *.as file, but i didn`t find any ways to correct wrong parsing of any font.
    Can anybody help with *.as file and flash parsing?

  20. Arsart
    020—2005.10.04.22:55

    Marko, i just wrote you a letter with a question about “customize_me.as” file missing for good font parsing. And after two minutes of thinking, i checked your site for this file… and i found it:))

    All:
    Use this
    customize_me.as

    and those dont_customize_me.as above in a post for a good font parsing:) (You`ll never see just “T” letter after using this files both when parsing sifr.fla)

    Thanx a lot for such a great feature.

  21. arsart
    021—2005.10.05.15:17

    Bug in New dont_customize_me.as:

    String 294 must be

    } else if(oSearch.nodeName.toLowerCase() == “br”){
    sContent += “<br/>”;
    };

    So, there is no shy-character for BR in other cases BR will not break a line

  22. arsart
    022—2005.10.05.17:03

    sorry… mispoint in above comment.
    Bug is in NEW sIFR.JS

  23. Max
    023—2005.11.13.15:03

    I love sIFR. I use it almost for all my flash now, not even just for text, also for flash elements throughout my websites such as logos, headers, navigation etc…

    I’m curious, other than the risk that someone might not have flash or javascript (enabled) is there any drawback to using sIFR (or ifr) like that?

    Also, does anyone know if there is any effect to search engine spiders? Since sIFR replaces something like < h1>SEO Rich Title< / h1> with flash, does it still read the original source html?

  24. Mike White
    024—2005.11.22.16:34

    Can we get revised as / js files with all of the bugs listed here taken care of?

  25. Arsart
    025—2005.11.22.23:50

    Mike, note that I spoke about sIFR 2.0_rc3 !
    I can’t force colouring in new sIFR relize:(

    Bthw, I’m using scalable font sizes (em) and for example 5 definitions of headline types according to their behaviour (they all about different paddings and 2 of them in different font size). Just for now 2.0rc3 working good (sometimes quirks when i need multiline headline)

  26. nrgetik
    026—2006.01.15.07:24

    Hello,

    I have encountered 1 problem using your coloring technique. When i first discovered this site, right away i went for the latest version of this solution> (2.0.1). Once i had everything setup i tried to use it with a few fonts that i have on my machine but i would alwys get box like character surrounding the first letter of my word. Color would change tho. i spent like an hour fideling with all possible combination. I also tried your swf file from teh example, now that one wouldnt have the box right characters surrounding it. so im thinking maybe its the font, i dunno. at this point i was pissed and just decided to read back on the older version. Now i can understand why you changed from span to em, messy code etc. but if it doesnt work with all the fonts i think its better to stay with the old version. i will show you my site with the font and your example with my font and your font. you can get a better idea, if you already dont know.

    Your example (new version):
    http://nrgetik.com/!upload/sifr_ex/

    My site (older version):
    http://nrgetik.com/!upload/!n3w/

  27. marko
    027—2006.01.15.14:11

    At the moment I cannot reproduce that issue. I’ll let you know if I figure it out, what might cause it.

    Also, please move the discussion to Two colors in sIFR 2.0.1.

  28. [...] [...]

main content, site navigation, search