13 Replies Latest reply on Mar 9, 2008 6:20 PM by rlc5611

    On frame action,, Not on Button.?

    jameskachan Level 1
      Hi all.


      I have the code figured out for how to make Flash do what I want >> If I wanted this to be activated "On Click"
      ..like click the image, and have "THIS" happen.

      problem is I need code that will have the same effect but will activate ONCE FRAME 10 is reached in the movieclip that is playing.

      does anyone know how to write it so that it will work like this?


      Below is the code that works for the button.


      Thanks!
      James
        • 1. Re: On frame action,, Not on Button.?
          rlc5611 Level 1
          imgholder_mc.onEnterFrame = function(){
          if(this._currentframe >= 10){
          this._parent.btn_TEST_mc.onPress = function() {
          this._parent.imgholder_mc.unloadMovie();
          }
          delete this.onEnterFrame;
          }
          }
          • 2. Re: On frame action,, Not on Button.?
            jameskachan Level 1
            Thanks so much for your response!

            I got so excited, but it doesn't work.
            The move just restarts itself at the end.
            any idea why?
            • 3. Re: On frame action,, Not on Button.?
              rlc5611 Level 1
              That script depends on the relationship between the btn_TEST_mc and the imgholder_mc so the path will depend on that. Where is the button in relation to the image holder? Are they in the same timeline? That script should work if and only if the paths are correct. I took a best guess at the paths based on the little info you provided.
              • 4. Re: On frame action,, Not on Button.?
                jameskachan Level 1
                Hi ric,

                I really, really have to tell you, thanks for trying to help me with this.
                It's one of those things that's been getting to me, I'm so close with it!

                for ease sake, I have zipped and uploaded the 2 fla and swfs
                the download link is
                http://www.jameskachan.com/links/flash_jkachan_help.zip

                basically the gallery.zip opens first, there is a small grey "tester" button
                which loads "test1.swf" into an empty movie clip on the stage.
                on click "test1.swf" will unload, however I need it to do this on frame10 as you know.

                btn_TEST_mc is within the Loaded swf. - (test1,swf)
                imgholder_mc is in the stage level - (gallery.swf)

                Thanks : )
                • 5. Re: On frame action,, Not on Button.?
                  rlc5611 Level 1
                  You should not try to apply the onEnterFrame function until after the content is loaded in your image holder.

                  You might try MovieClipLoader rather than loadMovie because this class has event listeners available such as onLoadComplete that you could use to apply the onEnterFrame once the content was loaded.
                  • 6. Re: On frame action,, Not on Button.?
                    rlc5611 Level 1
                    Sorry we were cross posting. The way you have your files structured, why don't you just place that button script in the keyframe in frame ten where you have your stop(); Why did you put it in frame 1? What is it you are really trying to do? If you are wanting to make this happen from the main timeline in the gallery.fla, that would be different.
                    • 7. Re: On frame action,, Not on Button.?
                      jameskachan Level 1
                      umm.. well,
                      What I want is simply for a thumbnail to be clicked in gallery.swf.. which will load an external swf into the holder on the gallery stage (imgholder_mc)
                      This external swf will have an image in it which will fade in and stop, (just for transition effect. after stopped, the user clicks the image and the play resumes (fading out) and when finished (frame 10) the external.swf movie (in this case test1.swf is unloaded from img_holder_mc, giving the effect that the user is back once again at the thumbnail gallery.

                      I'm a photographer / print designer mostly, I don't really know flash well,
                      so, really whatever way is easiest to do this and works is good with me.

                      I would appreciate any advice/"how to do that" you might have.

                      Thanks
                      james.
                      • 8. Re: On frame action,, Not on Button.?
                        rlc5611 Level 1
                        The very simplest way for you to accomplish that is to remove your button script from frame one of the test.flw and place it on frame 10 where the stop(); is. This isn't possibly the best programming practice but represents by far the least amount of work. Any other option will be more complicated.

                        However, this is an example of a script that you would put in the main timeline of gallery.swf. You would put absolutely zero actionscript in test1.fla as this script will take care of it.
                        • 9. Re: On frame action,, Not on Button.?
                          rlc5611 Level 1
                          The advantage of this over loadMovie is that you have a listener to tell when the swf is completely loaded before trying to do anything to it. If you try loadMovie and immediately put an onEnterFrame function on it, it will be wiped when the loaded SWF instantiates. And if you really want to fade in/out, here are two different methods to do that. The fadein uses the onEnterFrame since it is already there while the fadeout uses setInterval. I'm guessing that you plan on doing a timeline fade on the image swfs but you really don't need to. You can make them all single frame movies and still accomplish the same thing. The attached below works with your ten frame test1 movie as it is (when AS is removed from its timeline);
                          • 10. Re: On frame action,, Not on Button.?
                            rlc5611 Level 1
                            While the following script would work if test1.swf is a single frame movie and this would be my preference because it keeps all the control in one place and avoids having to remember what all your different swfs are doing and what script they contain.
                            • 11. Re: On frame action,, Not on Button.?
                              rlc5611 Level 1
                              And why does the girl have a gun to her head?
                              • 12. Re: On frame action,, Not on Button.?
                                jameskachan Level 1
                                Holy christmas.

                                THANK YOU.
                                This is what I needed.
                                It is ,, umm way more complex than I was hoping for, but I guess this works so I will go with it.

                                Thank you so much.

                                PS oh, and there is a gun to her head because,, ahh im a photographer and it needed a bit of charge?
                                haha.
                                ought your attention!
                                • 13. Re: On frame action,, Not on Button.?
                                  rlc5611 Level 1
                                  Well I already told you what the simple solution was and it is always an option. That script isn't really complicated - it is just more lines of script. But if you can keep all your AS in one place, it is much easier to maintain.