Hey,
Ok, this really will stress my english, so bear with me.
I have a problem calling a method of the document class from any other class. Since I don't know the "name" of this instance I can not call it directly. AS3 does not give it a name by which I can call it, nor does it allow me, as far as I know, to name it myself (which then would maybe make it possible to write it into a global variable).
I tried adding a 'this' as parameter when I would create an instance of another class inside the document class. Then I would save it in a class property of the type 'Object'. But that caused an TypeError (namely #1010) later on.
Next I tried the aquivalent of the public static var by stating my document class method simply 'public static function'! But - as I just read and experienced - then I get a problem calling other methods from within THIS method.
There's even a problem when I work with instances of display classes, that I added as child to the document class instance. Inside this display class I tried refering to the parent instance as - well, parent, obviously, but that did not work either. That only works with event.target.parent somehow. But for that I need an event.
So is this a conceptual error on my side - or is it AS3 and I just have to live with it and try working around it? I usually can, but this time, I need to call back to the document class instance because I have to wait for an xml-file to load!
How to reference to instance of document class(or simple callback)
Page 1 of 1
2 Replies - 6197 Views - Last Post: 16 January 2010 - 06:40 PM
Replies To: How to reference to instance of document class
#2
Re: How to reference to instance of document class
Posted 09 June 2009 - 05:12 AM
I think I understand you correctly.. Basically you want to reference the document class from within another class? You can pass it over in the constructor function and refer to that, like so:
Where DocClass is your document class. Then you can refer to the document class via the doc variable.
package
{
import DocClass;
public class MyClass
{
var doc:DocClass;
function MyClass(newDoc)
{
doc = newDoc;
}
}
}
Where DocClass is your document class. Then you can refer to the document class via the doc variable.
#3
Re: How to reference to instance of document class
Posted 16 January 2010 - 06:40 PM
Hi there!
Check at my new tutorial and download its source of a OOP Flash website using AS3 external classes.
No more code in the timeline!!!
Check here: http://www.mikeland....tform/index.swf
Hope you enjoy!!
Mike
Check at my new tutorial and download its source of a OOP Flash website using AS3 external classes.
No more code in the timeline!!!
Check here: http://www.mikeland....tform/index.swf
Hope you enjoy!!
Mike
This post has been edited by mika_mikeland: 16 January 2010 - 06:41 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|