PDA

View Full Version : Variable Scope Problems



wayupthere
November 18th, 2008, 06:43 PM
This should be an easy question but I can't figure it out.

I have a document class with the variable lastClicked:Object on it.

On the stage I have an undertimined amount of movieclips defined my MyMC.as

When I click on a movieClip I want it to gotoAndStop(2), and the lastClicked to gotoAndStop(1).

I also want lastClicked to gotoAndStop(1) if I click anywhere on the stage.

But I have know Idea how to access last clicked

I tried importing the document class into the MyMc class
exending the DocumentClass with MyMC class
implementing the DocumentClass with MyMC class
MovieClip(lastClicked)
DocumentClast(lastClicked)
parent(lastClicked)
stage.lastClicked
root.lastClicked
MovieClip(root).lastClicked
and about a thousand other ways to get this to work and I still have no idea.

If I trace parent from MyMC it returns main timeline. So I put lastClicked on the main time line and traced parent.lastClicked and that still didn't work.

My understanding of this is that the main time line's stage is an instance of the document class. And each movie clip is an instance of the MyMC class. So stage.lastClicked should give me access. I also tried putting lastClicked in the main timeI don't see where I'm going wrong. Can anyone Please shed some light on this for me?

Thank You