Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
QTGrabSprite
Director Web
Play and Review Flash
Checking for an internet connection
Move sprite along mouse vector Behavior
Masking Digital Video
FrameReady()
JTMR Image to Text
ADO Xtra For MUS
SpellerRT
 

 

 

Behavior CTRL+B, CTRL+I, CTRL+U

Added on 4/1/2003

 

Compatibilities:
behavior D8_5 D9 PC

This item has not yet been rated

Author: Sander Falise

Allows the user to format text fields using CTRL+B (bold), CTRL+I (italic) and CTRL+U (underline). A behavior with the same functionality has been contributed before (http://www.mediamacros.com/item/item-959358086/) but mine is a bit different using the selectedText property instead of the selection function. Drag and drop onto a text member or attach by script using textFormat = script("textFormat").new(me.spriteNum) sprite(me.spriteNum).scriptInstanceList.add(textFormat)

property spriteNum, sNum, sMem, k

on new me, s
  if ilk(s) = #integer then me.spriteNum = s
  me.sNum = sprite(me.spriteNum)
  me.sMem = me.sNum.member
  return me
end

on enterFrame me
  if the controlDown and the clickOn = me.spriteNum and me.sMem.editable = 1 then
    s = member(me.sMem).selectedText
    t = member(me.sMem).text
    if keyPressed("b") and me.k = 0 then
      me.k = 1
      member(me.sMem).selectedText.fontStyle = me.setStyle(s, "bold")
    else if keyPressed("i") and me.k = 0 then
      me.k = 1
      member(me.sMem).selectedText.fontStyle = me.setStyle(s, "italic")
    else if keyPressed("u") and me.k = 0 then
      me.k = 1
      member(me.sMem).selectedText.fontStyle = me.setStyle(s, "underline")
    end if
    if the keyPressed = "" then
      me.k = 0
    end if  
  else
    me.k = 0
  end if
end

on setStyle me, sel, sty
  if ilk(sty) <> #symbol then sty = symbol(sty)
  s = sel.fontStyle
  if s.getOne(#plain) <> 0 then s = []
  if s.getOne(sty) <> 0 then
    s.deleteOne(sty)
  else
    s.add(sty)    
  end if
  return s
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail