def self.add_event(class_name,event)
event_class = event[1].attributes["Class"]
event_type = event[1].attributes["Type"]
method = event.attributes["Name"]
class_name.add_method(shift_case(method)) do
|*argv|
options = argv.shift || {}
properties = REXML::Document.new event.to_s
options.each_pair do |key, value|
properties.elements.each("Event/Property") do |property|
if(property.attributes["Name"] == shift_case(key.to_s, true))
property.attributes["DefaultValue"] = value
end
end
end
if(options[:wait] != nil)
count = options[:wait]
new_event = flex_object.addevent(event_type, event_class, @id, properties.to_s)
while((new_event != nil || new_event == "Not synchronized")&& count > 0)
sleep(1)
count = count - 1
new_event = flex_object.addevent(event_type, event_class, @id, properties.to_s)
end
else
new_event = flex_object.addevent(event_type, event_class, @id, properties.to_s)
if(new_event == "Not synchronized")
count = $wait_sync
while(new_event == "Not synchronized" && count > 0)
sleep(1)
count = count -1
new_event = flex_object.addevent(event_type, event_class, @id, properties.to_s)
end
end
end
raise new_event unless new_event == nil
is_sync
sleep(funfx.speed)
end
end