13 Replies Latest reply on Apr 3, 2009 1:34 PM by Tatious

    Cursor and Button Assistance

    Tatious
      Hi guys.... hope this the right place to post this stuff, I have two questions, but first some background -

      I'm a student with basic (but growing) knowledge of flash, and for one of my projects I have to create a website in Flash CS3 (an actionscript 2.0 file) which will then be imported in to Dreamweaver and uploaded.

      My two questions are -

      1. I have made a custom cursor to use on my website, I found a tutorial that told me to do the following.

      create a symbol that I wanted to use as my cursor, convert it to a movieclip named cursorNew_mc, insert it in to frame 1 of a new layer and name the instance cursornew and in the actions panel use the following script

      Code:

      Mouse.hide()
      startDrag(cursornew,true)

      Now this works ALMOST perfectly, the cursor moves, I can click with it.... However, my custom cursor is out of synch positionally from where it should be, it rests just below where it should be, by maybe an inch on my screen. What would have caused this (please remember I am a beginner) and what could I do to correct??

      2. My second question concerns connecting two .swf files together with a button in one of the .swf files. My lecturer showed me how to do this last week... In that say... 1.swf would include a button within the animation that when clicked would load 2.swf in its place. He showed us some code that I'm not able to access at the moment, but I believe I found it on another site, this is what i believe his code was (with the .swf name obv diff)

      Code:

      loadMovieNum("custom.swf", 0);

      And he told us to click on the button, go to the actions panel and paste that code, obviously with the name of the movie we want instead of custom.swf. and that if both files were situated in the same folder there would be no need for the rest of the root address.

      I just tried this, both with just the filename "movie2.swf" and with the root address "C:\Users\Simon\Desktop\flashsite\movie2.swf" and neither worked. It came up with this error

      Location - Scene = Scene 1, layer = Layer 46, Frame = 375, Line = 1
      Description - Statement must appear within on handler
      Source - loadMovieNum("C:\Users\Simon\Desktop\flashsite\mov ie2.swf", 0);

      Again, can anyone tell me what I may be doing wrong? And what I can do to sort it.
        • 1. Re: Cursor and Button Assistance
          Level 7
          >>Now this works ALMOST perfectly, the cursor moves, I can click with it....
          However, my custom cursor is out of synch positionally from where it should
          be,
          it rests just below where it should be, by maybe an inch on my screen. What
          would have caused this (please remember I am a beginner) and what could I do
          to
          correct??

          Edit the clip and move the graphic so that the spot you want to point/click
          with is at the clips 0,0 registration point.

          2. I suggest looking up, and using, the MovieClipLoader class and not bother
          with anything else. There's a good example in the onLoadInit method
          description that shows how to load a jpg into a clip. It's no different to
          load a .swf.

          --
          Dave -
          www.offroadfire.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: Cursor and Button Assistance
            Ned Murphy Adobe Community Professional & MVP
            1. Make sure your cursor is centered in its own stage

            2. If your instructor is teaching you to put code on objects... tsk, tsk...

            Anytime you attach code to an object it requires some form of an on handler to make it work...

            on(release){
            loadMovieNum("custom.swf", 0);
            }

            The better alternative is to have this code in the timeline where the button is placed (in an actions layer, not the button's layer)...

            btnName.onRelease = function(){
            loadMovieNum("custom.swf", 0);
            }
            • 3. Re: Cursor and Button Assistance
              Tatious Level 1
              Hey, thanks alot guys

              My first quesiton has been answered, all sorted now and perfect...

              My second one however I am still having trouble with

              DMennenoh - I looked in to the moviecliploader idea but i couldnt get it to work, I was getting errors when I checked the code.

              NedWebs - Your code technically seemed to work, in that when I checked the code for errors there were non, but when I export the movies (something i was told by my lecturer i would have to do in order to check the link is working) the button doesnt work, i clock on it and nothing happens.
              • 4. Re: Cursor and Button Assistance
                Ned Murphy Adobe Community Professional & MVP
                The code is correct, so there has to be something else. Does the custom.swf file exist in the same folder as the file you're testing?

                Which version of the code are you trying? If it's the second, you have to give your button an instance name and use that... my example used "btnName", but it can be whatever you name it.
                • 5. Re: Cursor and Button Assistance
                  Tatious Level 1
                  I've tried both of the options you gave me.

                  The the filename of the file is movie2.swf and the instance name of the button is gomovie2. All of my .swf files are located in the same folder as each other, as well as the .fla files.

                  For the first option I selected the button and pressed F9 and gave it the code -

                  on(release){
                  loadMovieNum("movie2.swf", 0);
                  }

                  and when that produced the results I explained in my earlier post I tried -

                  on(release){
                  loadMovieNum("C:\Users\Simon\Desktop\flashsite\movie2.swf", 0);
                  }

                  Which did the same.

                  For the second option I created a new layer and inserted a keyframe on the same frame number as my button, F9'd and inserted this code

                  gomovie2.onRelease = function(){
                  loadMovieNum("movie2.swf", 0);
                  }

                  And got the same results, then I tried again with the whole folder address and nothing was different.
                  • 6. Re: Cursor and Button Assistance
                    Ned Murphy Adobe Community Professional & MVP
                    Are you sure that's the instance name and not the name you assigned it in the library?

                    Try putting a trace inside the button function to see if it's ever getting in there...

                    trace("in the button function");
                    • 7. Re: Cursor and Button Assistance
                      Tatious Level 1
                      Its definitely the instance name of the button that Ive changed, how do I put the trace in? Thanks for your help so far btw, much appreciated
                      • 8. Re: Cursor and Button Assistance
                        Tatious Level 1
                        Just bumping this in the hope of still getting help
                        • 9. Cursor and Button Assistance
                          Ned Murphy Adobe Community Professional & MVP
                          You type it in, like any other code.

                          The help docs are very useful things to become familiar with. They would have answered that question for you.
                          • 10. Re: Cursor and Button Assistance
                            Tatious Level 1
                            Thanks for the reply, apologies for being really slow on knowing what to do, but as I said, I'm a real flash newbie (been using flash for only... 2 months or so)

                            I'm gonna start using the flash help files as much as poss, but I'm confused about about a few things,

                            1. Can this trace be used in either of the coding situations you mentioned earlier (where I either use a separate actions layer, or I code the button itself)

                            2. I am confused as to what I put inside the trace () brackets, as the example they use in the help file just makes absolutely no sense to me...

                            3. If 1. Is correct would the code (for example if I use a separate layer) be

                            gomovie2.onRelease = function(){
                            loadMovieNum("movie2.swf", 0);
                            };
                            trace("");

                            With whatever I have to put inside the brackets


                            • 11. Cursor and Button Assistance
                              Ned Murphy Adobe Community Professional & MVP
                              trace() is a very valuable tool to get an understanding of, and it is quite simple to understand. What it does is output whatever you ask it to, and it outputs it to the Output panel.

                              So you can use it to check what a value is equal to at a certain point during processing. This can be very helpful when something is coming up 'undefined' in an error message. Unfortunately, Flash isn't very good about telling you what it found that is undefined in such circumstances (kinda awkward since it knew enough to tell you about it... it should be able to explicitly identify what item it is). So you sometimes have to fish with different variables to see which isn't what you thought it would be. So if you had a variable named "myVar", you would trace its value using: trace(myVar);

                              You can also use it to simply let you know if something made it to a certain point in your processing, such as I suggested in your case. I usually just use trace("here"); If it makes it that far into the processing the output panel will display "here" (no quotes). Then you can keep moving it until it no longer appears... that usually points to a problem in whatever line of code preceded it.

                              So, specific to your situation...

                              gomovie2.onRelease = function(){
                              trace("here");
                              loadMovieNum("movie2.swf", 0);
                              };

                              ... will tell you if it made it into the button's onRelease function.
                              • 12. Re: Cursor and Button Assistance
                                Tatious Level 1
                                Thanks :)

                                I have done the trace, as you instructed (on the actions layer, keyframe located above my button) with that code and nothing came up in the output panel.
                                • 13. Re: Cursor and Button Assistance
                                  Tatious Level 1
                                  I have uploaded a .fla file if you are interested in looking at that

                                  http://www.megaupload.com/?d=3WOTS50W

                                  On this .fla the button is located on frame 88/ layer 64. With the actionscript located on the layer above. The button will be navigating to "movie3.swf"