Re: Digest for bristol-flash-user-group@googlegroups.com - 15 Messages in 3 Topics

5 views
Skip to first unread message

Russell Kirkland

unread,
Sep 10, 2011, 5:02:37 AM9/10/11
to bristol-flas...@googlegroups.com, Digest Recipients
Hey Sam

You should be able to get precise coords using text line metrics, and you can use text events to fire events:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextLineMetrics.html

Good to see you the other night, have fun at FOTB!

Russ. 

On 10 Sep 2011, at 09:43 AM, bristol-flas...@googlegroups.com wrote:

Group: http://groups.google.com/group/bristol-flash-user-group/topics

    Sam <sam.mc...@gmail.com> Sep 09 03:08AM -0700 ^
     
    Hello BFUG,
     
    Very good to see a lot of you last night. Good times indeed.
     
    I have a technical issue with an interaction coming up that I wondered
    if anyone had any input on. Basically, it's a game where the user
    needs to identify, and change, sections or words of text in paragraphs
    of text by clicking on the offending items. The client needs to be
    able to update and change the content and functionality themselves at
    a later date so all content will be stored in xml. This cannot be done
    in a quick and dirty way by putting invisible hotspots over a static
    text field. I also cannot parse through the text and make mcs out of
    each word and then layout the text dynamically that way.
     
    I need to find a way of getting the coordinates of specific words or a
    word, creating hotspots over those coordinates and then being able to
    update the words with the correct or chosen versions. I also need to
    empower the client to generate this functionality through the xml. Has
    anyone any tips or advice on how to do this? Issues come to mind with
    things like..... how would it work if the clickable phrase was cut in
    half by a line break? How would I create the xml so that it's easy for
    someone to designate functionality and choices within paragraphs of
    text? And then..... how would I integrate the changes into that text
    at the right places and then reupdate the hotspots for other
    interactive sections of that text?
     
    Thanks,
     
    Sam

     

    David James <da...@djgd.co.uk> Sep 09 11:31AM +0100 ^
     
    Of the top of my head;
     
    you split the text string usng textString.split(" ") or similar and create
    movieclips out of every word, you can use the cumulitive width of all the
    words to find ut where line breaks exist - for selecting which words would
    be clickable you could use some other character to look for in the text
    string like tubes: | or use xml tags
     
    <string> text here <highlight> make this selectable </highlight> carry on
    with text here</string>
     
     
     

     

    barnaby menage <barn...@gmail.com> Sep 09 11:31AM +0100 ^
     
    how about:
     
    - putting a full stop in different colours e.g. red at start of word
    and green at end
    - saving the text area as bitmap data
    - process the bitmap to get the x and y coords based on the colour values
    - dynamically place movieclips hotspots based on that
     
    best
     
    barnaby
     
     
     
     
     

     

    Aden Forshaw <aden.f...@gmail.com> Sep 09 11:39AM +0100 ^
     
    And if you need to find the character under a give X/Y i.e. on mouse click,
    then getCharIndexAtPoint should be your friend there.
     
     
    Great to see so many there last night btw.
     
    Laters, Aden
     
     
    --
    Skype: aden.forshaw
    Mobile: 07595 152418

     

    Ben Bath <ben.o...@googlemail.com> Sep 09 04:50AM -0700 ^
     
    //how about this? does not account for words that run over two lines
    though
     
     
    import flash.text.TextField;
    import flash.geom.Rectangle;
    import flash.display.Sprite;
     
    var tf:TextField = new TextField();
    tf.width = 200;
    tf.height = 100;
    addChild(tf);
     
    var text:String = "sdkfhj asdlfkjhasdf kjhsdfjasdf sdkjhsd sdkljhsdf
    sadfkjhsdf sdf";
    var lookup:String = "sdfjas";
     
    tf.text = text;
    var index:int = text.indexOf(lookup);
     
    var rect:Rectangle;
    var rect1:Rectangle = tf.getCharBoundaries(index);
    var rect2:Rectangle = tf.getCharBoundaries(index+lookup.length-1);
     
    rect = rect1.union(rect2);
     
    var s:Sprite = new Sprite();
    s.graphics.beginFill(0,.3);
    s.graphics.drawRect(rect.x,rect.y,rect.width,rect.height);
    addChild(s);

     

    Ben Bath <ben.o...@googlemail.com> Sep 09 04:55AM -0700 ^
     
    //how about this. Problem if word wraps. Also could use special chars
    that are replaced to avoid duplicate matches in a String.
    .
    import flash.text.TextField;
    import flash.geom.Rectangle;
    import flash.display.Sprite;
     
    var tf:TextField = new TextField();
    tf.width = 200;
    tf.height = 100;
    addChild(tf);
     
    var text:String = "sdkfhj asdlfkjhasdf kjhsdfjasdf sdkjhsd sdkljhsdf
    sadfkjhsdf sdf";
    var lookup:String = "sdfjas";
     
    tf.text = text;
    var index:int = text.indexOf(lookup);
     
    var rect:Rectangle;
    var rect1:Rectangle = tf.getCharBoundaries(index);
    var rect2:Rectangle = tf.getCharBoundaries(index+lookup.length-1);
     
    rect = rect1.union(rect2);
     
    var s:Sprite = new Sprite();
    s.graphics.beginFill(0,.3);
    s.graphics.drawRect(rect.x,rect.y,rect.width,rect.height);
    addChild(s);

     

    "s'unya" <sunya....@gmail.com> Sep 09 02:14PM +0100 ^
     
    > s.graphics.drawRect(rect.x,rect.y,rect.width,rect.height);
    > addChild(s);
     
    > --
     
    Hi,
     
    That is about it. To deal with wrapping words you could look at the index of
    the start and end character of your search string to see if the y values has
    changed. If they are then you will need to split your sprite.
     
    Sorry no code; I'm a bit busy
    --
    o
    o o
    O O O
    o o O s´unya O o o

     

    Ben Bath <ben.o...@googlemail.com> Sep 09 06:29AM -0700 ^
     
    //ok more like this then...
    import flash.text.TextField;
    import flash.geom.Rectangle;
    import flash.display.Sprite;
    import flash.display.BlendMode;
     
    var tf:TextField = new TextField();
    tf.wordWrap = true;
    tf.width = 100;
    tf.height = 300;
    addChild(tf);
     
    var text:String = "sdkfhj asdlfkjhasdf kjhsdfjasdf sdkjhsd sdkljhsdf
    sadfkjhsdf sdf";
    var lookup:String = "asdlfkjhasdf kjhsdfjasdf sdkjhsd sdkljhsdf s";
     
    tf.text = text;
    var index:int = text.indexOf(lookup);
     
    var rect:Rectangle;
    var rect1:Rectangle = tf.getCharBoundaries(index);
    var rect2:Rectangle = tf.getCharBoundaries(index+lookup.length-1);
     
    rect = rect1.union(rect2);
     
    var s:Sprite = new Sprite();
    addChild(s);
    s.alpha = .4;
    switch(true){
    case rect1.y==rect2.y:
    //single line
    s.graphics.beginFill(1);
    s.graphics.drawRect(rect.x,rect.y,rect.width,rect.height);
    s.graphics.endFill();
    break;
    case rect1.bottom<rect2.y:
    //more than two lines fill full width gap
    rect = new Rectangle(tf.x,rect1.bottom,tf.width,rect2.top-
    rect1.bottom);
    s.graphics.beginFill(1);
    s.graphics.drawRect(rect.x,rect.y,rect.width,rect.height);
    s.graphics.endFill();
    //NB no break statement
    case rect1.bottom==rect2.y:
    //top and bottom rectangles
    rect = rect1.union(new Rectangle(tf.x+tf.width-1,rect1.y,1,1));
    s.graphics.beginFill(0);
    s.graphics.drawRect(rect.x,rect.y,rect.width,rect.height);
    s.graphics.endFill();
    rect = rect2.union(new Rectangle(tf.x,rect2.y,1,1))
    s.graphics.beginFill(0);
    s.graphics.drawRect(rect.x,rect.y,rect.width,rect.height);
    s.graphics.endFill();
    break;
    }
     

     

    Sam <sam.mc...@gmail.com> Sep 09 06:50AM -0700 ^
     
    Thanks everyone for your input, it is much appreciated and really helpful. I
    have lots of solid direction now. I'm not going to get properly stuck into
    until after FOTB so I'll let you know how it goes.
     
    Cheers,
     
    Sam

     

 Topic: Hello
    Graham <gra...@sibdev.co.uk> Sep 09 04:17AM -0700 ^
     
    Hello all,
     
    Good to de-lurk and meet you last night.
     
    I thought I'd tentatively venture my showreel for feedback... also I
    am freelance and always interested in making new contacts.
     
    http://www.graylo.net/showreel
     
    Graham

     

    David James <da...@djgd.co.uk> Sep 09 11:03AM +0100 ^
     
    Great to catch up with everyone at Bfug (which seemed to be characterised by
    the complete lack of any talk about flash itself)
     
    We should have a debrief after for flash on the beach for all those
    unfortunate enough not to be attending
     
    David
     

     

--
You received this message because you are subscribed to the Google Groups "Bristol Flash User Group" group.
To post to this group, send email to bristol-flas...@googlegroups.com.
To unsubscribe from this group, send email to bristol-flash-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bristol-flash-user-group?hl=en.
Reply all
Reply to author
Forward
0 new messages