2 Replies Latest reply on Sep 3, 2010 10:11 AM by shawn234

    External Variables help

    shawn234

      I've got this custom video player project I'm working on.  I'm so close  to being done, but the one thing that's standing in my way is setting up  an external file to define 4 variables.

      1 is a simple text string:
      title.text=variable1;
      variable1 would be something like:
      My Project's Title

      1 is a text string that displays a block of HTML code (using ascii for <, >, " and = )
      codeBlock.htmlText=variable2;
      variable2 would look like:
      &#60;object width&#61;&#34;800&#34;  height&#61;&#34;450&#34;&#62;&#60;param  name&#61;&#34;movie&#34;  value&#61;&#34;player.swf&#34;&#62;&#60;embed  src&#61;&#34;player.swf&#34;  width&#61;&#34;800&#34;  height&#61;&#34;450&#34;&#62;&#60;&#47;embed&#62;&#60;&#47;object&#62;

      1 is a URL
      thisLink:String=variable3;
      variable3 would be:
      http://www.twitter.com/home?I%20made%20this%20http://www.mylink.com

      1 is a hex code used to control the tint of an MC
      mcColor:String=variable4;
      variable4 is:
      0xFF0000

      I have a txt file set up like this, but it's not quite working.
      &videoTitle=Project:ORION Episode  100&twitterLinkage=http://www.twitter.com/home?Check%20this%20out%20http://www.legendzero.com/forum&embed_cod e=&#60;object  width&#61;&#34;800&#34;  height&#61;&#34;450&#34;&#62;&#60;param  name&#61;&#34;movie&#34;  value&#61;&#34;player.swf&#34;&#62;&#60;embed  src&#61;&#34;player.swf&#34;  width&#61;&#34;800&#34;  height&#61;&#34;450&#34;&#62;&#60;&#47;embed&#62;&#60;&#47;object&#62;&colorHexCode=0xFF0 000

      Any ideas how I can fix this?

        • 1. Re: External Variables help
          Rothrock Level 5

          I would probably look into using XML to define the structure of your external text file. There are many good things about that approach.

           

          Your post is also very difficult to read due to all the crazy characters and all. And in the end you ask if there is a way to "fix this?" but it isn't at all clear what "this" is.

           

          Often I recommend if you are having trouble doing something to set aside your current project and create a simplified "test." So can you just read in the project title and does it work? What about if you add just the color? At what point does it break?

           

          My guess is a combination of things.

           

          if you do something like this in your text file:

           

          videoTitle=Some Title Goes Here

          &someothervariable=etc

          &etc.

           

          You will get the invisible returns from the ends of the lines. So in that case your file should be formatted like this:

           

          videoTitle=Some Title Goes Here&

          &someothervariable=etc&

          &etc.

           

          I also suspect that everything will be loaded in as text. So

           

          colorHexCode=0xff0000

           

          Will mostly be a string instead of a number, so you might have success with it in certain cases, but in others it will behave as a string. So

           

          trace(colorHexCode-2) // this will trace out a number

          trace(colorHexCode+2) // this will trace out 0xff00002

           

          If you want to be sure to convert it to a number you should use parseInt() or parseFloat() to do the conversion.

          • 2. Re: External Variables help
            shawn234 Level 1

            Sorry for being so cryptic in the original post.

             

            What I was trying to explain in the first post was the difference of the 4 variables: The first is a text phrase, the second is a twitter link, the third is a block of text that physically shows the embed code so others can copy/paste it to their sites/blogs/what-have-you and the fourth is the hexcode to change the color of a movieclip.

             

            I noticed that XML may be the way to go, since I could simply call it in the project's URL within its object/embed HTML code. I could try something like

             

            <variables>
            <v1>title="Title"</v1>
            <v2>twitter="http://www.twitter.com/home?status=Got some good stuff here"</v2>
            <v3>embed_code="<object=...><params name=... /><embed src=...></embed></object>"</v3>
            <v4>hex_color="0xFF0000"</v4>
            </variables>
            

             

            Then I could call those variables into the project's actionscript, right?

             

            If there's a better way, please let me know