Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
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-31-2007, 12:23 PM   #4
Brucebannor
that is some bad binary.
 
Join Date: Jun 2007
Location: Pittsburgh, PA
Posts: 406
Default

I know this isn't going anywhere but I made a very simplistic class to demonstrate the inability of the class to pick up events on flash components. I figured its easier to look at the code than to describe.

Notice I used three different methods of trying to catch the event. Any last insight or idea's?

If not, is this problem fixed on AS 3.0?
Attached Files
File Type: zip Combo Test.zip (229.8 KB, 54 views)
__________________
Silly rabbit programming is for kids.
Brucebannor is offline   Reply With Quote
Old 09-01-2007, 07:22 AM   #5
creynders
flash veteran
 
creynders's Avatar
 
Join Date: May 2005
Location: Belgium
Posts: 914
Default

If this code is executed in the constructor of your class the problem probably is that the component is not fully initialized when you call the addEventListener.
Try executing the code on onLoad of your class. like this:
ActionScript Code:
//in constructor onLoad = initCb; //separate function public function initCb(){     cbListener = new Object();     cbListener.change = Delegate.create(this, comboChange);     filter_cb.addEventListener("change", cbListener); }
This only works if your class extends MovieClip.
I always address all my MovieClip and Component instances onLoad, just to be safe.

Last edited by creynders; 09-01-2007 at 07:25 AM.
creynders is offline   Reply With Quote
Old 08-30-2007, 06:54 PM   #6
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   #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

is cbListener a property of the class?
xxneon is offline   Reply With Quote
Old 08-30-2007, 07:00 PM   #8
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   #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

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   #10
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
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 04:16 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.