Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-30-2007, 02:51 PM   #1
Brucebannor
that is some bad binary.
 
Join Date: Jun 2007
Location: Pittsburgh, PA
Posts: 406
Default Classes and XML.onLoad

I'm making a rather large class for a project. So keep in mind this is all in a class file, thus my scope issue. I know I need to pass the onLoad the instance of the class. I would normally just pass it thru the function. ie
dr_xml.onLoad = function(thisObj){} but this is reserved for whether it has loaded correcty and will rewrite the value to true / false. Any idea how to get my thisObj to be visible?

I also tried to overLoad the parameters of onLoad, so it would set the first to true / false, then pass my thisObj to no avail.

ActionScript Code:
function myFunction() {   trace(thisObj); // traces my Instance   dr_xml = new XML();   dr_xml.onLoad = function ()   {      trace(thisObj); // undefined      processXML(dr_xml);   } } function processXML() {     // yadda yadda }
__________________
Silly rabbit programming is for kids.

Last edited by Brucebannor; 08-30-2007 at 02:54 PM.
Brucebannor is offline   Reply With Quote
Old 08-30-2007, 03:33 PM   #2
xxneon
Super Moderator
 
xxneon's Avatar
 
Join Date: Dec 2006
Location: Amish Country, PA
Posts: 8,570
Send a message via ICQ to xxneon Send a message via AIM to xxneon Send a message via MSN to xxneon Send a message via Skype™ to xxneon
Default

use Delegate..

ActionScript Code:
//... dr_xml.onLoad = mx.utils.Delegate.create(this,classXmlLoad); //... function classXmlLoad() {     trace(thisObj); // shouldn't be undefined..     processXML(dr_xml); } function processXML() {     // yadda yadda }

this should make it so thisObj should be able to be seen when onLoad is called..

or before the onLoad function of your original code.. add a property to the xml object..

ActionScript Code:
dr_xml.thisObj = thisObj; dr_xml.onLoad = function() {     trace(this.thisObj); //shouldn't be undefined..     processXML(this.thisObj); }

if you dont want to use Delegate..

Last edited by xxneon; 08-30-2007 at 03:37 PM.
xxneon is offline   Reply With Quote
Old 08-30-2007, 03:36 PM   #3
Brucebannor
that is some bad binary.
 
Join Date: Jun 2007
Location: Pittsburgh, PA
Posts: 406
Default

makes very much sense.. i had a stupid moment, especially since I Delegate all of my other events. Thanks man
__________________
Silly rabbit programming is for kids.
Brucebannor is offline   Reply With Quote
Old 08-30-2007, 06:54 PM   #4
Brucebannor
that is some bad binary.
 
Join Date: Jun 2007
Location: Pittsburgh, PA
Posts: 406
Default

ok so same class and one more problem.. this is all part of my constructor function. No problem dropp'n this in its own .fla. But its dead to the world as soon as I stick it in the class, any suggestions? thanks

ActionScript Code:
cbListener = new Object(); cbListener.change = Delegate.create(this, comboChange); filter_cb.addEventListener("change", cbListener);
__________________
Silly rabbit programming is for kids.
Brucebannor is offline   Reply With Quote
Old 08-30-2007, 06:58 PM   #5
xxneon
Super Moderator
 
xxneon's Avatar
 
Join Date: Dec 2006
Location: Amish Country, PA
Posts: 8,570
Send a message via ICQ to xxneon Send a message via AIM to xxneon Send a message via MSN to xxneon Send a message via Skype™ to xxneon
Default

is cbListener a property of the class?
xxneon is offline   Reply With Quote
Old 08-30-2007, 07:00 PM   #6
Brucebannor
that is some bad binary.
 
Join Date: Jun 2007
Location: Pittsburgh, PA
Posts: 406
Default

I declare it above the constructor as type object: var cbListener:Object;
__________________
Silly rabbit programming is for kids.
Brucebannor is offline   Reply With Quote
Old 08-30-2007, 07:13 PM   #7
xxneon
Super Moderator
 
xxneon's Avatar
 
Join Date: Dec 2006
Location: Amish Country, PA
Posts: 8,570
Send a message via ICQ to xxneon Send a message via AIM to xxneon Send a message via MSN to xxneon Send a message via Skype™ to xxneon
Default

and filter_cb is a property pointing to a combo box on the stage then correct?
xxneon is offline   Reply With Quote
Old 08-30-2007, 07:17 PM   #8
Brucebannor
that is some bad binary.
 
Join Date: Jun 2007
Location: Pittsburgh, PA
Posts: 406
Default

yes sir, traced all of the components / objects and they all trace correctly.
If I disregard the Delgate like so:
ActionScript Code:
cbListener.change = function() {   trace("here"); } filter_cb.addEventListener("change", cbListener);

its still dead to the world. Could this be a limitation of a class file in AS 2.0? I can't think of what I'm doing wrong, or any other ways to try
__________________
Silly rabbit programming is for kids.
Brucebannor is offline   Reply With Quote
Old 08-30-2007, 07:23 PM   #9
xxneon
Super Moderator
 
xxneon's Avatar
 
Join Date: Dec 2006
Location: Amish Country, PA
Posts: 8,570
Send a message via ICQ to xxneon Send a message via AIM to xxneon Send a message via MSN to xxneon Send a message via Skype™ to xxneon
Default

you could try this.. then you basically make the class the listener..
ActionScript Code:
filter_cb.addEventListener("change", Delegate.create(this,comboChange));

is this class extending the MovieClip class by any chance?

Last edited by xxneon; 08-30-2007 at 07:27 PM.
xxneon is offline   Reply With Quote
Old 08-30-2007, 07:27 PM   #10
Brucebannor
that is some bad binary.
 
Join Date: Jun 2007
Location: Pittsburgh, PA
Posts: 406
Default

ahhh already did. I think I'm gonna end up dropping back 10 and punting to a external as file instead of class. I have a datagrid that I assume will have the same problem.

and yup it extends MovieClip, would that be the problem?
__________________
Silly rabbit programming is for kids.

Last edited by Brucebannor; 08-30-2007 at 07:29 PM.
Brucebannor is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apply tween classes to dynamically loaded images!!! phencesgirl ActionScript 2.0 0 03-12-2007 06:46 PM
releasing xml file from XML.onLoad() sophistikat ActionScript 2.0 2 02-21-2007 07:00 PM
Why XML.onLoad run after all classes Shahzeb ActionScript 2.0 2 02-02-2006 11:21 AM
If we use XML.onLoad in classes when it will run?? Shahzeb ActionScript 2.0 0 02-01-2006 11:17 AM
help with passing parameters with XML.onLoad ? dcardena Other Flash General Questions 0 08-25-2005 12:19 AM


All times are GMT. The time now is 07:37 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.