-
1. Re: Error found in custom class
barpos Apr 1, 2011 1:51 PM (in response to barpos)I just tried the following way to call the class, but I still get the same error message:
var myTrace:traceDisplayList = new traceDisplayList();
myTrace.traceNow(stage);I renamed the public function to traceNow() thinking it might help.
-
2. Re: Error found in custom class
kglad Apr 1, 2011 2:32 PM (in response to barpos)import that class:
import flash.display.DisplayObjectContainer;
-
3. Re: Error found in custom class
barpos Apr 1, 2011 3:51 PM (in response to kglad)Makes sense! A lot of the time the import statements come up automatically, for whatever reason.
package
{
import flash.display.DisplayObjectContainer;
import flash.display.DisplayObject;
public class traceDisplayList
{public function traceDisplayList(kontainer:DisplayObjectContainer, indentString:String=""):void
{
var child:DisplayObject;
for (var i:uint = 0; i < kontainer.numChildren; i++)
{
child = kontainer.getChildAt(i);
trace(indentString,child,child.name);
if (kontainer.getChildAt(i) is DisplayObjectContainer)
{
traceDisplayList(DisplayObjectContainer(child),indentString + "");
}
}
}}
}
But, I have to admit, now it is the last line -- traceDisplayList() -- that bugs. I'm told I have the wrong number of parameters. Is this real?
Regards,
Ron
-
4. Re: Error found in custom class
kglad Apr 1, 2011 4:10 PM (in response to barpos)that error message is misleading but you have screwy code. try:
package
{
import flash.display.DisplayObjectContainer;
import flash.display.DisplayObject;
public class traceDisplayList
{public function traceDisplayList(kontainer:DisplayObjectContainer, indentString:String=""):void
{
traceF(kontainer,indentString);}
private function traceF(kontainer:DisplayObjectContainer,indentString:String=""):void{
var child:DisplayObject;
for (var i:uint = 0; i < kontainer.numChildren; i++)
{
child = kontainer.getChildAt(i);
trace(indentString,child,child.name);
if (kontainer.getChildAt(i) is DisplayObjectContainer)
{
traceF(DisplayObjectContainer(child),indentString + "");
}
}}
}
}
-
5. Re: Error found in custom class
barpos Apr 1, 2011 4:26 PM (in response to kglad)I see, one cannot call recursively a public function. I'll try to remember that.
Thanks!
Ron
-
6. Re: Error found in custom class
kglad Apr 1, 2011 5:18 PM (in response to barpos)it's not that it's public that's the problem. the issue is that traceDisplayList is not a class method; it's a class.


