1

Facts:

  • I have 2 classes: Entity and Ship. Entity extends MovieClip and Ship extends Entity.
  • I have a MovieClip associated to the Ship.as class file.

The thing is that I'm able to show, rotate and move the Ship object. However, I cannot change the pointer to the place I want in its timeline; in short: I can NOT have a successful response from gotoAndStop(n). It just doesn't work.

Thanks in advance.

I've already tried:

  • Casting the MovieClip inside and outside the class file.
  • Importing flash.utils.*
  • Changing the parameters from a number to a string (for the frame label).

The only way it's worked for me is deriving Ship directly from MovieClip and not from Entity; but that would be undesirable and last resort.

You can download the source files here: http://cid-7b6cf3fa8e7f0691.skydrive.live.com/self.aspx/ActionScript%20Exercises/Asteroids.zip

Jacob Poul Richardt
  • 3,145
  • 1
  • 26
  • 29
jorge_codes
  • 3,026
  • 4
  • 26
  • 25

5 Answers5

2

``select’’ Isn’t Broken

It is rare to find a bug in the OS or the compiler, or even a third-party product or library. The bug is most likely in the application.

-The Pragmatic Programmer

un-comment line 93-101 in Ship.as

comment out line 121 in Ship.as

Community
  • 1
  • 1
JStriedl
  • 1,296
  • 6
  • 10
0

Try adding

import flash.utils.*;

HTH

0

You might try changing the argument of gotoAndStop() from a number to a string, or from a string to a number. (Which might require you to add a frame label.) I've had a little trouble with this before.

fenomas
  • 11,131
  • 2
  • 33
  • 57
  • I tried but it didn't work. You can download the source files here: http://cid-7b6cf3fa8e7f0691.skydrive.live.com/self.aspx/ActionScript%20Exercises/Asteroids.zip – jorge_codes Sep 29 '09 at 15:05
0

That's strange. I would try casting the ship as a MovieClip -

MovieClip(myShipVar).gotoAndStop(1)

I've experienced weird behavior along those lines, where MovieClip methods simply don't work on something that's extending an extension of MovieClip - but I couldn't tell you why. If you cast it as a MovieClip just for that method call that should allow it to work - but I'm going to keep an eye on this thread to see if anyone who knows more about this responds.

Myk
  • 6,205
  • 4
  • 26
  • 33
  • The casting didn't work for me; either inside or outside the class file :( – jorge_codes Sep 29 '09 at 15:04
  • Hmm. Are you importing flash.display.MovieClip? I guess you'd get a compiler error if you weren't. Weird man, sorry, I don't know. – Myk Sep 30 '09 at 13:50
0

I've had trouble extending before and almost always use composition instead when I can. I solved the problem this way:

Change the linkage id of the ship movie clip in your library to this: Class: shipAsset Base class: flash.display.MovieClip

In ship.as, create a public var 'asset', and then create a new instance of it and add it to the display list of the Ship instance like this: asset = new shipAsset(); addChild(asset);

In Main.as, control the timeline like so: ship.asset.gotoAndStop('boost');

Hope that helps!