PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/flash/multiupload/multiupload/src/sina/ui/controls/Item.as

http://chenjin.googlecode.com/
ActionScript | 713 lines | 624 code | 83 blank | 6 comment | 90 complexity | e23da9aacdb5665b5de5c5e1bd2f0452 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. package sina.ui.controls
  2. {
  3. import com.adobe.serialization.json.JSON;
  4. import com.adobe.serialization.json.JSONParseError;
  5. import flash.display.Bitmap;
  6. import flash.display.BitmapData;
  7. import flash.display.GradientType;
  8. import flash.display.Graphics;
  9. import flash.display.Loader;
  10. import flash.display.Sprite;
  11. import flash.events.DataEvent;
  12. import flash.events.Event;
  13. import flash.events.HTTPStatusEvent;
  14. import flash.events.IOErrorEvent;
  15. import flash.events.MouseEvent;
  16. import flash.events.ProgressEvent;
  17. import flash.events.SecurityErrorEvent;
  18. import flash.geom.Matrix;
  19. import flash.net.FileReference;
  20. import flash.net.URLLoader;
  21. import flash.net.URLRequest;
  22. import flash.net.URLRequestMethod;
  23. import flash.net.URLVariables;
  24. import flash.text.TextField;
  25. import flash.text.TextFieldAutoSize;
  26. import flash.text.TextFormat;
  27. import flash.utils.*;
  28. import nl.demonsters.debugger.MonsterDebugger;
  29. import sina.ui.events.ItemEvent;
  30. import sina.ui.skin.AllSkins;
  31. import sina.ui.skin.DeleteIcon;
  32. import sina.ui.skin.UploadedIconComplete;
  33. import sina.ui.skin.UploadedIconError;
  34. /**
  35. * @author mole<mole1230@gmail.com>
  36. * @version $Id: Item.as 7 2010-10-19 10:38:30Z mole1230 $
  37. */
  38. public class Item extends Sprite
  39. {
  40. public static const WIDTH:Number = 96;
  41. public static const HEIGHT:Number = 96;
  42. public static const ROTATE_CW:String = "rotate_cw";
  43. public static const ROTATE_ACW:String = "rotate_acw";
  44. public static const UPLOAD_STATUS_NORMAL:String = "upload_status_normal";
  45. public static const UPLOAD_STATUS_SIZE_ERROR:String = "upload_status_size_error";
  46. public static const UPLOAD_STATUS_PRELOAD_ERROR:String = "upload_status_preload_error";
  47. public static const UPLOAD_STATUS_FAILURE:String = "upload_status_failure";
  48. public static const UPLOAD_STATUS_SUCCESS:String = "upload_status_success";
  49. public static const UPLOAD_STATUS_UPLOADING:String = "upload_status_uploading";
  50. public static const UPLOAD_STATUS_WAITING:String = "upload_status_waiting";
  51. private const AVIABLE_STATUS_NORMAL:String = "aviable_status_normal";
  52. private const AVIABLE_STATUS_SIZE_ERROR:String = "aviable_status_size_error";
  53. private const AVIABLE_STATUS_PRELOAD_ERROR:String = "aviable_status_preload_failure"
  54. private const COLOR_BORDER:uint = 0xB4B4B4;
  55. private const COLOR_FILL:uint = 0xFFFFFF;
  56. private const COLOR_FILL_GRAY:uint = 0xE7E7E7;
  57. private const SELECT_MASK_Y:Number = 2;
  58. private var _fp:int = 10;
  59. private var _maxSize:Number = 3;
  60. private var _uploadUrl:String = "";
  61. private var _index:int
  62. private var _delay:Number;
  63. private var _fileReference:FileReference;
  64. private var _fileUrlLoader:URLLoader;
  65. private var _percent:Number = 0;
  66. private var _requestVariables:Object = { };
  67. private var _logFailTime:String = "0";
  68. private var _json:Object = { };
  69. private var _preloadProgress:Sprite;
  70. private var _previewLoader:Loader;
  71. private var _imgWidth:Number = 0;
  72. private var _imgHeight:Number = 0;
  73. private var _previewerBitMap:Bitmap;
  74. private var _preloaded:Boolean = false;
  75. private var _rotationAngle:Number = 0;
  76. private var _waitMask:Sprite;
  77. private var _errorMask:Sprite;
  78. private var _errorMaskText:TextField;
  79. private var _available:String = AVIABLE_STATUS_NORMAL;
  80. private var _selected:Boolean = false;
  81. private var _selectMask:Sprite;
  82. private var _deleteIcon:Sprite;
  83. private var _closewiseBtn:Button;
  84. private var _anticlosewiseBtn:Button;
  85. private var _progressBar:Sprite;
  86. private var _skins:AllSkins = new AllSkins();
  87. private var _uploadStatus:String = UPLOAD_STATUS_NORMAL;
  88. public static function isValidPreviewFileType(type:String):Boolean
  89. {
  90. var types:Array = [".jpg", ".jpeg", ".gif", ".png"];
  91. return (types.indexOf(type.toLowerCase()) > -1);
  92. }
  93. public function Item()
  94. {
  95. _addBg();
  96. }
  97. public function starPreload():void
  98. {
  99. if (_preloaded) {
  100. dispatchEvent(new Event(ItemEvent.PRELOAD_COMPLETE, true));
  101. return;
  102. }
  103. if (_fileReference.size > _maxSize * 1024 * 1024) {
  104. _addErrorMask("????" + _maxSize + "M");
  105. _preloaded = true;
  106. _available = AVIABLE_STATUS_SIZE_ERROR;
  107. dispatchEvent(new Event(ItemEvent.PRELOAD_COMPLETE, true));
  108. } else {
  109. if (_fp >= 10 && isValidPreviewFileType(_fileReference.type)) {
  110. try {
  111. _fileReference.load();
  112. } catch (e:Error) {
  113. _preloaded = true;
  114. _available = AVIABLE_STATUS_PRELOAD_ERROR;
  115. _noPreview();
  116. dispatchEvent(new Event(ItemEvent.PRELOAD_COMPLETE, true));
  117. }
  118. } else {
  119. _preloaded = true;
  120. _available = AVIABLE_STATUS_PRELOAD_ERROR;
  121. _noPreview();
  122. dispatchEvent(new Event(ItemEvent.PRELOAD_COMPLETE, true));
  123. }
  124. }
  125. }
  126. public function startUpload():void
  127. {
  128. dispatchEvent(new Event(ItemEvent.UPLOAD_START, true));
  129. if (_available == AVIABLE_STATUS_SIZE_ERROR) {
  130. uploadStatus = UPLOAD_STATUS_SIZE_ERROR;
  131. dispatchEvent(new Event(ItemEvent.UPLOAD_SIZE_ERROR, true));
  132. dispatchEvent(new Event(ItemEvent.UPLOAD_COMPLETE, true));
  133. } else {
  134. _uploadStatus = UPLOAD_STATUS_UPLOADING;
  135. if (_fp >= 10) {
  136. contains(_waitMask) && removeChild(_waitMask);
  137. } else {
  138. _addWaitMask("????...");
  139. }
  140. var request:URLRequest = new URLRequest(_uploadUrl);
  141. var data:URLVariables = new URLVariables();
  142. for (var key:String in _requestVariables) {
  143. data[key] = _requestVariables[key];
  144. }
  145. data["rotate"] = _rotationAngle;
  146. request.method = URLRequestMethod.POST;
  147. request.data = data;
  148. _fileReference.upload(request);
  149. }
  150. }
  151. public function pauseUpload():void
  152. {
  153. _fileReference.cancel();
  154. _progressBar.scaleX = 0;
  155. uploadStatus = UPLOAD_STATUS_WAITING;
  156. _addWaitMask("????");
  157. }
  158. public function rotationImg(type:String = ROTATE_CW):void
  159. {
  160. // gif ????????
  161. if (_fp >= 10 && isValidPreviewFileType(_fileReference.type)
  162. && _fileReference.type != ".gif"
  163. && _available == AVIABLE_STATUS_NORMAL) {
  164. if (type == ROTATE_CW) {
  165. _previewerBitMap.rotation += 90;
  166. } else {
  167. _previewerBitMap.rotation -= 90;
  168. }
  169. var x:Number = 0;
  170. var y:Number = 0;
  171. switch (_previewerBitMap.rotation) {
  172. case 90:
  173. x = (WIDTH + _previewerBitMap.width) / 2;
  174. y = (HEIGHT - _previewerBitMap.height) / 2;
  175. _rotationAngle = 90;
  176. break;
  177. case -90:
  178. x = (WIDTH - _previewerBitMap.width) / 2;
  179. y = (HEIGHT + _previewerBitMap.height) / 2;
  180. _rotationAngle = -90;
  181. break;
  182. case 180:
  183. case -180:
  184. x = (WIDTH + _previewerBitMap.width) / 2;
  185. y = (HEIGHT + _previewerBitMap.height) / 2;
  186. _rotationAngle = 180;
  187. break;
  188. default:
  189. x = (WIDTH - _previewerBitMap.width) / 2;
  190. y = (HEIGHT - _previewerBitMap.height) / 2;
  191. _rotationAngle = 0;
  192. break;
  193. }
  194. _previewerBitMap.x = x;
  195. _previewerBitMap.y = y;
  196. }
  197. }
  198. private function _init():void
  199. {
  200. _addSelectmaskIconsProgressbar();
  201. _addTooltips();
  202. addEventListener(MouseEvent.ROLL_OVER, _itemEvent);
  203. addEventListener(MouseEvent.ROLL_OUT, _itemEvent);
  204. addEventListener(MouseEvent.CLICK, _itemEvent);
  205. }
  206. private function _itemEvent(e:MouseEvent):void
  207. {
  208. if (!_preloaded) {
  209. return;
  210. }
  211. switch (e.type) {
  212. case MouseEvent.ROLL_OVER:
  213. if (!e.buttonDown &&
  214. (_uploadStatus == UPLOAD_STATUS_NORMAL || _uploadStatus == UPLOAD_STATUS_WAITING)) {
  215. if (!_selected) {
  216. addChild(_selectMask);
  217. _selectMask.visible = true;
  218. _selectMask.alpha = 0.5;
  219. }
  220. addChild(_deleteIcon);
  221. _deleteIcon.visible = true;
  222. if (_closewiseBtn) {
  223. addChild(_closewiseBtn);
  224. addChild(_anticlosewiseBtn);
  225. _closewiseBtn.visible = true;
  226. _anticlosewiseBtn.visible = true;
  227. }
  228. }
  229. break;
  230. case MouseEvent.ROLL_OUT:
  231. if (!_selected) {
  232. _selectMask.visible = false;
  233. }
  234. _deleteIcon.visible = false;
  235. if (_closewiseBtn) {
  236. _closewiseBtn.visible = false;
  237. _anticlosewiseBtn.visible = false;
  238. }
  239. break;
  240. case MouseEvent.CLICK:
  241. if ((_uploadStatus == UPLOAD_STATUS_NORMAL || _uploadStatus == UPLOAD_STATUS_WAITING)
  242. && !(e.target is Button) && e.target != _deleteIcon) {
  243. if (e.ctrlKey) {
  244. selected = !selected;
  245. dispatchEvent(new Event(ItemEvent.SELECT_CHANGED, true));
  246. } else {
  247. selected = true;
  248. dispatchEvent(new Event(ItemEvent.UNSELECT_OTHERS, true));
  249. }
  250. }
  251. break;
  252. case MouseEvent.MOUSE_DOWN:
  253. break;
  254. default:
  255. break;
  256. }
  257. }
  258. private function _addTooltips():void
  259. {
  260. }
  261. private function _addSelectmaskIconsProgressbar():void
  262. {
  263. var graphic:Graphics;
  264. _selectMask = new Sprite();
  265. graphic = _selectMask.graphics;
  266. graphic.lineStyle(3, 0x2876B7, 1, true, "normal", "square", "miter");
  267. graphic.beginFill(0xFFFFFF, 0);
  268. graphic.drawRect( -2, -2, WIDTH + 4, HEIGHT + 4);
  269. graphic.endFill();
  270. _selectMask.visible = false;
  271. addChild(_selectMask);
  272. _deleteIcon = new DeleteIcon() as Sprite;
  273. _deleteIcon.x = WIDTH - _deleteIcon.width - 2;
  274. _deleteIcon.y = SELECT_MASK_Y;
  275. _deleteIcon.buttonMode = true;
  276. _deleteIcon.visible = false;
  277. _deleteIcon.addEventListener(MouseEvent.CLICK, _deleteIconClick);
  278. addChild(_deleteIcon);
  279. if (_fp >= 10 && isValidPreviewFileType(_fileReference.type) && _fileReference.type != ".gif") {
  280. _closewiseBtn = new Button();
  281. _closewiseBtn.setStyle("skin", _skins.closewise);
  282. _closewiseBtn.x = 22
  283. _closewiseBtn.y = SELECT_MASK_Y;
  284. _closewiseBtn.useHandCursor = true;
  285. _closewiseBtn.visible = false;
  286. _closewiseBtn.addEventListener(MouseEvent.CLICK, _rotationBtnClick);
  287. addChild(_closewiseBtn);
  288. _anticlosewiseBtn = new Button();
  289. _anticlosewiseBtn.setStyle("skin", _skins.anticlosewise);
  290. _anticlosewiseBtn.x = 2
  291. _anticlosewiseBtn.y = SELECT_MASK_Y;
  292. _anticlosewiseBtn.useHandCursor = true;
  293. _anticlosewiseBtn.visible = false;
  294. _anticlosewiseBtn.addEventListener(MouseEvent.CLICK, _rotationBtnClick);
  295. addChild(_anticlosewiseBtn);
  296. }
  297. _progressBar = new Sprite();
  298. graphic = _progressBar.graphics;
  299. graphic.lineStyle();
  300. graphic.beginFill(0x2876B7);
  301. graphic.drawRect(0, 0, HEIGHT + 1, 3);
  302. graphic.endFill();
  303. _progressBar.x = -0.5;
  304. _progressBar.y = HEIGHT;
  305. _progressBar.scaleX = 0;
  306. addChild(_progressBar);
  307. }
  308. private function _deleteIconClick(e:MouseEvent):void
  309. {
  310. if (_uploadStatus == UPLOAD_STATUS_NORMAL
  311. || _uploadStatus == UPLOAD_STATUS_WAITING) {
  312. dispatchEvent(new Event(ItemEvent.DELETE, true));
  313. }
  314. }
  315. private function _rotationBtnClick(e:MouseEvent):void
  316. {
  317. if (e.target == _closewiseBtn) {
  318. rotationImg(ROTATE_CW);
  319. } else {
  320. rotationImg(ROTATE_ACW);
  321. }
  322. }
  323. private function _addBg():void
  324. {
  325. var bg:Sprite = new Sprite();
  326. var graphic:Graphics = bg.graphics;
  327. graphic.lineStyle(1, COLOR_BORDER);
  328. graphic.beginFill(COLOR_FILL);
  329. graphic.drawRect(0, 0, WIDTH, HEIGHT);
  330. graphic.endFill();
  331. graphic.lineStyle();
  332. var matrix:Matrix = new Matrix();
  333. matrix.createGradientBox(WIDTH, HEIGHT, 2 * Math.PI / 5);
  334. graphic.beginGradientFill(GradientType.LINEAR, [COLOR_FILL_GRAY, COLOR_FILL], [0.8, 0], [0, 250], matrix);
  335. graphic.drawRect(2, 2, WIDTH - 4, HEIGHT - 4);
  336. graphic.endFill();
  337. addChildAt(bg, 0);
  338. }
  339. private function _noPreview():void
  340. {
  341. var tf:TextFormat = new TextFormat("??", 12, 0x666666);
  342. tf.leading = 5;
  343. var previewerText:TextField = new TextField();
  344. previewerText.defaultTextFormat = tf;
  345. previewerText.selectable = false;
  346. previewerText.autoSize = TextFieldAutoSize.LEFT;
  347. var str:String = _fileReference.name;
  348. previewerText.text = str;
  349. if (previewerText.width > WIDTH - 4) {
  350. while (previewerText.width > WIDTH - 10) {
  351. str = str.substr(0, str.length - 1);
  352. previewerText.text = str;
  353. }
  354. str = previewerText.text + "...";
  355. }
  356. previewerText.text = "????\n" + str;
  357. previewerText.x = 2;
  358. previewerText.y = 16;
  359. addChildAt(previewerText, 1);
  360. }
  361. private function _addListeners():void
  362. {
  363. if (_fp >= 10 && isValidPreviewFileType(_fileReference.type)) {
  364. _fileReference.addEventListener(Event.COMPLETE, _startPreview);
  365. }
  366. _fileReference.addEventListener(IOErrorEvent.IO_ERROR, _errorHandler);
  367. _fileReference.addEventListener(ProgressEvent.PROGRESS, _progressHandler);
  368. _fileReference.addEventListener(SecurityErrorEvent.SECURITY_ERROR, _errorHandler);
  369. _fileReference.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, _uploadCompleteDataHandler);
  370. }
  371. private function _errorHandler(e:Event = null):void
  372. {
  373. if (uploadStatus == UPLOAD_STATUS_FAILURE) {
  374. var icon:Sprite = new UploadedIconError() as Sprite;
  375. icon.x = WIDTH;
  376. icon.y = HEIGHT;
  377. addChild(icon);
  378. _removeProgressAndMask("????");
  379. uploadStatus = UPLOAD_STATUS_FAILURE;
  380. dispatchEvent(new Event(ItemEvent.UPLOAD_FAILURE, true));
  381. //dispatchEvent(new Event(ItemEvent.UPLOAD_COMPLETE, true));
  382. }
  383. MonsterDebugger.trace('item upload error', e);
  384. }
  385. private function _progressHandler(e:ProgressEvent):void
  386. {
  387. if (_uploadStatus == UPLOAD_STATUS_NORMAL) {
  388. if (!_preloadProgress) {
  389. _preloadProgress = new Sprite();
  390. var t:TextField = new TextField();
  391. t.autoSize = TextFieldAutoSize.LEFT;
  392. t.selectable = false;
  393. t.text = "??????...";
  394. _preloadProgress.addChild(t);
  395. var gp:Graphics = _preloadProgress.graphics;
  396. gp.lineStyle(2, 0xE7E7E7);
  397. gp.moveTo(0, 20);
  398. gp.lineTo(80, 20);
  399. gp.lineStyle(2, 0xF56A4);
  400. gp.moveTo(0, 20);
  401. }
  402. addChild(_preloadProgress);
  403. _preloadProgress.graphics.lineTo(e.bytesLoaded / e.bytesTotal * 80, 20);
  404. }
  405. if (_uploadStatus != UPLOAD_STATUS_NORMAL
  406. && _uploadStatus != UPLOAD_STATUS_WAITING) {
  407. _percent = e.bytesLoaded / e.bytesTotal;
  408. _progressBar.scaleX = _percent;
  409. }
  410. }
  411. private function _removeProgressAndMask(str:String = ""):void
  412. {
  413. contains(_progressBar) && removeChild(_progressBar);
  414. _progressBar = null;
  415. if (_fp >= 10) {
  416. contains(_waitMask) && removeChild(_waitMask);
  417. _waitMask = null;
  418. } else {
  419. _addWaitMask(str);
  420. }
  421. }
  422. private function _uploadCompleteDataHandler(event:DataEvent):void
  423. {
  424. try {
  425. _json = JSON.decode(event.text);
  426. if (/^A\w{5}$/.test(_json.code)) {
  427. var icon:Sprite = new UploadedIconComplete() as Sprite;
  428. icon.x = WIDTH;
  429. icon.y = HEIGHT;
  430. addChild(icon);
  431. _removeProgressAndMask("????");
  432. _uploadStatus = UPLOAD_STATUS_SUCCESS;
  433. dispatchEvent(new Event(ItemEvent.UPLOAD_SUCCESS, true));
  434. } else {
  435. _uploadStatus = UPLOAD_STATUS_FAILURE;
  436. _errorHandler();
  437. MonsterDebugger.trace('json', event.text);
  438. }
  439. } catch (e:JSONParseError) {
  440. MonsterDebugger.trace('json', event.text);
  441. _uploadStatus = UPLOAD_STATUS_FAILURE;
  442. _errorHandler();
  443. }
  444. dispatchEvent(new Event(ItemEvent.UPLOAD_COMPLETE, true));
  445. }
  446. private function _startPreview(e:Event):void
  447. {
  448. _fileReference.removeEventListener(Event.COMPLETE, _startPreview);
  449. contains(_preloadProgress) && removeChild(_preloadProgress);
  450. _preloadProgress = null;
  451. _previewLoader = new Loader();
  452. _previewLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, _previewLoaded);
  453. _previewLoader.loadBytes(this._fileReference.data);
  454. }
  455. private function _previewLoaded(e:Event):void
  456. {
  457. var w:Number = _previewLoader.width;
  458. var h:Number = _previewLoader.height;
  459. var mult:Number = Math.min((WIDTH - 4) / w, (HEIGHT - 4) / h, 1);
  460. var box:Matrix = new Matrix();
  461. box.createBox(mult, mult);
  462. var bitmapData:BitmapData = new BitmapData(w * mult, h * mult, true, 0xFFFFFFFF);
  463. bitmapData.draw(_previewLoader, box);
  464. _previewerBitMap = new Bitmap(bitmapData);
  465. _previewerBitMap.x = (WIDTH - _previewerBitMap.width) / 2;
  466. _previewerBitMap.y = (HEIGHT - _previewerBitMap.height) / 2;
  467. addChildAt(_previewerBitMap, 1);
  468. _previewLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, _previewLoaded);
  469. _previewLoader = null;
  470. _preloaded = true;
  471. dispatchEvent(new Event(ItemEvent.PRELOAD_COMPLETE, true));
  472. }
  473. private function _addErrorMask(str:String):void
  474. {
  475. var paddBottom:Number = 30;
  476. if (!_errorMask) {
  477. var gp:Graphics;
  478. var color:uint = 0xFFFFFF;
  479. _errorMask = new Sprite();
  480. gp = _errorMask.graphics;
  481. gp.lineStyle();
  482. gp.beginFill(color, 0.5);
  483. gp.drawRect(0.5, 0.5, WIDTH - 1, HEIGHT - paddBottom);
  484. gp.endFill();
  485. gp.beginFill(color, 0.8);
  486. gp.drawRect(0.5, HEIGHT - paddBottom, WIDTH - 1, paddBottom);
  487. gp.endFill();
  488. var tf:TextFormat = new TextFormat("??", 12, 0xBA0000);
  489. tf.bold = true;
  490. _errorMaskText = new TextField();
  491. _errorMaskText.defaultTextFormat = tf;
  492. _errorMaskText.autoSize = TextFieldAutoSize.LEFT;
  493. _errorMaskText.selectable = false;
  494. _errorMask.mouseEnabled = false;
  495. _errorMask.mouseChildren = false;
  496. _errorMask.addChild(_errorMaskText);
  497. }
  498. if (_errorMaskText.text != str) {
  499. _errorMaskText.text = str;
  500. _errorMaskText.x = (WIDTH - _errorMaskText.width) / 2;
  501. _errorMaskText.y = HEIGHT - paddBottom + (paddBottom - _errorMaskText.height) / 2;
  502. }
  503. addChild(_errorMask);
  504. }
  505. private function _addWaitMask(tip:String = ""):void
  506. {
  507. if (!_waitMask) {
  508. _waitMask = new Sprite();
  509. if (_fp >= 10) {
  510. var gp:Graphics;
  511. gp = _waitMask.graphics;
  512. gp.lineStyle();
  513. gp.beginFill(0xFFFFFF, 0.5);
  514. gp.drawRect(0, 0, WIDTH, HEIGHT);
  515. gp.endFill();
  516. } else {
  517. var t:TextField = new TextField();
  518. var tf:TextFormat = new TextFormat("??", 12, 0x666666);
  519. tf.bold = true;
  520. t.defaultTextFormat = tf;
  521. t.selectable = false;
  522. t.autoSize = TextFieldAutoSize.LEFT;
  523. t.x = 2;
  524. t.y = HEIGHT / 2;
  525. _waitMask.addChild(t);
  526. }
  527. }
  528. if (!(_fp >= 10)) {
  529. (_waitMask.getChildAt(0) as TextField).text = tip;
  530. }
  531. addChild(_waitMask);
  532. }
  533. public function set fp(value:int):void
  534. {
  535. if (value) {
  536. _fp = value;
  537. }
  538. }
  539. public function set maxSize(value:Number):void
  540. {
  541. if (value) {
  542. _maxSize = value;
  543. }
  544. }
  545. public function set uploadUrl(value:String):void
  546. {
  547. if (value) {
  548. _uploadUrl = value;
  549. }
  550. }
  551. public function get index():int
  552. {
  553. return _index;
  554. }
  555. public function set index(value:int):void
  556. {
  557. _index = value;
  558. }
  559. public function get delay():Number
  560. {
  561. return _delay;
  562. }
  563. public function set delay(value:Number):void
  564. {
  565. _delay = value;
  566. }
  567. public function get fileReference():FileReference
  568. {
  569. return _fileReference;
  570. }
  571. public function set fileReference(value:FileReference):void
  572. {
  573. if (value) {
  574. _fileReference = value;
  575. _fileUrlLoader = new URLLoader();
  576. _addListeners();
  577. setTimeout(_init, _delay * 20);
  578. }
  579. }
  580. public function get uploadStatus():String
  581. {
  582. return _uploadStatus;
  583. }
  584. public function set uploadStatus(value:String):void
  585. {
  586. if (_uploadStatus == value) {
  587. return;
  588. }
  589. _uploadStatus = value;
  590. switch (_uploadStatus) {
  591. case UPLOAD_STATUS_WAITING:
  592. _addWaitMask("????...");
  593. selected = false;
  594. break;
  595. case UPLOAD_STATUS_SIZE_ERROR:
  596. _addWaitMask("????...");
  597. break;
  598. case UPLOAD_STATUS_FAILURE:
  599. break;
  600. default:
  601. break;
  602. }
  603. }
  604. public function get selected():Boolean
  605. {
  606. return _selected;
  607. }
  608. public function set selected(value:Boolean):void
  609. {
  610. if (_selected == value) {
  611. return;
  612. }
  613. _selected = value;
  614. _selectMask.visible = value;
  615. _selectMask.alpha = 1;
  616. }
  617. public function get requestVariables():Object
  618. {
  619. return _requestVariables;
  620. }
  621. public function setRequestVariables(key:String, value:*):void
  622. {
  623. _requestVariables[key] = value;
  624. }
  625. public function get json():Object
  626. {
  627. return _json;
  628. }
  629. }
  630. }