Skip to main content
barpos
Known Participant
March 13, 2011
Answered

Crazy non-sense Actionscript compiler error

  • March 13, 2011
  • 1 reply
  • 1513 views

    trace("scaleH: " + scaleH + "\n");        yields .89132002
    trace("browserH: " + browserH + "\n");   yields 962
   
    RollingTractor(scaleH, browserH);      yields Intro, Layer 'Actions', Frame 1, Line 112  1137: Incorrect number of arguments.  Expected no more than 1.

The RollingTractor function resides in a custom class of the same name:

package
{
    import fl.motion.AnimatorFactory;
    import fl.motion.MotionBase;
    import fl.motion.Motion;
    import flash.filters.*;
    import flash.geom.Point;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.display.*;
    import flash.events.*;
    import flash.sensors.Accelerometer;

    public class RollingTractor
    {
        var _scaleH:Array = new Array(1);
        var tractorBodyObj:DisplayObject;
        var frontWheelObj:DisplayObject;
        var backWheelObj:DisplayObject;

        public function RollingTractor(scaleH:Number, browserH:uint)
        {

Any ideas?

Ron

This topic has been closed for replies.
Correct answer kglad

Ok, I'm posting the entire code:

RollingTractor(1, 962);    // found on Frame 1 in Flash main timeline


Code from RollingTractor.as file:

package
{
    import fl.motion.AnimatorFactory;
    import fl.motion.MotionBase;
    import fl.motion.Motion;
    import flash.filters.*;
    import flash.geom.Point;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.display.*;
    import flash.events.*;
    import flash.sensors.Accelerometer;

    public class RollingTractor
    {
        var _scalePH:Array = new Array(1);
        var tractorBodyObj:DisplayObject;
        var frontWheelObj:DisplayObject;
        var backWheelObj:DisplayObject;

        public function RollingTractor(scalePH:Number, browserPH:uint)
        {
            // convert parameter values into array values
            _scalePH[0] = scalePH;

            // create a display object container
            var tractorContainer:Sprite = new Sprite();

            // load one of three bitmap images
            var tractorBodyLoader:Loader = new Loader();
            tractorBodyLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, bodyLoadComplete);
            tractorBodyLoader.load(new URLRequest("WheelFreeTractor.png"));

            function bodyLoadComplete(event:Event):void
            {
                // calculate the object height to display at bottom of browser
                var _tractorBodyY:Array = new Array(1);
                _tractorBodyY[0] = browserPH - (tractorBodyLoader.height / 2);

                // load one of three bitmap images
                var backWheelLoader:Loader = new Loader();
                backWheelLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, backWheelLoadComplete);
                backWheelLoader.load(new URLRequest("BackWheel.png"));

                function backWheelLoadComplete(event:Event):void
                {
                    var frontWheelLoader:Loader = new Loader();
                    frontWheelLoader.load(new URLRequest("FrontWheel.png"));
                    frontWheelLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, frontWheelLoadComplete);

                    function frontWheelLoadComplete(event:Event):void
                    {
                        // initialize the display object instances
                        tractorBodyObj = tractorBodyLoader.content;
                        frontWheelObj = frontWheelLoader.content;
                        backWheelObj = backWheelLoader.content;

                        // store the loaded iamges into a group container
                        tractorContainer.addChild(tractorBodyObj);
                        tractorContainer.addChild(frontWheelObj);
                        tractorContainer.addChild(backWheelObj);

                        // adjust the image Y values to bring the
                        // rolling tractor at the bottom of the screen
                        frontWheelObj.y = browserPH - ((frontWheelObj.height * scalePH) / 2);
                        backWheelObj.y *=  backWheelObj.y / frontWheelObj.y;
                        tractorBodyObj.y *=  tractorBodyObj.y / frontWheelObj.y;


                        // initialize the motion tweens
                        // (COPY MOTION AS ACTIONSCRIPT 3.0)
                        tractorBody();
                        backWheel();
                        frontWheel();

                        // start the tween animations through Flash motion tween instances
                        /*TractorBody.addTarget(tractorBodyObj, 0);
                        BackWheel.addTarget(backWheelObj, 0);
                        FrontWheel.addTarget(frontWheelObj, 0);*/

                        // get rid of the loaders (NOT SURE IT IS NEEDE3D)
                        tractorBodyLoader = undefined;
                        frontWheelLoader = undefined;
                        backWheelLoader = undefined;
                    }
                }
            }
        }

        private function tractorBody()
        {
            var __motion_TractorBody:MotionBase;
            if (__motion_TractorBody == null)
            {
                __motion_TractorBody = new Motion();
                __motion_TractorBody.duration = 165;

                // Call overrideTargetTransform to prevent the scale, skew,
                // or rotation values from being made relative to the target
                // object's original transform.
                // __motion_TractorBody.overrideTargetTransform();

                // The following calls to addPropertyArray assign data values
                // for each tweened property. There is one value in the Array
                // for every frame in the tween, or fewer if the last value
                // remains the same for the rest of the frames.
                __motion_TractorBody.addPropertyArray("x", [0,44.1972,87.3677,129.545,170.728,210.934,250.164,288.449,325.791,362.205,397.41,432.284,465.983,498.804,530.747,561.846,592.1,621.526,650.141,677.944,704.969,731.199,756.668,781.391,805.369,828.618,851.139,872.981,894.21,914.578,934.367,953.51,972.007,989.874,1007.13,1023.79,1039.85,1055.33,1070.25,1084.63,1098.45,1111.75,1124.54,1136.82,1148.61,1159.92,1170.79,1181.19,1191.14,1200.68,1209.78,1218.51,1226.82,1234.77,1242.36,1249.59,1256.5,1263.06,1269.32,1275.08,1280.92,1286.32,1291.62,1296.31,1300.94,1305.35,1309.55,1313.55,1317.35,1320.98,1324.44,1327.75,1330.93,1333.98,1336.93,1339.76,1342.51,1345.19,1347.79,1350.36,1352.87,1355.37,1357.88,1360.36,1362.86,1365.38,1367.94,1370.54,1373.23,1375.97,1378.81,1381.75,1384.8,1387.98,1391.29,1394.75,1398.38,1402.19,1406.18,1410.39,1414.79,1419.43,1424.11,1429.41,1434.81,1440.67,1446.42,1452.68,1459.24,1466.14,1473.38,1480.96,1488.91,1497.22,1505.95,1515.06,1524.6,1534.55,1544.95,1555.81,1567.12,1578.91,1591.2,1603.98,1617.28,1631.11,1645.48,1660.4,1675.88,1691.95,1708.6,1725.86,1743.73,1762.22,1781.37,1801.15,1821.54,1842.75,1864.59,1887.12,1910.36,1934.34,1959.07,1984.53,2010.76,2037.79,2065.59,2094.21,2123.63,2153.89,2184.99,2216.93,2249.75,2283.45,2318.04,2353.53,2389.94,2427.28,2465.57,2504.8,2545.01,2586.19,2628.37,2671.54,2715.75]);
                __motion_TractorBody.addPropertyArray("y", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
                __motion_TractorBody.addPropertyArray("scaleX", [.9]);
                __motion_TractorBody.addPropertyArray("scaleY", _scalePH);
                __motion_TractorBody.addPropertyArray("skewX", [0]);
                __motion_TractorBody.addPropertyArray("skewY", [0]);
                __motion_TractorBody.addPropertyArray("rotationConcat", [0]);
                __motion_TractorBody.addPropertyArray("cacheAsBitmap", [false]);

                // Create an AnimatorFactory instance, which will manage;
                // targets for its corresponding Motion.
                var TractorBody:AnimatorFactory = new AnimatorFactory(__motion_TractorBody);
                TractorBody.transformationPoint = new Point(0.500000,0.500253);

                // Call the addTarget function on the AnimatorFactory
                // instance to target a DisplayObject with this Motion.
                // The second parameter is the number of times the animation
                // will play - the default value of 0 means it will loop.
                // TractorBody.addTarget(<instance name goes here>, 0);
                TractorBody.addTarget(tractorBodyObj, 0);
            }
        }

        private function backWheel()
        {
            var __motion_BackWheel:MotionBase;
            if (__motion_BackWheel == null)
            {
                __motion_BackWheel = new Motion();
                __motion_BackWheel.duration = 165;

                // Call overrideTargetTransform to prevent the scale, skew,
                // or rotation values from being made relative to the target
                // object's original transform.
                // __motion_BackWheel.overrideTargetTransform();

                // The following calls to addPropertyArray assign data values
                // for each tweened property. There is one value in the Array
                // for every frame in the tween, or fewer if the last value
                // remains the same for the rest of the frames.
                __motion_BackWheel.addPropertyArray("x", [0,44.2851,87.5414,129.802,171.067,211.354,250.661,289.023,326.438,362.925,398.2,433.144,466.91,499.796,531.802,562.963,593.277,622.762,651.433,679.292,706.371,732.653,758.172,782.945,806.97,830.266,852.832,874.717,895.988,916.397,936.225,955.406,973.939,991.843,1009.13,1025.82,1041.92,1057.43,1072.38,1086.78,1100.64,1113.96,1126.77,1139.08,1150.9,1162.23,1173.11,1183.53,1193.51,1203.06,1212.19,1220.93,1229.26,1237.23,1244.83,1252.08,1259,1265.57,1271.84,1277.61,1283.47,1288.88,1294.19,1298.88,1303.53,1307.94,1312.16,1316.16,1319.97,1323.61,1327.07,1330.39,1333.58,1336.63,1339.59,1342.42,1345.18,1347.87,1350.47,1353.04,1355.56,1358.07,1360.58,1363.06,1365.57,1368.09,1370.66,1373.27,1375.96,1378.71,1381.55,1384.5,1387.55,1390.74,1394.06,1397.53,1401.16,1404.98,1408.97,1413.19,1417.6,1422.25,1426.94,1432.25,1437.66,1443.54,1449.29,1455.57,1462.14,1469.06,1476.31,1483.91,1491.87,1500.2,1508.94,1518.07,1527.63,1537.6,1548.02,1558.9,1570.24,1582.05,1594.36,1607.17,1620.49,1634.35,1648.75,1663.7,1679.22,1695.31,1712,1729.29,1747.19,1765.73,1784.91,1804.74,1825.16,1846.42,1868.3,1890.87,1914.16,1938.19,1962.96,1988.48,2014.76,2041.84,2069.7,2098.37,2127.86,2158.17,2189.33,2221.34,2254.22,2287.99,2322.65,2358.21,2394.69,2432.11,2470.47,2509.78,2550.07,2591.33,2633.59,2676.85,2721.15]);
                __motion_BackWheel.addPropertyArray("y", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
                __motion_BackWheel.addPropertyArray("scaleX", _scalePH);
                __motion_BackWheel.addPropertyArray("scaleY", _scalePH);
                __motion_BackWheel.addPropertyArray("skewX", [0]);
                __motion_BackWheel.addPropertyArray("skewY", [0]);
                __motion_BackWheel.addPropertyArray("rotationConcat", [0,11.7176,23.1629,34.3449,45.2634,55.9229,66.3234,76.4737,86.3737,96.0278,105.436,114.607,123.541,132.243,140.712,148.957,156.978,164.779,172.365,179.737,186.901,193.856,200.608,207.162,213.52,219.683,225.654,231.445,237.047,242.473,247.72,252.795,257.699,262.436,267.01,271.427,275.685,279.79,283.746,287.557,291.222,294.748,298.137,301.395,304.52,307.519,310.399,313.156,315.795,318.323,320.738,323.052,325.256,327.363,329.374,331.292,333.123,334.861,336.521,338.097,339.599,341.03,342.386,343.677,344.906,346.074,347.189,348.247,349.257,350.219,351.136,352.014,352.857,353.665,354.446,355.197,355.926,356.637,357.326,358.007,358.674,359.337,360,360.659,361.321,361.989,362.669,363.359,364.07,364.799,365.549,366.331,367.139,367.981,368.86,369.777,370.739,371.748,372.806,373.921,375.089,376.319,377.609,378.966,380.397,381.899,383.475,385.134,386.873,388.703,390.622,392.633,394.74,396.944,399.258,401.672,404.201,406.84,409.597,412.477,415.475,418.601,421.859,425.248,428.773,432.439,436.25,440.205,444.31,448.569,452.985,457.56,462.297,467.201,472.276,477.522,482.949,488.551,494.341,500.312,506.476,512.833,519.388,526.14,533.094,540.259,547.63,555.217,563.018,571.039,579.284,587.753,596.454,605.388,614.56,623.968,633.622,643.522,653.672,664.073,674.732,685.651,696.833,708.278,720]);
                __motion_BackWheel.addPropertyArray("cacheAsBitmap", [false]);

                // Create an AnimatorFactory instance, which will manage;
                // targets for its corresponding Motion.
                var BackWheel:AnimatorFactory = new AnimatorFactory(__motion_BackWheel);
                BackWheel.transformationPoint = new Point(0.500000,0.500000);

                // Call the addTarget function on the AnimatorFactory
                // instance to target a DisplayObject with this Motion.
                // The second parameter is the number of times the animation
                // will play - the default value of 0 means it will loop.
                /// BackWheel.addTarget(<instance name goes here>, 0);
                BackWheel.addTarget(backWheelObj, 0);
            }
        }

        private function frontWheel()
        {
            var __motion_FrontWheel:MotionBase;
            if (__motion_FrontWheel == null)
            {
                __motion_FrontWheel = new Motion();
                __motion_FrontWheel.duration = 165;

                // Call overrideTargetTransform to prevent the scale, skew,
                // or rotation values from being made relative to the target
                // object's original transform.
                // __motion_FrontWheel.overrideTargetTransform();

                // The following calls to addPropertyArray assign data values
                // for each tweened property. There is one value in the Array
                // for every frame in the tween, or fewer if the last value
                // remains the same for the rest of the frames.
                __motion_FrontWheel.addPropertyArray("x", [0,44.1972,87.3677,129.545,170.728,210.934,250.164,288.449,325.791,362.205,397.41,432.284,465.983,498.804,530.747,561.846,592.1,621.526,650.141,677.944,704.969,731.199,756.668,781.391,805.369,828.618,851.139,872.981,894.21,914.578,934.367,953.51,972.007,989.874,1007.13,1023.79,1039.85,1055.33,1070.25,1084.63,1098.45,1111.75,1124.54,1136.82,1148.61,1159.92,1170.79,1181.19,1191.14,1200.68,1209.78,1218.51,1226.82,1234.77,1242.36,1249.59,1256.5,1263.06,1269.32,1275.08,1280.92,1286.32,1291.62,1296.31,1300.94,1305.35,1309.55,1313.55,1317.35,1320.98,1324.44,1327.75,1330.93,1333.98,1336.93,1339.76,1342.51,1345.19,1347.79,1350.36,1352.87,1355.37,1357.88,1360.36,1362.86,1365.38,1367.94,1370.54,1373.23,1375.97,1378.81,1381.75,1384.8,1387.98,1391.29,1394.75,1398.38,1402.19,1406.18,1410.39,1414.79,1419.43,1424.11,1429.41,1434.81,1440.67,1446.42,1452.68,1459.24,1466.14,1473.38,1480.96,1488.91,1497.22,1505.95,1515.06,1524.6,1534.55,1544.95,1555.81,1567.12,1578.91,1591.2,1603.98,1617.28,1631.11,1645.48,1660.4,1675.88,1691.95,1708.6,1725.86,1743.73,1762.22,1781.37,1801.15,1821.54,1842.75,1864.59,1887.12,1910.36,1934.34,1959.07,1984.53,2010.76,2037.79,2065.59,2094.21,2123.63,2153.89,2184.99,2216.93,2249.75,2283.45,2318.04,2353.53,2389.94,2427.28,2465.57,2504.8,2545.01,2586.19,2628.37,2671.54,2715.75]);
                __motion_FrontWheel.addPropertyArray("y", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
                __motion_FrontWheel.addPropertyArray("scaleX", _scalePH);
                __motion_FrontWheel.addPropertyArray("scaleY", _scalePH);
                __motion_FrontWheel.addPropertyArray("skewX", [0]);
                __motion_FrontWheel.addPropertyArray("skewY", [0]);
                __motion_FrontWheel.addPropertyArray("rotationConcat", [0,14.647,28.9537,42.9311,56.5793,69.9037,82.9043,95.5921,107.967,120.035,131.795,143.259,154.427,165.304,175.89,186.196,196.222,205.974,215.457,224.671,233.627,242.32,250.76,258.953,266.899,274.604,282.068,289.306,296.309,303.091,309.649,315.993,322.123,328.045,333.763,339.284,344.607,349.738,354.682,359.446,364.028,368.435,372.671,376.743,380.651,384.399,387.999,391.445,394.743,397.904,400.923,403.815,406.57,409.204,411.717,414.115,416.404,418.577,420.651,422.621,424.498,426.287,427.983,429.596,431.133,432.593,433.987,435.309,436.571,437.773,438.92,440.018,441.071,442.081,443.058,443.996,444.907,445.796,446.658,447.509,448.343,449.171,450,450.823,451.652,452.486,453.337,454.198,455.087,455.998,456.937,457.913,458.923,459.977,461.074,462.221,463.423,464.685,466.008,467.402,468.862,470.398,472.012,473.707,475.496,477.373,479.343,481.418,483.591,485.879,488.277,490.791,493.425,496.18,499.072,502.09,505.251,508.549,511.996,515.596,519.344,523.251,527.323,531.56,535.966,540.549,545.312,550.257,555.388,560.711,566.232,571.95,577.871,584.001,590.345,596.903,603.686,610.688,617.927,625.39,633.095,641.041,649.235,657.675,666.368,675.324,684.538,694.021,703.773,713.799,724.105,734.691,745.568,756.735,768.199,779.96,792.027,804.402,817.09,830.091,843.415,857.063,871.041,885.348,900]);
                __motion_FrontWheel.addPropertyArray("cacheAsBitmap", [false]);

                // Create an AnimatorFactory instance, which will manage;
                // targets for its corresponding Motion.
                var FrontWheel:AnimatorFactory = new AnimatorFactory(__motion_FrontWheel);
                FrontWheel.transformationPoint = new Point(0.500000,0.500000);

                // Call the addTarget function on the AnimatorFactory
                // instance to target a DisplayObject with this Motion.
                // The second parameter is the number of times the animation
                // will play - the default value of 0 means it will loop.
                /// FrontWheel.addTarget(<instance name goes here>, 0);
                FrontWheel.addTarget(frontWheelObj, 0);
            }
        }
    }
}


to instantiate an RT class instance, you should be using something like:

var asdf:RollingTractor=new RollingTractor(1,962);

1 reply

kglad
Community Expert
Community Expert
March 13, 2011

you have a scope issue.

save your files to a new directory to ensure there's no extraneous/old RollingTractor class.

barpos
barposAuthor
Known Participant
March 13, 2011

Ok, I just tried your suggestion, but with no better result.

I'm wondering about the variable declarations at the top of my code within the class body.  Is that conform to the AS3 language to be up there?

Also, should the .AS file be closed before running the code?

Could it be that the arguments passed have the same names as the class's function parameter names?

Ron

kglad
Community Expert
Community Expert
March 13, 2011

I'm wondering about the variable declarations at the top of my code within the class body.  Is that conform to the AS3 language to be up there?

yes.  make sure you're passing the correct data types.

Also, should the .AS file be closed before running the code?

yes, or you'll be executing the code of the previously save class file

Could it be that the arguments passed have the same names as the class's function parameter names?

argument names and class property names can be the same.