Module: FN::SWF::Node::Text

Includes:
Node::Base
Defined in:
lib/fn/swf/node/text.rb

Constant Summary collapse

SPACE =
/\s+/

Constants included from Node::Base

Node::Base::CURRENT_PAGE_HEIGHT, Node::Base::CURRENT_PAGE_WIDTH

Instance Method Summary collapse

Methods included from Node::Base

#classify, #has_no_children, #mixin, #value, #visit_children, #with_attributes_like

Instance Method Details

#escaped_textObject



26
27
28
# File 'lib/fn/swf/node/text.rb', line 26

def escaped_text
  text.gsub("\\", "\\\\").gsub("\"", "\\\"").gsub(SPACE, " ")
end

#textObject



17
18
19
# File 'lib/fn/swf/node/text.rb', line 17

def text
  (child && child.content).to_s
end

#text=(s) ⇒ Object



21
22
23
24
# File 'lib/fn/swf/node/text.rb', line 21

def text=(s)
  self.children.map{|c| c.remove! }
  self << XML::Node.new_cdata(s)
end

#visit(struct, debug = false) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fn/swf/node/text.rb', line 30

def visit(struct, debug = false)
  has_no_children
  name = "#{self[:text]}_#{self[:index]}"
  x = self[:x]
  y = self[:y]
  w = self[:width]
  h = self[:height].to_i + 20 # Fudge
   
  struct.<< ".action:" do
 struct << "this.createTextField('#{name}', #{$depth+=1}, #{x}, #{y}, #{w}, #{h});"
	struct << "id = this['#{name}'];"
	struct << "id.html=true;"
	struct << "id.multiline=true;"
	struct << "id.wordWrap=true;"
	struct << "id.htmlText = \"#{escaped_text}\";"
	struct << "id.selectable = false;"
    			end
end