Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rss {
- import rss.*;
- import flash.display.Bitmap;
- public class DB {
- private var itemList: Array;
- public var assets: AssetManager;
- // the XML Processor that corresponds to the item type
- private var processor: RssXMLProcessor;
- // the constructor function
- public function DB() {
- itemList = new Array();
- assets = new AssetManager();
- //create the processor
- processor = new RssXMLProcessor(this);
- trace("DB: Info - new instance created");
- }
- /*
- * the main configuration file load function
- */
- public function loadData(xmlData: XML): void {
- trace("DB: Info - loading feed data");
- processor.process(xmlData);
- }
- public function assetsLoaded(): Boolean {
- return assets.loaded();
- }
- public function itemCount(): int {
- return itemList.length;
- }
- public function addItem(item: RssItem): void {
- itemList.push(item);
- }
- public function getItem(itemId: Number): RssItem {
- if ((itemId > -1) && (itemId < itemList.length)) {
- return itemList[itemId];
- } else {
- trace("DB: Error - supplied id is out of range");
- return null;
- }
- }
- /*
- public function getItemImage(itemId: Number): Bitmap {
- var myItem: RssItem = getItem(itemId);
- // check the id is in range etc.
- if ((myItem != null) && (myItem.imageIndex > -1)) {
- return assets.getAsset(myItem.imageIndex);
- } else {
- trace("DB: Warning - no image is available for id");
- return null;
- }
- }
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement