12 Replies Latest reply: Apr 3, 2013 8:04 PM by asydd RSS

    Create a User-Interactive Flash

    kvnrizzo1

      Is there any way I can create an interactive Flash with which the user can put X-marks on random locations of a picture? (e.g. X marking different locations on a map.)

        • 1. Re: Create a User-Interactive Flash
          kglad CommunityMVP

          sure.

           

          but what's supposed to happen after those x's are placed?

          • 2. Re: Create a User-Interactive Flash
            kvnrizzo1 Community Member

            Well, I need to make an interactive PDF. In it, I'm supposed to put in a map that people can put X-marks on. I had no idea how to do it; so I started putting small (Acrobat) buttons all over the map. (I know you are laughing, but it wasn't funny, since it took me an entire weekend!)

            Now, the PDF looks good, and the map thing looks OK. But since I am a very curious person, I had to figure out how to do it correctly for my future projects.

            Kevin

            • 3. Re: Create a User-Interactive Flash
              kglad CommunityMVP

              in flash:

               

              create a movie the looks like the X-mark you want to place on your map and assign it a class (eg, XMark).

               

              add your map to the stage and add the following to your actions panel:

               

              this.addEventListener(MouseEvent.CLICK,clickF);

              function clickF(e:MouseEvent):void{

              var xmark:XMark=new XMark();

              this.addChild(xmark);

              xmark.x=e.stageX;

              xmark.y=e.stageY;

              }

              • 4. Re: Create a User-Interactive Flash
                kvnrizzo1 Community Member

                Thank you very much for the reply.

                I know very little about Flash, or AS for that matter. Is there any way I could find a step-by-step way of following your guide?

                 

                On my part, I opened Flash and clicked CTRL + R.

                I imported a PNG that looks like an "X".

                I then clicked F8, and chose the name XMark for my symbol, and checked "Export for ActionScript" and "Export in frame 1".

                I then clicked on File > New, and chose "ActionScript 3.0 Class". I typed the "Class name" as XMark.

                A window popped up with a default script (below).

                 

                Here's where I got stuck: I have two tabs. One is my PNG in the form of a movie, and one the script window.

                What do I do here? (I guess I am asking, how do I "merge" the two tabs into one flash?)

                 

                Also, do I cut and paste your script after the following, or should I delete the default script?:

                 

                package  {

                 

                    public class XMark {

                 

                        public function XMark() {

                            // constructor code

                        }

                 

                    }

                 

                }

                 

                 

                Any help would be very much appreciated.

                • 5. Re: Create a User-Interactive Flash
                  kglad CommunityMVP

                  open your fla with the XMark png in the library.  right click it>click properties>tick export for actionscript and assign the class name XMark if it's not already assigned>click ok.

                   

                  add your map to the stage and add the following to your actions panel:

                   

                  this.addEventListener(MouseEvent.CLICK,clickF);

                  function clickF(e:MouseEvent):void{

                  var xmark:XMark=new XMark();

                  this.addChild(xmark);

                  xmark.x=e.stageX;

                  xmark.y=e.stageY;

                  }

                  • 6. Re: Create a User-Interactive Flash
                    kvnrizzo1 Community Member

                    Sorry about the delay... In order to follow your directions, I had to learn Flash!

                     

                    OK, I made an fla. But the problem now is that I want the users to be able to "uncheck" a mistakenly placed X-mark.

                    Could you help me with that as well?

                     

                    Thank you so much.

                    Kevin

                    • 7. Re: Create a User-Interactive Flash
                      kglad CommunityMVP

                      use:

                       

                       

                      this.addEventListener(MouseEvent.CLICK,clickF);

                      function clickF(e:MouseEvent):void{

                      var xmark:XMark=new XMark();

                      this.addChild(xmark);

                      xmark.x=e.stageX;

                      xmark.y=e.stageY;

                      xmark.addEventListener(MouseEvent.CLICK,xmarkF);

                      }

                      function xmarkF(e:MouseEvent):void{
                      e.currentTarget.removeEventListener(MouseEvent.CLICK,xmarkF);

                      this.removeChild(e.currentTarget);

                      }

                      • 8. Re: Create a User-Interactive Flash
                        kvnrizzo1 Community Member

                        Thanks again.

                         

                        I got an "1118 Error" in the Compiler Errors window. It says that line 20 has an "implicit coercion of a value with static type Object to a possibly unrelated type flash.display: DisplayObject."

                        • 9. Re: Create a User-Interactive Flash
                          kglad CommunityMVP

                          that makes no sense, if line 20 is one of the lines of code i suggested.

                           

                          which line is it?

                          • 10. Re: Create a User-Interactive Flash
                            kvnrizzo1 Community Member

                            Sorry, it is Line 11, which is:

                             

                            this.removeChild(e.currentTarget);

                            • 11. Re: Create a User-Interactive Flash
                              kvnrizzo1 Community Member

                              KGlad, You have been very helpful and patient with my project.

                              But, it seems that even a simple, three-step project requires me to learn Flash, which will take a while.

                               

                              I appreciate all your help one again; and I will post in a few weeks, after learning the basics of Flash.

                               

                              Thank you so much.

                              • 12. Re: Create a User-Interactive Flash
                                asydd Community Member

                                This worked for me... giving the second function proximity to the variables etc: This was useful in that I didn't previously know how to get an MC directly from the library. Thanks MR K. although it is somewhat belated from the original post date

                                 

                                stop();

                                this.addEventListener(MouseEvent.CLICK,clickF);

                                function clickF(e:MouseEvent):void {

                                     var keybut:keyMC=new keyMC();

                                     this.addChild(keybut);

                                     keybut.x=e.stageX;

                                     keybut.y=e.stageY;

                                     keybut.addEventListener(MouseEvent.CLICK,keybutF);

                                 

                                     function keybutF(e:MouseEvent):void {

                                          e.currentTarget.removeEventListener(MouseEvent.CLICK,keybutF);

                                          this.removeChild(e.currentTarget); // but it didn't like this bit either as e.currentTarget or keybut

                                     }

                                }