PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Passing Flashvars into public class and assign this string as path to XML????
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Passing Flashvars into public class and assign this string as path to XML????

Threaded View

  1. #1
    Senior Member
    Join Date
    Aug 2001
    Location
    Seattle, WA
    Posts
    180

    Passing Flashvars into public class and assign this string as path to XML????

    I am trying to pass FlashVars into public class EventDispatcher to set the path to data.xml. I need it because the name and path of the xml file will be dynamically created. I need to use Flashvar in order to access the correct path.
    I was able to pass Flashvar from html page on timeline this way:
    Actionscript Code:
    var Flashvars:String = LoaderInfo(stage.loaderInfo).parameters.xmlfile;
    Then, I was able to use it with new UrlRequest;
    Actionscript Code:
    var request:URLRequest = new URLRequest(Flashvars);

    This method works really good, but this solution only works on timeline.
    I need to implement this technique in the class. Before I setup a static var for with the path to xml file. I'd like to be able to get FlashVar withing this class and assign this string to 'public static var DATA_XML_URL:String' I have there. This way I can pass Flashwar to the project I already have.
    I am wondering if it is doable from what I described. I already spent a gay for it but obviously stack here. Any help is highly appreciate.
    Below is the class:

    Actionscript Code:
    import flash.events.Event;
        import flash.events.EventDispatcher;
        import flash.display.Sprite;
        import flash.display.LoaderInfo;
        import flash.display.MovieClip;
        import flash.display.Stage;

       
        public class ConfigManager extends EventDispatcher {
           
           
            //private var loaderInfo:LoaderInfo;
            private var _targetLoaderInfo:LoaderInfo;
           
            // The name of the event to be fired when configuration is read
            public static const CONFIG_LOADED:String = "configLoaded";
           
            // Location of the data xml file
            public static var DATA_XML_URL:String = "xml/data.xml";
           
            public static var PHOTO_DIR:String = "images/profile/"
            private var configXMLLoader:XMLLoader;
           
            // Xml data
            private var xml:XML;
           
            // A reference to the ConfigManager
            private static var _configManager:ConfigManager;
           
            private var test1:String = "";
       
           
            public function ConfigManager(singletonEnforcer:SingletonEnforcer) {           
                // NOTHING HERE
            }          
           
           
           
            public function load():void {
                // Create a new XMLLoader object
               
                //DATA_XML_URL = LoaderInfo(stage.loaderInfo).parameters.xmlfile;
       
                //Or it can be this way
                /*if (LoaderInfo(this.parent.parent.loaderInfo).parameters.xmlfile !== undefined){
                    test1 = LoaderInfo(this.parent.parent.loaderInfo).parameters.xmlfile;
                    DATA_XML_URL = test1;
                   
                }*/

                init();
            }
           
           
            public function init():void {
               
                configXMLLoader = new XMLLoader(CONFIG_XML_URL);
               
                // Add an event listener to be dispatched when xml is parsed.
                configXMLLoader.addEventListener(XMLLoader.XML_LOADED, onConfigXMLLoaded);
               
                // Start loading the file
                configXMLLoader.load();
               
            }
           
            private function readConfig(xml:XML):void {
                // Read configurations here
                PHOTO_DIR = xml.@photoDir;
            }
           
            //This method is called when the configuration file is loaded.       
            private function onConfigXMLLoaded(evt:Event):void {
               
                // Read the setting values from the configuration file
                readConfig(configXMLLoader.getXML());
                dispatchEvent(new Event(ConfigManager.CONFIG_LOADED));

            }
            // Returns the configuration manager.
            public static function getInstance():ConfigManager {
               
                if (_configManager == null) {
                    _configManager = new ConfigManager(new SingletonEnforcer());
                }
               
                return _configManager;
               
            }
           
        }
       
    }
    Last edited by vladc77; 05-29-2010 at 07:08 AM.
    Best regards
    Vlad,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center