6 Replies Latest reply: Sep 9, 2009 4:34 AM by SlickRik RSS

    Strange display glitch

    SlickRik Community Member

      (AS3, Win XP, CS4, publihsh in FlashPlayer 9, viewed in FlashPlayer10)

       

      I've encounntered a strange 'glitch' in CS4

       

      I'm using a lot (20+) simple lineTo commands to create the links in a menu tree structure.

      The targets or the tree structure move so hence the lineTo end point moves so hence needs to be redrawn - this is happening on EnterFrame.

       

      The problem is that quite often (predictably often) once the 3rd level is drawn there are grey boxes (the colour of the line) flashing on and off the screen, sort of paying attention to the lines being drawn but in places not bounded by them.

       

      These lineTo's are ALL single lines with just 2 vertex's and a single straght line between them, so no shape to fill etc.

       

      Does that makes sense to anyone.

       

      Ask away and i'll try to clarify any points, needless to say it's driving me nuts

       

      regards, Rich

        • 1. Re: Strange display glitch
          Andrei1 Community Member

          Posting code would be helpful.

          • 2. Re: Strange display glitch
            SlickRik Community Member

            code that draw's the lines:

             

            public function drawLineToSubs():void

             

                        menuHolder.graphics.clear();
                       
                        for each (var obj:MenuItem in menuItemArray) {
                            var tX:Number = obj.x;
                            var tY:Number = obj.y;
                           
                            menuHolder.graphics.lineStyle(1, 0xffffff, 0.05);
                            menuHolder.graphics.moveTo(item.x, item.y);
                            menuHolder.graphics.lineTo(tX, tY);
                        }
            }

             

            -------------

            where menuHolder is a Sprite()

            where type MenuItem is a class that extends MovieClip and contains the subnodes for that level, each subNode object within menuHolder would contain another menuHolder and run the above class locally if has childNodes.

            i never get multiple lines on the screen (other that those i desire) so graphics.clear() is def working

             

            regards, Rich

            • 3. Re: Strange display glitch
              Andrei1 Community Member

              What do you refer to when you say "above class"? Is function drawLineToSubs a method of an instance or it is on timeline?

               

              What is the item.x/item.y in the code?

               

              Are you saying that an object is moving on a timeline and you are connecting children with these lines. Or children are moving inside their parents too?

              • 4. Re: Strange display glitch
                SlickRik Community Member

                sorry, yeah, taht would help.

                 

                 

                class View - is the root.

                 

                class MenuItem is instantiated into View.

                 

                class MenuItem contains an empty Sprite() called menuHolder.

                 

                class MenuHolder instaitiates all it's subNodes inside it's menuHolder

                 

                 

                Each subnode which gets instantiated is another instance of MenuItem

                 

                drawLineToSubs() is a public method of the class MenuItem

                 

                 

                I know it's likely odd/bad practice to instantiate a class within itself but the nature of the project demanded it unfortunately.

                 

                the tree continues down another 2 levels

                 

                View => MenuItem - menuHolder ==> MenuItem - menuHolder ==> MenuItem

                                                                                                           ==> MenuItem

                                                                                                           ==> MenuItem

                                                                 ==> MenuItem - menuHolder ==> MenuItem

                                                                                                           ==> MenuItem

                                                                                                           ==> MenuItem

                 

                does that make sense?

                 

                R

                • 5. Re: Strange display glitch
                  Andrei1 Community Member

                  It does make sense.

                   

                  And why is it a bad practice to instantiate class inside itself? We do it all the time with Sprites and MovieClips.

                   

                  I still cannot picture though why you say that line drawing happens on enter frame? It would make sense if the objects are moving, otherwise, why bother?

                  • 6. Re: Strange display glitch
                    SlickRik Community Member

                    HI Andrei,

                     

                    yes - the objects are in motion, each node in the tree moves in response to the mouse proximity and few other factors.