Week 6 - Text and Field

 

The Basics

  • Director knows two types of text CastMembers: text and field.

  • Text cast members are more "modern" than the field members.

  • Both field and text members have similar properties.
  • The unique properties of the text members are anti-aliasing, kerning
  • The unique property of the field member is the fact that you can set a border with drop shadow etc.
  • click on the sprite: if it's a Text cast member, click on the "Text" tab in the property inspector.
    If it's a Field member, click on field in the property inspector. You should see the unique properties.

     

    Making Text and Field cast members editable

    If you want to process text you may want to make the text or field members editable --- this is how it's done:

    if you pull down the "Framing" menu you can make the text or field member scroll-able.

     

    What makes text and field members somewhat weird:

    So you've made your text member editable: Run the movie and start typing,
    you will see that the cast member changes along with the the text that you input into the sprite.
    This only affects the movie when you are working on it in director.
    Once you have published your movie as a projector or .dcr - this type of storage won't be happening.

     

    Now finally, working with text!

    1) the practical approach: take input and then do something with it... example
    Basically there is only one "onMouse up" -script in this example and it goes as follows:

    on mouseUp me
        member(6).text = "hello"&&member(1).text
        go to marker("scene2")
    end

    This script causes the text of member(6) to become that of member(1).
    member(1) is the text input field.
    it also adds a "hello" by going "hello"&&member(1).text

    the "&&" causes the two strings to be tied together with a space inbetween. (if you just use one "&" there will not be a space).

    also: in frame 1 of the script channel we can put a script that resets the text fields. This is makes things easier when testing.

    on exitFrame me
        member(1).text = EMPTY
        member(6).text = EMPTY
    end

     

     

    2) Getting a bit more chaotic: the typewriter effect... kind of.... example
    this typewriter-like effect is caused by a little addition to the "on mouseUp" script:

    on exitFrame me
        member(6).text = member(1).text
    end

    this has to be an "on exit frame" behavior because as the playhead constantly loops through the frame it updates the text.

     

    3) Even more chaotic: In this example, the fonts are wildly manipulated example

    on exitFrame me
        member(6).text = member(1).text

    if the key = "a" then
        member(6).color = rgb("#00FF00")
    end if

    if the key = "b" then
         member(6).fontSize = 60
    end if

    if the key = "c" then
        member(6).fontSize = 10
    end if

    if the key = "d" then
        member(6).font = "arial"
    end if

    if the key = "e" then
        member(6).font = "times"
    end if

    if the key = "f" then
        member(6).char[1].FontSize= 200
    end if

    end

    For the Verrry Advanced Ones: Downloading and Parsing XML files!

    a) Downloading

    GetNetText - the way to get internet text into director... example

    on mouseUp me
        theNetID = getNetText ("http://BigServer.com/sample.txt")
    end


    on exitFrame me
        if netDone(theNetID) then
            sprite(2).member.text = netTextResult(theNetID)
        end if
    end

     

    b) Parsing

    Check out the tutorial from macromedia on XML parsing in director

    here is an example that will get you the first three current slashdot headlines:

    example / example.html