all groups > flash actionscript > may 2005 >
You're in the

flash actionscript

group:

Access object properties from within MovieClip



Access object properties from within MovieClip havegot2beon
5/30/2005 9:23:40 PM
flash actionscript: When I attach a movie through code in a class, how can I access properties of
an instance of this class through events in this MovieClip. At the //HERE
marker (see code) I can't access the properties. What's the best way to achieve
this?



class SomeClass
{
private var somevar:String;
private var somemovie:MovieClip;
//
public function SomeClass(name:String, target:MovieClip, depth:Number)
{
somemovie = target.attachMovie("SomeMovieSymbol", name, depth);

somemoviec.onEnterFrame = function ()
{
// HERE

}
}
Re: Access object properties from within MovieClip LuigiL
5/31/2005 8:07:06 AM
Set a local reference to the current class:



public function SomeClass(name:String, target:MovieClip, depth:Number)
{
thisObj:SomeClass = this; //local reference to the current class
somemovie = target.attachMovie("SomeMovieSymbol", name, depth);

somemovie.onEnterFrame = function ()
{
// HERE
thisObj.somevar = "Something";

}
}
Re: Access object properties from within MovieClip havegot2beon
5/31/2005 9:56:18 AM
AddThis Social Bookmark Button