0
votes

I've done this a million times already, yet for some reason it refuses to work now.

I've made a MovieClip of an electric wire with 3 different keyframes with a few frames between each. The first 2 keyframes have a single bitmap in each with a different picture, I want it to cycle between these two to make it look like the electricity is moving and not just sitting there. The 3rd keyframe has nothing, eventually I will put an image with the electricity off, so the player can walk through, I just haven't done it yet. Since I don't want it to run the last keyframe until the player turns it off, I put a gotoAndPlay(); command in the movie clip after the second frame looping it back to the first frame, problem is, the line refuses to work. I have copied and pasted it from other programs where it worked, I have checked the Frame Name, I put other lines in there, like stop(); trace(); and other things, but could not get ANY line of code to work in the MovieClip. There's probably something like "the layer is invisible, code will not run", but I can't tell what it is. I've deleted the symbol and started over, same problem. I've restarted Flash, same problem. I've restarted the computer, same problem. I even took it to a different computer, same problem. I don't know why it won't run this code, is there something disabling it that I overlooked? I have other code in the main timeline outside the movie clip and code in other movieclips that has always worked fine and continues to work fine, I don't see what the problem is.

I ignored the problem for a while, and worked on other things, but I had to add multiple frames to an existing movieclip (which I believe was created before the other one), and now this movieclip is having the same problem. Does anyone know how to fix this, before it spreads to the rest?

I would post some code, but there really isn't any considering it's only one or two lines I need to work, and I can really copy and paste the MovieClip in here.

Thanks in advance for any help.

1
Try some simple debugging and tell me what happens. ie put trace(currentFrame) on each of the frames in your MovieClip and see if there's any output.Marty
Nothing. It doesn't output anything, whether I put in currentFrame, or "ahfboaidnbah". It won't do anything.Doug
That's really odd. I'll answer with a solution that I would use, but it is pretty heavy for something this simple. Moment.Marty
Is it possible that you could post a fla with this core issue ? I know the answer solves this, but would be nice to have a conclusive "what was wrong". Also, do you reference the movieclip instance in code anwhere, besides on it's own timeline in the movieclip itself ?prototypical
This is in the final stages of the project, the .fla is I think 10 MB right now, and just explaining where to go to see the problem would relegate another question on this site. And I don't really know what caused the problem, only that his roundabout way worked, I can't really explain what the source was. And the MovieClip was not directly refrenced in the main timeline when the problem arose. I just dragged it onto the screen, since it was purely decorative. Since I had to turn it off though, I did have a gotoAndStop(); command, but that was after the problem was fixed.Doug

1 Answers

0
votes

Extremely odd, though you could use this as the base class for your MovieClip which should work a treat:

package
{
    import flash.display.MovieClip;
    import flash.events.Event;

    public class Elec extends MovieClip
    {
        // vars
        private var _prevFrame:uint = 1;

        /**
         * Constructor
         */
        public function Elec()
        {
            addEventListener(Event.ENTER_FRAME, _handle);
        }

        /**
         * Event.ENTER_FRAME
         */
        private function _handle(e:Event):void
        {
            if(_prevFrame == 2) gotoAndPlay(1);

            _prevFrame = currentFrame;
        }
    }
}