views:

512

answers:

5

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

A: 

Try adding

import flash.utils.*;

HTH

Hank Scorpio
A: 

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
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
pctroll
A: 

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
The casting didn't work for me; either inside or outside the class file :(
pctroll
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
+2  A: 

``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

JStriedl
A: 

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!

rob eberhardt