7 Replies Latest reply on Oct 16, 2006 10:47 PM by kglad

    Converting Actionscript from 1.0 to 2.0

    ChuckRWD
      I am trying to convert Actionscript written in 1.0 to 2.0 for Flash 8. It is from a tsunami menu I downloaded off kirupa.com. There is no actions layer where al the actionscript is kept, and I have tried to convert it. I customized the menu and the tsunami effect works great, however, when I try to convert the actionscript, it is a mess. I am building a flash site, and don't want to have to import the swf containing my menu. If I do have to do that, will the fact that it is written in Actionscript 1 for Flash Player 4 have any bearing on the fact that I am making the site for Flash Player 8 or above? Also, how can I import just the text portion without any background (transparent background) in Flash so it lays neatly over the background I've created for the site? Although I have designed many flash headers and elements for my HTML websites, I am a newbie when it comes to Flash Site design and have a ton of questions, but this will get me started. Thank you for your time.
        • 1. Re: Converting Actionscript from 1.0 to 2.0
          kglad Adobe Community Professional & MVP
          do you mean when you publish using actionscript 2.0 your menu doesn't function correctly? can you find all the code?
          • 2. Re: Converting Actionscript from 1.0 to 2.0
            ChuckRWD Level 1
            The code is not in an "actions layer", it is attached to buttons and movie clips. Here is the code:

            colnum = "1";
            startnum = 1;
            endnum = 19;
            numberofItems = 19;
            mouseposX = int(getProperty("../dragscale", _x));
            mouseposY = int(getProperty("../dragscale", _y));
            i = startnum;
            m = startnum;
            filledSpace = 0;
            gapspace = 0;
            if (Number(myInit) == Number(FALSE)) {
            // on first run make an array of all the text Y Pos.
            while (Number(i)<=Number(endnum)) {
            set("textY" add i, getProperty ("text" add i, _y ) );
            i = Number(i)+1;
            }
            i = startnum;
            myInit = TRUE;
            }
            boundleft = getProperty ("../boundbox" add colnum, _x);
            boundright = boundleft + getProperty ("../boundbox" add colnum, _width) ;
            boundtop = getProperty ("../boundbox" add colnum, _y);
            boundbottom = boundtop + getProperty ("../boundbox" add colnum,_height);
            if (Number(mouseposX)>=Number(boundleft) and Number(mouseposX)<=Number(boundright) and Number(mouseposY)>=Number(boundtop) and Number(mouseposY)<=Number(boundbottom)) {
            while (Number(i)<=Number(endnum)) {
            myDif = (eval("textY" add i) ) - (mouseposY - boundtop);
            // percentage increase
            scaleAmount = 175-((myDif*myDif)/14);
            alphaAmount = 100-((myDif*myDif)/6);
            if (Number(alphaAmount)<50) {
            alphaAmount = 50;
            }
            if (Number(scaleAmount)<100) {
            scaleAmount = 100;
            }
            setProperty("text" add i, _xscale, scaleAmount);
            setProperty("text" add i, _yscale, scaleAmount);
            setProperty("text" add i, _alpha, alphaAmount);
            i = Number(i)+1;
            }
            // *** add up total Y pixels taken by text ***
            while (Number(m)<=Number(endnum-1)) {
            filledSpace = filledspace + getProperty ( "text" add m, _height);
            m = Number(m)+1;
            }
            // *** find total Y pixels not taken by text
            totalheight = getProperty ( "text" add endnum, _y) - getProperty ( "text" add startnum, _y);
            gapSpace = totalheight-filledspace;
            avgDistance = gapSpace/numberofitems;
            m = Number(startnum)+1;
            while (Number(m)<=Number(endnum-1)) {
            setProperty("text" add m, _y, (getProperty ( "text" add (m-1), _y) + getProperty ( "text" add (m-1), _height)) + avgdistance);
            set("watchheight" add m, getProperty ( "text" add m, _height));
            m = Number(m)+1;
            }
            } else {
            // *** shrink text back when mouse rolls out
            i = startnum;
            while (Number(i)<=Number(endnum)) {
            if (int ( getProperty ("text" add i, _yscale ) ) >= 100) {
            // return scale back to original state
            setProperty("text" add i, _yscale, int ( getProperty ("text" add i, _xscale ) ) - 1);
            setProperty("text" add i, _xscale, int ( getProperty ("text" add i, _yscale ) ) -1);
            }
            if ( getProperty ("text" add i, _y) < eval("textY" add i)) {
            // return y position back to original state
            setProperty("text" add i, _y, int ( getProperty ("text" add i, _y ) ) + 1);
            }
            if ( getProperty ("text" add i, _y) > eval("textY" add i)) {
            setProperty("text" add i, _y, int ( getProperty ("text" add i, _y ) ) - 1);
            }
            if ( getProperty ("text" add i, _Alpha) > 50) {
            setProperty("text" add i, _alpha, int ( getProperty ("text" add i, _alpha ) ) - 1);
            }
            i = Number(i)+1;
            }
            }
            • 3. Re: Converting Actionscript from 1.0 to 2.0
              kglad Adobe Community Professional & MVP
              there are so many problems with that code i doubt i caught them all. but this will get you most of the way towards updating that code:

              • 4. Re: Converting Actionscript from 1.0 to 2.0
                ChuckRWD Level 1
                So, attach this code to frame 1 of the actions layer I will add to the top of the timeline? Also, if I load in this swf into the main swf, is there any way the background can be transparent so all I am loading is the text menu with no background to lay on top of the background in the main swf?

                • 5. Re: Converting Actionscript from 1.0 to 2.0
                  kglad Adobe Community Professional & MVP
                  add that code to the same timeline in which it's currently located. there's no way to determine from that code how to use different paths.

                  the background of a loaded swf is always transparent when loaded into another swf.
                  • 6. Re: Converting Actionscript from 1.0 to 2.0
                    ChuckRWD Level 1
                    Although I don't get any errors now from the Actionscript when I change the publis settings to Flash Player 8, I also don't get the tsunami effect. I copied and pasted it where you said, and have played with it gor quite awile trying to get this guy to work, but no dice. Here is a link to grab the .fla file:

                    http://www.premieretans.com/FLA/tsunami.fla.

                    What is happening with the menu where it won't function in Flash Player 8?