Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. package rss {
  2. import rss.*;
  3. import flash.display.Bitmap;
  4. public class DB {
  5. private var itemList: Array;
  6. public var assets: AssetManager;
  7. // the XML Processor that corresponds to the item type
  8. private var processor: RssXMLProcessor;
  9. // the constructor function
  10. public function DB() {
  11. itemList = new Array();
  12. assets = new AssetManager();
  13. //create the processor
  14. processor = new RssXMLProcessor(this);
  15. trace("DB: Info - new instance created");
  16. }
  17. /*
  18. * the main configuration file load function
  19. */
  20. public function loadData(xmlData: XML): void {
  21. trace("DB: Info - loading feed data");
  22. processor.process(xmlData);
  23. }
  24. public function assetsLoaded(): Boolean {
  25. return assets.loaded();
  26. }
  27. public function itemCount(): int {
  28. return itemList.length;
  29. }
  30. public function addItem(item: RssItem): void {
  31. itemList.push(item);
  32. }
  33. public function getItem(itemId: Number): RssItem {
  34. if ((itemId > -1) && (itemId < itemList.length)) {
  35. return itemList[itemId];
  36. } else {
  37. trace("DB: Error - supplied id is out of range");
  38. return null;
  39. }
  40. }
  41. /*
  42. public function getItemImage(itemId: Number): Bitmap {
  43. var myItem: RssItem = getItem(itemId);
  44. // check the id is in range etc.
  45. if ((myItem != null) && (myItem.imageIndex > -1)) {
  46. return assets.getAsset(myItem.imageIndex);
  47. } else {
  48. trace("DB: Warning - no image is available for id");
  49. return null;
  50. }
  51. }
  52. */
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement