I tend not to use Delegate and go for this easier/cleaner alternative

private var scope : ClassName = this ;

this.my_mc.onRelease = function ( ) {
scope.doSomething ( "great!" ) ;
}

function doSomething ( id : String ) {
trace("what's my id: " + id ) ;
}



On 6/4/07, Daniel Glue <[EMAIL PROTECTED]> wrote:

Thanks everyone, I've been reading through the article on scope and
using the Delegate Class that Alain reccomended which was very useful
and had just come round to code a very similar solution as written out
by Fernando, thanks everyone!
Danny

On 04/06/07, Fernando Castillo <[EMAIL PROTECTED]> wrote:
> Hi Daniel,
>
> Just something like this.
>
>
> <code>
> import mx.utils.Delegate;
> class VersionChecker{
>     private var my_lv:LoadVars;
>     private var xmlAdd:String;
>     private var browserType:String;
>     private var ipAddress:String;
>
>     public function VersionChecker(xmlAddy:String) {
>                 my_lv = new LoadVars();
>                 my_lv.onLoad = Delegate.create(this, onXMLLoad);
>                 xmlAdd = xmlAddy;
>                 startCheck();
>         }
>
>     private function startCheck() {
>                 trace("version checker starting to check:"+xmlAdd);
>                 my_lv.load(xmlAdd);
>         }
>
>         private function onXMLLoad(success:Boolean):Void {
>                 if(success){
>                         trace("OK");
>                 }else{
>                         trace("ERROR");
>                 }
>         }
> }
>
> </code>
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Daniel
Glue
> Sent: lunes, 04 de junio de 2007 16:21
> To: Flashcoders@chattyfig.figleaf.com
> Subject: [Flashcoders] Setting up loadVars onLoad handler within custom
> class
>
> Hey there, I am creating a custom class with a loadVars object that
> gets data from a web page. My problem is I can't get my loadVars
> object to load! I think I am setting the onLoad handler in the wrong
> place. Might anyone have any ideas how I set this inside my custom
> class?
>
> Thanks in advance guys!
> Danny
>
>
> Here is my code:
>
> Class VersionChecker{
>         private var my_lv:LoadVars;
>                private var xmlAdd:String;
>               private var browserType:String;
>               private var ipAddress:String;
>
>
> //receives url to connect to sets onLoad handler
>      public function VersionCheck(xmlAddy:String {
>                 xmlAdd = xmlAddy;
>                 my_lv.onLoad = function(success:Boolean) {
>                         if (success) {
>                             trace("loaded");
>                                 browserType = this.browser;
>                                 ipAddress = this.ip;
>                         } else {
>                                 trace("load failed");
>                         }
>                 };
>                 startCheck();
>         }
>
>       private function startCheck() {
>                 trace("version checker starting to check:"+xmlAdd);
>                 my_lv.load(xmlAdd);
>         }
> }
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to