Skip to main content
Participant
August 10, 2013
Answered

Class Breaking gotoAndStop

  • August 10, 2013
  • 1 reply
  • 681 views

I am making minesweeper.

I have a Movie Clip with linkage name 'tile' which is dynamically attached in a 2D array.

I have a class called 'tileClass' allowing me to define properties such as ._mine and ._marked rather than using dynamic variables such as instance["mine"]. I like using the class because it is a bit neater. This is for a Year 12 major projects so it also demonstrates a broader depth of knowledge.


My issue is that when I assign the 'tileClass' to the 'tile' Movie Clip in the library, I am no longer able to use the command 'gotoAndStop' on the tile movie clip. I use it to change between the sprites of the tile (eg. pressed, numbers, flagged). When the class is taken off I can change frames, if it is assigned, I can not. It has no errors, simply does not change the frame.


This is the class file (.as).

class tileClass{

     var _mine:Boolean;

     var _revealed:Boolean;

     var _marked:Boolean;

     var _surround:Number;

     var _xcor:Number;

     var _ycor:Number;

     function tileClass() {

          _mine = false;

          _revealed = false;

          _marked = false;

          _surround = 0;

     }

}

This is the place where I am trying to change frames

while(mineCount<(mines+1)) {

     randomNumber = Math.round(Math.random()* ((tilesDown * tilesAcross) - 1));

     tempX = randomNumber % tilesAcross; tempY = Math.floor(randomNumber / tilesAcross);

     if(_root["tile" + tempX + "_" + tempY]._mine == false) {

          _root["tile" + tempX + "_" + tempY].gotoAndStop(2);

          _root["tile" + tempX + "_" + tempY]._mine = true;

          trace("Mine: (" + tempX + "," + tempY + ") " + _root["tile" + tempX + "_" + tempY]); mineCount++;

     }

}

Any help is greatly appreciated, I have tried to find someone else with this issue and a solution but am so far unsuccessful.


-lokthelok

This topic has been closed for replies.
Correct answer kglad

tileClass needs to extend MovieClip if it's the class of a movieclip in your library:

class tileClass extends MovieClip{

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
August 10, 2013

tileClass needs to extend MovieClip if it's the class of a movieclip in your library:

class tileClass extends MovieClip{

Participant
August 10, 2013

Ahh, I have seen that around. What exactly does that achieve? Just so I know.

kglad
Community Expert
Community Expert
August 10, 2013

it allows tileClass to inheret all the methods, properties and events of the movieclip class.  that includes the gotoAndPlay and gotoAndStop methods.