23 Replies Latest reply on Apr 28, 2006 5:22 AM by Lucy4

    SWF File question...PLEASE HELP

    Lucy4
      I've been asked to edit a Flash web site. The page they want me to edit has a form on it, but they only have the .swf file. I've opened it in Flash and am able to make the required changes, but they thing I wanted to know is will the form be affected if I then re export it as a .swf file or will it still work as it did before?

      Thanks for your help,
      Lucy
        • 1. Re: SWF File question...PLEASE HELP
          Level 7
          Lucy,

          > The page they want me to edit has a form on it, but they
          > only have the .swf file.

          Thet'll need to dig up the source file (FLA) for you.

          > I've opened it in Flash and am able to make the required
          > changes,

          You are? What changes are you making? By importing this SWF, you're
          losing any of the ActionScript that went with it.

          > but they thing I wanted to know is will the form be affected
          > if I then re export it as a .swf file or will it still work as it
          > did before?

          You betcha. The only thing that imports with SWFs are shapes, text
          fields, and other visual objects (movie clips, etc.). ActionScript does not
          import, which means the form will no longer post its information as it did
          before.


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: SWF File question...PLEASE HELP
            Level 7
            as david says - and just to add - SWF is to FLA as JPG or GIF is to PSD - it is compressed format -
            like Urami once said, you can't get the egg back after making the omellette. you need the FLA.

            ******************************************
            --> Adobe Certified Expert (ACE)
            --> www.mudbubble.com :: www.keyframer.com
            --> http://flashmx2004.com/forums/index.php?
            --> http://www.macromedia.com/devnet/flash/articles/animation_guide.html
            --> http://groups.google.com/advanced_group_search?q=group:*flash*&hl=en&lr=&ie=UTF-8&oe=UTF-8




            Lucy4 wrote:
            > I've been asked to edit a Flash web site. The page they want me to edit has a
            > form on it, but they only have the .swf file. I've opened it in Flash and am
            > able to make the required changes, but they thing I wanted to know is will the
            > form be affected if I then re export it as a .swf file or will it still work as
            > it did before?
            >
            > Thanks for your help,
            > Lucy
            >
            • 3. Re: SWF File question...PLEASE HELP
              Lucy4 Level 1
              How easy is it then to a php to a Flash document to get the form to work?
              • 4. Re: SWF File question...PLEASE HELP
                C-Rock Level 2
                it's very easy there are hundreds of tutorials online for this. i found it's the easiest to download the sample files from a tutorial that does this and change what they have to suit your needs. testing it every few minutes making sure it still works. that's how i learned, it was easy... good luck
                • 5. Re: SWF File question...PLEASE HELP
                  Lucy4 Level 1
                  I've just fouind out that the form was probably done with cgi scripting, but I know nothing about that. I'd be grateful for any help that anybody can give me. If it helps the original .swf file (the one that works) is at http://www.lucyohara.talktalk.net/Bburns_form.swf

                  Thanks
                  • 6. Re: SWF File question...PLEASE HELP
                    Level 7
                    Lucy4,

                    > I've just fouind out that the form was probably done with
                    > cgi scripting, but I know nothing about that.

                    Do they not *have* the FLA? If they do, your job is easy ... just leave
                    all the existing ActionScript in place, make your other changes (the nature
                    of which you still haven't described), and it will just work.

                    > I'd be grateful for any help that anybody can give me.
                    > If it helps the original .swf file (the one that works) is at
                    > http://www.lucyohara.talktalk.net/Bburns_form.swf

                    SWFs is a compiled, "sealed" documents, I'm afraid. They're a "done
                    deal" and you really can't open them again and poke around inside unless you
                    have a SWF decompiler and know how to use it.

                    What we'll need to know in order to help you are the names of the form
                    fields. Not the "friendly" name that appears in the SWF, but the variable
                    names that carry each field datum to the server. It doesn't really matter
                    if the server is running CGI (perhaps Perl), PHP, ASP, or whatever ... you
                    just need to hear from this company which fields they need and what the
                    variable names are. If you can get the FLA (the source file), you'll be on
                    easy street, because all of that information will be in it.


                    David
                    stiller (at) quip (dot) net
                    Dev essays: http://www.quip.net/blog/
                    "Luck is the residue of good design."


                    • 7. Re: SWF File question...PLEASE HELP
                      Lucy4 Level 1
                      I don't know what the variable name are and the company isn't in contact with the person who originally created the document. I think that I'll have to redo the form, but I've never done anything with cgi. They have a cgi form on the html side of the site is it possible to use that code?

                      By the way they want me to change the address.
                      • 8. Re: SWF File question...PLEASE HELP
                        Level 7
                        Lucy4,

                        > I don't know what the variable name are and the company
                        > isn't in contact with the person who originally created the
                        > document.

                        Wow. :-/

                        > I think that I'll have to redo the form, but I've never done
                        > anything with cgi.

                        Well, fortunately, you don't have to know anything about how CGI works
                        to post a form. Depending on how the form is written, you may not even need
                        to know the variable names, now that I think of it. But again, it all
                        depends on how the CGI form mailer is written.

                        > They have a cgi form on the html side of the site is it possible
                        > to use that code?

                        This may be just what you need. View the source of that HTML form and
                        look at the <form> element and all its <input> elements. Assuming this HTML
                        form posts to the same CGI as the Flash, this will give you all the
                        information you need.

                        > By the way they want me to change the address.

                        Address of what?


                        David
                        stiller (at) quip (dot) net
                        Dev essays: http://www.quip.net/blog/
                        "Luck is the residue of good design."


                        • 9. Re: SWF File question...PLEASE HELP
                          Lucy4 Level 1
                          I've enclosed the HTML code, but I'm not sure which part is relevant.
                          • 10. Re: SWF File question...PLEASE HELP
                            Level 7
                            Lucy4,

                            > I've enclosed the HTML code, but I'm not sure which
                            > part is relevant.

                            The <form> element, and its <input> elements, are relevant.

                            > <Form method=POST
                            > action=" http://cgi.www.blackburns.ltd.uk/cgi-bin/www.blackburns.ltd.uk/form-mail
                            > .pl">

                            The action attribute tells you where this form needs to post. The .pl
                            file extension usually means Perl, not that that matters.

                            > <input type="text" name="realname" size="25">

                            There's an example of one of the <input> elements. The name attribute
                            tells you what this field's variable name needs to be: realname. Here's
                            another ...

                            > <input type="text" name="company" size="25">

                            ... which means you'll need another text field associated with the variable
                            name company, and so on. The name attributes tell you what variables you
                            need to send.

                            Next, you'll have to choose any of the available ways in ActionScript to
                            post these variables. The LoadVars class is a good, solid approach. Look
                            that up in the ActionScript Language Reference and take a gander at the
                            examples. See what makes sense, and what doesn't, then come back with
                            specific questions, if you still have them


                            David
                            stiller (at) quip (dot) net
                            Dev essays: http://www.quip.net/blog/
                            "Luck is the residue of good design."


                            • 11. Re: SWF File question...PLEASE HELP
                              Lucy4 Level 1
                              So do I need to put this code into the html file and who do I determine what e-mail address the results will be sent to?

                              <Form method=POST action=" http://cgi.www.blackburns.ltd.uk/cgi-bin/www.blackburns.ltd.uk/form-mail.pl">
                              <input type="text" name="realname">
                              <input type="text" name="company">
                              <input type="text" name="username">
                              <textarea rows="4" name="comments"></textarea>
                              <input type="submit" value="Submit">
                              • 12. Re: SWF File question...PLEASE HELP
                                Level 7
                                Lucy4,

                                > So do I need to put this code into the html file

                                I'm a bit confused by that question. This code is already *in* an HTML
                                file, right? What you're talking about is using Flash to submit to a CGI
                                application. This is possible both from HTML and from Flash. If you want
                                to do this from Flash, you need to make a note of the variables used in the
                                HTML form (realname, company, username, etc.), then use those names in your
                                ActionScript in cahoots with LoadVars to sumbit the data from Flash.

                                This is only true, by the way, if your Flash file is supposed to submit
                                to the same CGI application that this HTML file does.

                                > and who do I determine what e-mail address the
                                > results will be sent to?

                                You don't. That depends on how the CGI application is written. Anybod
                                who knows Perl should be able to figure it out. I don't really know Perl,
                                I'm afraid.


                                David
                                stiller (at) quip (dot) net
                                Dev essays: http://www.quip.net/blog/
                                "Luck is the residue of good design."


                                • 13. Re: SWF File question...PLEASE HELP
                                  Lucy4 Level 1
                                  The HTML file is for a seperate form on the site. So does that mean then that I don't need to add any additional code to the HTML page that the Flash form will be on? Also I've added the following code to the submit button on the Flash file, but am not sure if it will work okay:

                                  on (release) {
                                  if (!realname.length) {
                                  EmailStatus = "Please Enter your name before Sending";
                                  }

                                  else if (!company.length) {
                                  EmailStatus = "Please Enter your company before Sending";
                                  }

                                  if (!username.length || username.indexOf("@") == -1 || username.indexOf(".") == -1) {
                                  EmailStatus = "Please enter a valid E-mail address";
                                  }

                                  else if (!comments.length) {
                                  EmailStatus = "Please enter your comments";
                                  }

                                  else {
                                  loadVariablesNum ("snowMailPHP.php", "0", "Post");
                                  EmailStatus = "Sending...";

                                  }
                                  }

                                  Thanks for helping me with this.
                                  • 14. Re: SWF File question...PLEASE HELP
                                    Level 7
                                    Lucy4,

                                    > The HTML file is for a seperate form on the site.

                                    Okay. Sometimes people provide two versions ... a "jazzy" Flash version
                                    and a "plain vanilla" HTML version. If that form is a different one
                                    altogether, then the variables required by form-mail.pl might have nothing
                                    to do with the variables required by the script to which your SWF must
                                    submit. Until we know how form-mail.pl works, we simply don't know what to
                                    send to it.

                                    It *might* be the case that form-mail.pl was written to receive *any*
                                    variables. You won't know until you try. Send whatever variables you like
                                    and see what comes out at the other end (whoever it is that receives the
                                    email sent by the Perl script).

                                    Then again, it might be the case that form-mail.pl requires a certain
                                    set of variables. If those variables are different from the ones you showed
                                    me in that HTML form, you'll have to find out what those variables are.
                                    That only makes sense, right?

                                    > So does that mean then that I don't need to add any
                                    > additional code to the HTML page that the Flash
                                    > form will be on?

                                    An HTML page *could* have both an HTML form and a Flash form, by why
                                    would a developer do that? It would confuse people ... you can already hear
                                    them asking, "Which form should I fill out?" When a developer produces two
                                    versions, they're both completely separate. Some developers like to provide
                                    site visitors with a Flash version of the site and a non-Flash version of
                                    the site -- but they're never provided side-by-side on the same HTML page.

                                    Your Flash form has nothing to do with existing HTML on the page --
                                    other than the <object> and <embed> tags necessary to embed the SWF in the
                                    document. There shouldn't be a form on the SWF's HTML page at all.

                                    > Also I've added the following code to the submit button
                                    > on the Flash file, but am not sure if it will work okay:
                                    >
                                    > on (release) {
                                    > if (!realname.length) {
                                    > EmailStatus = "Please Enter your name before Sending";
                                    > }

                                    This code might work and it might not. Without know what it's supposed
                                    to do, I can't answer the question. First, you're checking of an
                                    object, realname, has a length property greater than zero. The way this is
                                    written, you're coincidentally checking of the realname object has a length
                                    property at all. My question to you is, what sort of object is realname?
                                    Is it a String? Is it an Array?

                                    My guess is that it's a String (after all the String class does define a
                                    String.length property), but if so, where is this string coming from? Does
                                    realname represent an input text field somewhere in your SWF? If so, you
                                    should probably be referencing that text field's TextField.text property.
                                    In other words, you presumably have an input text field in your movie, and
                                    that text field's instance name is realname. Since realname is an instance
                                    of the TextField class, you'll use the TextField.text property to retrieve
                                    the text inside that text field. And since TextField.text returns a string,
                                    you can use the expression realname.text in place of your string in the
                                    expression myString.length. Combined, that would be ...

                                    if (realname.text.length == 0)

                                    ... or ...

                                    if (!realname.text.length)

                                    Does that make sense to you? If it doesn't, that's fine, but it means
                                    you need to familiarize yourself with what it means to use objects in
                                    ActionScript.

                                    The next part ...

                                    EmailStatus = "Please Enter your name before Sending";

                                    ... might mean something, too. But I have no idea what EmailStatus is. Is
                                    that a variable you'll be using later? There is no EmailStatus entry in the
                                    ActionScript Language Reference, so this must be something you've defined or
                                    written somewhere. Without that description from you, I have no way of
                                    telling you what EmailStatus is for -- or, for example, if it can be set to
                                    a String, as you've done here.

                                    > loadVariablesNum ("snowMailPHP.php", "0", "Post");
                                    > EmailStatus = "Sending...";

                                    Now, this part may be fine. I don't know what snowMail.PHP.php is.
                                    Presumably, it's a form handler. If so, it's either a form handler that can
                                    handle exactly the variables you'll be sending or any variables at all.
                                    Your second parameter, "0", is incorrect. That needs to be a Number, not a
                                    String (see the loadVariablesNum entry of the ActionScript Language
                                    Reference for details).


                                    David
                                    stiller (at) quip (dot) net
                                    Dev essays: http://www.quip.net/blog/
                                    "Luck is the residue of good design."


                                    • 15. Re: SWF File question...PLEASE HELP
                                      Lucy4 Level 1
                                      Okay I did understand some of what you said. I downloaded a tutorial from FlashKit and that is where the ActionScript came from. The realname is somebodies actual name. I've searched through the entire site and can't find any file with a .pl extension. Does this mean I'll have to create on. Also the HTML form is on one page, but the Flash form will be on a totally different one.
                                      • 16. Re: SWF File question...PLEASE HELP
                                        Level 7
                                        Lucy4,

                                        > Okay I did understand some of what you said. I downloaded
                                        > a tutorial from FlashKit and that is where the ActionScript came
                                        > from.

                                        It is extremely important, then, that you pick apart the FlashKit
                                        example *as an example,* and not as a template for your own ActionScript.


                                        > The realname is somebodies actual name.

                                        Actually, it isn't. This is pretty important, too. The variable
                                        realname is an instance of a given class, which determines its data type.
                                        ActionScript has strings (quoted material), numbers (integers, decimal
                                        numbers, etc.), arrays (lists of things), movie clips (you know what those
                                        are), text fields (ditto), etc. Each of these objects have certain
                                        characteristics that make them what they are. Movie clips, for example,
                                        have timelines and display visuals and can be clicked, etc. Strings are
                                        chunks of text: they have no timelines, etc. Makes sense, right? Each of
                                        these types of objects has very strict definitions. Each of these has a
                                        "blue print" that determines what kind of object is. This blue print is
                                        called a "class," and every object in ActionScript has a class entry in the
                                        ActionScript Language Reference, right there behind your F1 key, right at
                                        your service. You have an "Owner's Manual" for every object in
                                        ActionScript.

                                        Read this for an overview ...

                                        http://www.quip.net/blog/2006/flash/actionscript-20/ojects-building-blocks

                                        So in your case, it all comes down to what realname actually represents
                                        as an object. Sure, in the "real world" this object represents someone's
                                        name. Of course that makes sense. But in the ActionScript world, this
                                        person's name must be described somehow in your code. Ultimately, a
                                        person's name would be a string (not a number, not an array, etc.). And
                                        this string must come from somewhere (entered by the user). The user enters
                                        this information into an input text field. So, you're dealing with the
                                        TextField class. This makes sense, right? Look up the TextField class --
                                        after you've read that "building blocks" article, above -- and you'll find a
                                        TextField.text property. Aha! So the TextField class, which defines
                                        dynamic and input text fields, has a property that represents a string.

                                        You're really going to have to "get" these concepts in order to proceed.
                                        Copying sample code from FlashKit is a fine idea for getting inspiration,
                                        but unless you pick apart the sample code and understand what it's doing,
                                        you won't learn this stuff. And if you don't learn this stuff, you will
                                        always have more questions than answers.

                                        > I've searched through the entire site and can't find any file with
                                        > a .pl extension.

                                        It is presumably in your cgi-bin, which may or may not be in the same
                                        area as your non CGI files.

                                        > Does this mean I'll have to create on.

                                        Not necessarily. If you prefer to use PHP (such as in the example from
                                        FlashKit), you can do that instead and simply put your PHP form handler into
                                        the same folder as your other HTML files. Assuming, of course, that your
                                        host supports PHP. It may; it may not. You have to research all of these
                                        things.


                                        David
                                        stiller (at) quip (dot) net
                                        Dev essays: http://www.quip.net/blog/
                                        "Luck is the residue of good design."


                                        • 17. Re: SWF File question...PLEASE HELP
                                          Lucy4 Level 1
                                          I"ve read the artilce you mentioned and I've also read as much as I can about objects and classes, but I can't find textField class in the reference guide (I'm sing MX would that make a difference). I've got to get this finished before the end of tomorrow and am finding it very difficult to take things in. I've found the formMail.pl file and all it says about realname is:

                                          # Now send mail to $recipient

                                          open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
                                          print MAIL "Reply-to: $FORM{'username'} ($FORM{'realname'})\n";
                                          print MAIL "Subject: WWW comments (Forms submission)\n\n";
                                          print MAIL "$FORM{'username'} ($FORM{'realname'}) of $FORM{'company'} sent the following\n";
                                          print MAIL "comment:\n\n";
                                          print MAIL "------------------------------------------------------------\n";
                                          print MAIL "$FORM{'comments'}";
                                          print MAIL "\n------------------------------------------------------------\n";
                                          print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
                                          print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
                                          print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
                                          close (MAIL);

                                          On the form it says 'name' before the realname textField and I've set the variable the realname as well.

                                          Sorry to keep asking about this, but I'm finding it difficult to get my head round at the moment.
                                          • 18. Re: SWF File question...PLEASE HELP
                                            Level 7
                                            Lucy4,

                                            > I"ve read the artilce you mentioned and I've also read as
                                            > much as I can about objects and classes, but I can't find
                                            > textField class in the reference guide (I'm sing MX would
                                            > that make a difference).

                                            Yes. Flash MX is Flash 6, and Flash 8 is the current version. The
                                            documentation started using the terminology "class" in Flash MX 2004 (aka
                                            Flash 7).

                                            > I've got to get this finished before the end of tomorrow and
                                            > am finding it very difficult to take things in.
                                            > I've found the formMail.pl file and all it says about realname is:

                                            > open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
                                            > print MAIL "Reply-to: $FORM{'username'} ($FORM{'realname'})\n";

                                            You betcha. By the time the variable gets to Perl, it's a string. By
                                            the looks of it, this Perl script is expecting to see the following
                                            variables: username, realname, company, comments -- and that's it. It does
                                            not look set up to handle any additional variables than those. Caveat: I
                                            am not a Perl programmer; this is just what I believe I'm seeing.

                                            So your Flash movie is going to need those same variables in order to
                                            send them.

                                            You could use the Var field in your Property inspector to assign each of
                                            these variables, in turn, to the input text fields in your FLA. If your
                                            text fields are in the main timeline, then your variables will also be in
                                            the main timeline.

                                            You'll use loadVariables() to send those variables to the location of
                                            this Perl file as described in the documentation.

                                            > On the form it says 'name' before the realname textField
                                            > and I've set the variable the realname as well.

                                            When you say "the form" are you talking about the HTML document? If so,
                                            please understand that the HTML document has nothing to do with the SWF --
                                            nothing beyond embedding the SWF. There does not need to be a <form> in the
                                            HTML document.

                                            > Sorry to keep asking about this, but I'm finding it difficult
                                            > to get my head round at the moment.

                                            It's okay. This stuff *is* difficult until you understand it.


                                            David
                                            stiller (at) quip (dot) net
                                            Dev essays: http://www.quip.net/blog/
                                            "Luck is the residue of good design."


                                            • 19. Re: SWF File question...PLEASE HELP
                                              Lucy4 Level 1
                                              Thanks for helping with this. I've set the var field to the right names and changed the code for the submit button in the Flash file to;

                                              on (press) {
                                              loadVariablesNum("form-mail.pl", 0);
                                              }
                                              • 20. Re: SWF File question...PLEASE HELP
                                                Level 7
                                                Lucy4,

                                                > Thanks for helping with this.



                                                > I've set the var field to the right names and changed the
                                                > code for the submit button in the Flash file to;
                                                >
                                                > on (press) {
                                                > loadVariablesNum("form-mail.pl", 0);
                                                > }

                                                That would mean your Perl file would be in the same folder as the HTML
                                                document that contains the SWF. You may have to change the first parameter
                                                to the full path to the Perl file, and you'll have to specify "POST" as your
                                                third parameter, per the loadVariablesNum() entry in the docs.


                                                David
                                                stiller (at) quip (dot) net
                                                Dev essays: http://www.quip.net/blog/
                                                "Luck is the residue of good design."


                                                • 21. Re: SWF File question...PLEASE HELP
                                                  Lucy4 Level 1
                                                  The .pl file is in the cgi-bin folder and the .swf file inside the flash folder which is inturn inside the docs folder. I've changed the code to:

                                                  on (press) {
                                                  loadVariablesNum("../../cgi-bin/form-mail.pl", 0, "POST");
                                                  }

                                                  is that right or should I change it to something else? like:

                                                  on (press) {
                                                  loadVariablesNum("http//www.blackburnsdesign.com/cgi-bin/form-mail.pl", 0, "POST");
                                                  }
                                                  • 22. Re: SWF File question...PLEASE HELP
                                                    Level 7
                                                    Lucy4,

                                                    > The .pl file is in the cgi-bin folder and the .swf file inside the
                                                    > flash folder which is inturn inside the docs folder. I've changed
                                                    > the code to:
                                                    >
                                                    > on (press) {
                                                    > loadVariablesNum("../../cgi-bin/form-mail.pl", 0, "POST");
                                                    > }

                                                    That may or may not be right. It depends on where the HTML page is that
                                                    holds the SWF. The HTML's location is where the SWF sees its "point of
                                                    view."

                                                    > is that right or should I change it to something else? like:
                                                    >
                                                    > on (press) {
                                                    >
                                                    > loadVariablesNum("http//www.blackburnsdesign.com/cgi-bin/form-mail.pl", 0,
                                                    > "POST");
                                                    > }

                                                    That wouldn't hurt, because that's an absolute path. No guessing,
                                                    there.


                                                    David
                                                    stiller (at) quip (dot) net
                                                    Dev essays: http://www.quip.net/blog/
                                                    "Luck is the residue of good design."


                                                    • 23. Re: SWF File question...PLEASE HELP
                                                      Lucy4 Level 1
                                                      Thank for helping me with this.