View Full Version : setting movie clip properites in classes

10-05-2005, 10:07 PM
with the development of flash and its orientation around classes i ma trying to get to grips with using my own for the obvious reasons of reuse and development.

I have developed classes that do mathmatical and string alterations etc but this is the first time I have come across a problem with moving a movie clip within class functions.

Just as a test I am tring this simple task of moving the cont_mc with a button but dont work, as you can see have applied an action to the scrollUp_mc to move itself and this works so why cant I move the cont_mc? Is this a thing with classes that they cant do and actions like this should be left to the flash environment itself??? Can someone point me in right direction please???

class Skin.skinScrollPane extends MovieClip {

private var boundingBox_mc:MovieClip;
private var scrollDown_mc:MovieClip;
private var scrollUp_mc:MovieClip;
private var cont_mc:MovieClip;

function skinScrollPane() {

public function init():Void{

scrollUp_mc.onReleaseOutside=scrollUp_mc.onRelease ;


private function scrollContent():Void{


and yes I have check the instance names!!!

10-05-2005, 10:18 PM
All you did was declare the cont one as a MovieClip, you didnt ever define the path to it. you need to do this... all it is now is a variable with type MovieClip.

10-05-2005, 11:20 PM
Ok, missed the obvious from the button, but what about when i call the scrollContent function, the cont_mc is on the same main timeline of the movie clip that is associated with the class?!?. Ive tried this.cont_mc but dont work!!!
Sorry if Im missing obvious again bit of novice when it comes to classes!!

10-05-2005, 11:27 PM
the following should work.

create a class variable like this

private var classScope:MovieClip;

then in the constructor call the following.


then you should be able to call

classScope.cont_mc when you call things such as
everything in that function then has the scope of scrollDown_mc

for this you should look into the Delegate class which can be used like this
//at the beginning of the class
import mx.utils.Delegate;

then instead of
your function

you can call

scrollDown_mc.onPress=Delegate.create(this, yourFunction);

what this does is calls your function in the correct scope so you'll be able to access class variables etc

this is the scope you want to run it in which almost 100% of the time will be 'this'

and yourFunction is the function you want to call.

10-05-2005, 11:44 PM
Brilliant, I had looked at this delegate before for eventDispatch but didn't realise it could be used in this way, so not only have you solved my problem but have given me a full understanding of the delegate clas..

Many Thanks!!!!

10-06-2005, 12:01 AM
glad it worked