/flowplayer/branches/3_2_6/src/actionscript/org/flowplayer/model/DisplayPluginModelImpl.as

http://flowplayer-core.googlecode.com/ · ActionScript · 114 lines · 72 code · 22 blank · 20 comment · 0 complexity · d60d6deb4748d1582b3baa94c88dbce7 MD5 · raw file

  1. /*
  2. * Copyright (c) 2008-2011 Flowplayer Oy *
  3. * This file is part of Flowplayer.
  4. *
  5. * Flowplayer is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Flowplayer is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. package org.flowplayer.model {
  19. import flash.display.DisplayObject;
  20. import org.flowplayer.model.Cloneable;
  21. /**
  22. * @author api
  23. */
  24. public class DisplayPluginModelImpl extends DisplayPropertiesImpl implements DisplayPluginModel {
  25. private var _config:Object;
  26. private var _methods:Array = new Array();
  27. private var _builtIn:Boolean;
  28. private var _url:String;
  29. public function DisplayPluginModelImpl(disp:DisplayObject, name:String, setDefaults:Boolean = true):void {
  30. super(disp, name, setDefaults);
  31. }
  32. public function addMethod(method:PluginMethod):void {
  33. _methods.push(method);
  34. }
  35. public function getMethod(externalName:String):PluginMethod {
  36. return PluginMethodHelper.getMethod(_methods, externalName);
  37. }
  38. public function invokeMethod(externalName:String, args:Array = null):Object {
  39. return PluginMethodHelper.invokePlugin(this, getDisplayObject(), externalName, args);
  40. }
  41. public function get config():Object {
  42. return _config;
  43. }
  44. public function set config(config:Object):void {
  45. _config = config;
  46. }
  47. public function set visible(visible:Boolean):void {
  48. super.display = visible ? "block" : "none";
  49. }
  50. override protected function copyFields(from:DisplayProperties, to:DisplayPropertiesImpl):void {
  51. super.copyFields(from, to);
  52. DisplayPluginModelImpl(to).config = DisplayPluginModelImpl(from).config;
  53. DisplayPluginModelImpl(to).methods = DisplayPluginModelImpl(from).methods;
  54. DisplayPluginModelImpl(to).isBuiltIn = DisplayPluginModelImpl(from).isBuiltIn;
  55. }
  56. public override function clone():Cloneable {
  57. var copy:DisplayPluginModelImpl = new DisplayPluginModelImpl(getDisplayObject(), name);
  58. copyFields(this, copy);
  59. return copy;
  60. }
  61. public function get methods():Array {
  62. return _methods;
  63. }
  64. public function set methods(values:Array):void {
  65. _methods = values;
  66. }
  67. [Value(name="methods")]
  68. public function get methodNames():Array {
  69. return PluginMethodHelper.methodNames(_methods);
  70. }
  71. public function get pluginObject():Object {
  72. return getDisplayObject();
  73. }
  74. public function set pluginObject(pluginObject:Object):void {
  75. setDisplayObject(pluginObject as DisplayObject);
  76. }
  77. [Value(name="builtIn")]
  78. public function get isBuiltIn():Boolean {
  79. return _builtIn;
  80. }
  81. public function set isBuiltIn(value:Boolean):void {
  82. _builtIn = value;
  83. }
  84. [Value]
  85. public function get url():String {
  86. return _url;
  87. }
  88. public function set url(url:String):void {
  89. _url = url;
  90. }
  91. }
  92. }