A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: return values from event handler

  1. #1
    will i ever get it?
    Join Date
    Feb 2004

    return values from event handler

    hi..i have a class (PrimaryAssets) i am creating, but i am uncertain on how to do a fundamental get method. For example, this class will hold information such as a parsed stylesheet, a gateway url, etc. The thinking is that other classes needing this info would simply access it by a new PrimaryAsset object. Seems to makes since, rather than re-writing a bunch of URLRequests/URLLoaders.

    here is the part where the PrimaryAsset class loads and parses the StyleSheet. It happens after the initial gateway url is defined:

    //<-------------------LOAD CSS------------------->
    		public function getCSS(cssPath:String=null):void
    			var urlr:URLRequest= new URLRequest()
    			var cssUrll:URLLoader= new URLLoader()
    		private function parsecss(ev:Event):StyleSheet
    			var ld:URLLoader= ev.currentTarget as URLLoader;
    			this.css= new StyleSheet();
    			return css;
    now, when i call a new PrimaryAsset object, all is fine. But i would like to call something like
    var pa:PrimaryAssets= new PrimaryAssets();
    function parseCSS(pae:PrimaryAssetEvent):void
    var CSS_stylesheet:StyleSheet=pa.getCSS();
    how/where should i be returning the css from my PrimaryAssets class? The event handler is not the place

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Austin, TX
    No, it's not.
    Your naming confused me for a second. I figured getCSS would simply return the value of the css property.

    You'll need to re-design so that you can dispatch events when the assets are loaded and retrieve them from member variables.

    Actually, you could pass callbacks to your PrimaryAssets class which would call them with the loaded assets after they load. This would still be asynchronous though, and you're probably better off explicitly throwing events around.

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