Quantcast
Channel: Adobe Community : All Content - Adobe Animate CC - General
Viewing all articles
Browse latest Browse all 13519

Putting Arrays to work: error 1065

$
0
0

Hi all,

 

I have created this array which works well:

 

function initLetters():void

        {                               

            for (var i:Number =0; i < lettersL1.length; i++)

            {

                trace (lettersL1[i]); // traces perfectly

 

             }

 

My next question: I want to do a lot of stuff with the objects in this array, (like suffle, appear at a certain x,y coordinate, change alpha, move along a path etc. All of wich I need to learn yet LOL)

                             Someone suggested that I add the following code to create a var to do this. When I add this I get the error code below. Is this the righ way to go for what I want?  Maybe it is in the wrong spot again?

 

   /*var C:Class=Class(getDefinitionByName(lettersL1[i]));

            var c:*=new C(); // create instances from the classes in lettersL1

                                        // do whatever with c*/

 

When I uncomment the above I suddenly get this error code:

 

ReferenceError: Error #1065: Variable [object A] is not defined.

    at global/flash.utils::getDefinitionByName()

    at LetterArray/initLetters()

    at LetterArray()

    at BugGoopFSGame()

 

My .as class code:

 

package

{

    import flash.display.*;

    import flash.events.*;

    import flash.text.*;

    import flash.utils.Timer;

    import flash.utils.getDefinitionByName;

    import flash.media.Sound;

    import flash.media.SoundChannel;

    import flash.net.URLRequest;

 

 

    public class LetterArray extends MovieClip

    {

        private var _stage:Stage;

 

        //Movie clips to be used

        public var a:A = new A();//etc

 

        private var  lettersL1:Array = [a,f,g,h,i,n,o,s,t];

 

        //Text Fields and Format

                                                            //works well

                                                      //Sound Specs

                                                            //works well

 

        //***CONSTRUCTOR FUNCTION***

 

 

        public function LetterArray(s:Stage)

 

        {

            _stage = stage;

 

            trace("Main construtor is working");

 

            //GameLoop

            initText();

            initLetters();

            initLetterWasClickedOn();

            initCheckIfLetterIsCorrect();

            initInGameAnimation();

            initRemoveLetterChildren();

            initPointsGiven();

        }

 

    //OTHER FUNCTIONS

 

        function initText():void

                {                               

                    // text formatting: general

                 }

 

        function initLetters():void

        {                               

            for (var i:Number =0; i < lettersL1.length; i++)

            {

                trace (lettersL1[i]); //trace works well

 

            var C:Class=Class(getDefinitionByName(lettersL1[i]));

            var c:*=new C(); // create instances from the classes in lettersL1

                                        // do whatever with c

            }


Viewing all articles
Browse latest Browse all 13519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>