16 Replies Latest reply on Oct 28, 2009 5:10 AM by donkey2009

    Flash variable indicating number of unread emails

    donkey2009 Level 1

      Hi all

       

      would anyone beable to help me with a little flash variable. not sure how this works, just been asked to do it, doh!

       

      What I am trying to do.
      I have an email icon that when there is new messages would like to indicate the number of emails that are unread. this will simply be a number, that indicates how many unread messages

       

      We pass in the number of unread messages to the flash object like a URL request string.

       


      would anyone beable to explain how this is done with an AS2 script example, or direct me to any technote

       

      many thanks for your help

        • 1. Re: Flash variable indicating number of unread emails
          kgui-yG5PVz

          You need to do something like the following:

           

          Your URL : <a href="http://www.mywebsite.com/myflash.swf?myvariable=999">click here</a>

           

          In your flash, on the first frame, you create a dynamic text field, with an instancename like: myURLvariabele_txt

          Add to this textfield (is an option of this object), an variable with the same name as in the url: myvariable

           

          with myURLvariabele_txt.text you can see the value: 999

           

          The textfield can be located outside the flashscreen, so no user can see it.

          • 2. Re: Flash variable indicating number of unread emails
            donkey2009 Level 1

            hi there

             

            thanks for your reply

             

            ok, I have created the fla, with a text field and called it 'myURLvariabele_txt' but I am not sure what you mean by

             

            Add to this textfield (is an option of this object), an variable with the same name as in the url: myvariable

             

            can you please explain, sorry am a newbie to this : 0

             

            many thanks

             

            i have attached the fla example i have just done

            • 3. Re: Flash variable indicating number of unread emails
              donkey2009 Level 1

              hi there

               

               

              thanks for your reply, ok I have created dynamic textfield and called myURLvariabele_txt but a little unsure as to what you mean by

               

              Add to this textfield (is an option of this object), an variable with the same name as in the url: myvariable

               

              where do I do this, can you explain, sorry a newbie at this

               

               

              I have just created an example fla, see attached

              • 4. Re: Flash variable indicating number of unread emails
                kgui-yG5PVz Level 1

                HTML

                 

                  <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="200" height="200" id="example" align="middle">
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="false" />
                    <param name="movie" value="example.swf?myvariable=999" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" />   
                    <embed src="example.swf?myvariable=999" quality="high" bgcolor="#000000" width="200" height="200" name="example" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer_nl" />   
                  </object>

                 

                FLASH

                 

                *) Click on myURLvariabele_txt
                *) See TAB properties
                *) inside properties, find the OPTONS
                *) Find field "variable" in the OPTION, fill in ''myvariable''

                 

                See working example

                • 5. Re: Flash variable indicating number of unread emails
                  donkey2009 Level 1

                  hey there

                   

                  thanks for that.

                   

                  Ok I see what you have done, I see that.

                   

                  Q: how does it work then, when for example, there is 3 unread messages, would this be displayed in the 'myvariable_text' or 'myURLvariable_text'

                   

                   

                   

                  Am unsure as to what is happening,  aargghhh!!! : )

                   

                  so the bit that you have just explained, the myvariable, this is where I would put the URL link that would ?

                   

                   

                   

                   

                   

                   

                   

                  • 6. Re: Flash variable indicating number of unread emails
                    donkey2009 Level 1

                    I have something that is called 'EmailCount' variable which is the number of unread messages, does 'EmailCount' go where you said change 'myVariable

                     

                    : 0

                    • 7. Re: Flash variable indicating number of unread emails
                      donkey2009 Level 1

                      oohhh!!

                       

                      i see the AS

                       

                      trace("Variable using URL 'example.swf?myvariabele=" + myURLvariabele_txt.text + "'"); //  WHAT DO i NEED TO CHANGE HERE??
                      myvariable_txt.text = myvariable ;  <<<<< I REPLACE THIS WITH MY VARIABLE TO 'EmailCount'
                      trace("myvariabele="+myvariable );  <<<<<AND HERE ALSO REPLACE VARIABLE TO  'EmailCount'

                      stop();

                      • 8. Re: Flash variable indicating number of unread emails
                        donkey2009 Level 1

                        sorry for asking such newbie question but the thing that is confusing me is also

                         

                        example.swf?myvariable=999"

                         

                         

                        I understand what the 'example.swf' part is but  the '?myvariable=99"

                         

                        I should put  example.swf?EmailCount=999"

                         

                        where does the 999 come, or is this a random number to see if generates in flash...aaarrrggghhhhHHH!!!

                         

                        sorry for being such a newbie on this

                         

                         

                        • 9. Re: Flash variable indicating number of unread emails
                          kgui-yG5PVz Level 1

                          In the HTML change "example.swf?myvariable=999" to "example.swf?EmailCount=999" on 2 places (embed and object section).

                           

                          In the Flash code, change the  'myURLvariable_text' property, option field 'variable' into 'EmailCount'. Thats it.

                           

                          When the Flash movie is executed, the EmailCount=999 is converted into an variable. This variable is called 'EmailCount', but it has to be declared in Flash by you. You do that bij creating a dynamic TextField. It instance name is not inportant, but in this example it is called "myURLvariable_text".

                          A property of this dynamic TextField "myURLvariable_text" is the linkage with a Flash variable. For this you need to set the "myURLvariable_text" property -> options -> parameter field called 'variabele' into 'EmailCount'.

                          • 10. Re: Flash variable indicating number of unread emails
                            donkey2009 Level 1

                            hey there

                             

                            fantastic, thank you for breaking it down, bit by bit, sorry for such a newbie lot of question, I have done all that, many thanks.

                             

                            one final silly newbie question. with it all set up

                             

                            first line of the AS

                            trace("Variable using URL 'example.swf?EmailCount=" + myURLvariabele_txt.text + "'");

                             

                            how or where if any, do I ad the link to the url that will pass the variable?

                             

                             

                            am I making any sense, maybe I am not understanding correctly, I thinking there has to be a url link somewhere..aargghh!!!???

                             

                            thank you for your help

                            • 11. Re: Flash variable indicating number of unread emails
                              kgui-yG5PVz Level 1

                              ** how or where if any, do I ad the link to the url that will pass the variable? **

                               

                              a.) You do that in the HTML file using the Flash Object as shown in the example file.

                               

                              b.) You can yust call the Flash movie directly, with out any HTML Flash object.

                              In a HTML file you create a hyperlink, like this:

                               

                              <a href="example.swf?myvariable=999"> click me </a>

                               

                              creating a textlink in HTML.

                               

                              c.) from within Flash you can call HTML using getURL() function

                              Create a button.

                               

                              mybutton.onPress = function () {

                                   getURL("example.swf?myvariable=999");

                              }

                              • 12. Re: Flash variable indicating number of unread emails
                                donkey2009 Level 1

                                hi there

                                 

                                many many thanks for clearing that up, sorry for the silly questions,,never done this before so, just starting from the ground up and trying to understand what does what and how it works.

                                 

                                I understand what you are saying now, that makes it alot clearer.

                                 

                                 

                                again, many thanks for all your help, you a have been very generous and helpful with your time....thank you

                                 

                                 

                                • 13. Re: Flash variable indicating number of unread emails
                                  donkey2009 Level 1

                                  hi there

                                   

                                  thanks for helping me out, I have one little question I was wondering if you could help me with regarding the variable.

                                   

                                  At the moment it reads in the number of messages, what I would like to add is the word that appears and disappears depending on whether or not there is message!

                                   

                                  does this make any sense, I think its just a case of adding to the dynamic text field but not sure how?

                                   

                                  so for example;

                                   

                                  when there is no messages, there would be a word that simply says  'Inbox'

                                   

                                  when there is messages the word 'Inbox' would be replaced with the number of messages.

                                   

                                   

                                  aaargghh!!

                                   

                                   

                                  thanks for your help!

                                  • 14. Re: Flash variable indicating number of unread emails
                                    kgui-yG5PVz Level 1

                                    If you didn't do it already. create a dynamic text field "myvariable_txt"

                                     

                                    Put the following code in a frame.

                                     

                                    if (Number(myvariable)==0) myvariable_txt.text = "inbox" ;
                                    else myvariable_txt.text = myvariable+" messages" ;

                                     

                                    /* OR when using yourEmailCount as in  example.swf?EmailCount=0
                                        if (Number(EmailCount)==0) myvariable_txt.text = "inbox" ;
                                        else myvariable_txt.text = EmailCount+" messages" ;
                                    */

                                     

                                    === OR THIS IS BETTER ==

                                    switch ( Number(EmailCount) ) {

                                         case 0 :

                                              myvariable_txt.text = "inbox" ;

                                              break;

                                         case 1 :

                                              myvariable_txt.text = "1 message" ;

                                              break;

                                         default :

                                              myvariable_txt.text = EmailCount+" messages" ;

                                    }

                                    • 15. Re: Flash variable indicating number of unread emails
                                      donkey2009 Level 1

                                      hi there

                                       

                                      thanks for replying again.

                                       

                                      can you please show with the example as very confusing....sorry for being such a newbie?

                                       

                                      thank you for your help

                                       

                                      I have attached the demo file

                                      • 16. Re: Flash variable indicating number of unread emails
                                        donkey2009 Level 1

                                        I was given this, does this do the same job?

                                         

                                         

                                        if (EmailCount != "0")
                                        myvariable_txt.text = EmailCount ;
                                        else
                                        myvariable_txt.text = "Inbox";