RE: [Flashcoders] Setting up loadVars onLoad handler within custom class
>>I tend not to use Delegate and go for this easier/cleaner alternative >>this.my_mc.onRelease = function ( ) { I now tend to not use anonymous functions like you have and use Delegate instead. Anonymous functions are bad practice in my opinion. I think your idea is actually messier than Delegate, no offense. At least in AS3, neither "'trick" is necessary any more. Jason Merrill Bank of America GT&O Learning & Leadership Development eTools & Multimedia Team ___ 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
Re: [Flashcoders] Setting up loadVars onLoad handler within custom class
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. > > > > 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"); > } > } > } > > > > > > -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
Re: [Flashcoders] Setting up loadVars onLoad handler within custom class
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. 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"); } } } -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
RE: [Flashcoders] Setting up loadVars onLoad handler within custom class
Hi Daniel, Just something like this. 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"); } } } -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
RE: [Flashcoders] Setting up loadVars onLoad handler within custom class
To learn more about Delegate I'd suggest you read the following : http://osflash.org/flashcoders/as2 Alain -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rákos Attila Sent: 4 juin 2007 10:32 To: Daniel Glue Subject: Re: [Flashcoders] Setting up loadVars onLoad handler within custom class Where did you instantiate LoadVars? I don't see it anywhere. But it almost doesn't matter, since you will have scoping problems, look after some kind of delegation (eg. mx.utils.Delegate). Attila DG> Hey there, I am creating a custom class with a loadVars object that DG> gets data from a web page. My problem is I can't get my loadVars DG> object to load! I think I am setting the onLoad handler in the wrong DG> place. Might anyone have any ideas how I set this inside my custom DG> class? DG> DG> Thanks in advance guys! DG> Danny DG> DG> DG> Here is my code: DG> DG> Class VersionChecker{ DG> private var my_lv:LoadVars; DG>private var xmlAdd:String; DG> private var browserType:String; DG> private var ipAddress:String; DG> DG> DG> //receives url to connect to sets onLoad handler DG> public function VersionCheck(xmlAddy:String { DG> xmlAdd = xmlAddy; DG> my_lv.onLoad = function(success:Boolean) { DG> if (success) { DG> trace("loaded"); DG> browserType = this.browser; DG> ipAddress = this.ip; DG> } else { DG> trace("load failed"); DG> } DG> }; DG> startCheck(); DG> } DG> DG> private function startCheck() { DG> trace("version checker starting to check:"+xmlAdd); DG> my_lv.load(xmlAdd); DG> } DG> } ___ 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 No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 2007-06-03 12:47 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.472 / Virus Database: 269.8.7/830 - Release Date: 2007-06-03 12:47 ___ 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
RE: [Flashcoders] Setting up loadVars onLoad handler within custom class
Hi Daniel, Don't you have this line in your code my_lv = new LoadVars(); ? If you don't have this, your loadvars will not work. Bye Daniel Portilla Heras ___ 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
RE: [Flashcoders] Setting up loadVars onLoad handler within custom class
Where is your new LoadVars() statement for the my_lv variable? Also, this: public function VersionCheck(xmlAddy:String { Should throw a compiler error Jason Merrill Bank of America GT&O Learning & Leadership Development eTools & Multimedia Team >>-Original Message- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] On Behalf >>Of Daniel Glue >>Sent: Monday, June 04, 2007 10:21 AM >>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
Re: [Flashcoders] Setting up loadVars onLoad handler within custom class
Where did you instantiate LoadVars? I don't see it anywhere. But it almost doesn't matter, since you will have scoping problems, look after some kind of delegation (eg. mx.utils.Delegate). Attila DG> Hey there, I am creating a custom class with a loadVars object that DG> gets data from a web page. My problem is I can't get my loadVars DG> object to load! I think I am setting the onLoad handler in the wrong DG> place. Might anyone have any ideas how I set this inside my custom DG> class? DG> DG> Thanks in advance guys! DG> Danny DG> DG> DG> Here is my code: DG> DG> Class VersionChecker{ DG> private var my_lv:LoadVars; DG>private var xmlAdd:String; DG> private var browserType:String; DG> private var ipAddress:String; DG> DG> DG> //receives url to connect to sets onLoad handler DG> public function VersionCheck(xmlAddy:String { DG> xmlAdd = xmlAddy; DG> my_lv.onLoad = function(success:Boolean) { DG> if (success) { DG> trace("loaded"); DG> browserType = this.browser; DG> ipAddress = this.ip; DG> } else { DG> trace("load failed"); DG> } DG> }; DG> startCheck(); DG> } DG> DG> private function startCheck() { DG> trace("version checker starting to check:"+xmlAdd); DG> my_lv.load(xmlAdd); DG> } DG> } ___ 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] 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