开发者

Flash AS3 MovieClip Code Not Running

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 开发者_JAVA技巧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.


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;
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜