8 Replies Latest reply on Sep 7, 2010 12:01 PM by kglad

    MovieClipLoader issue

    iamhepp

      I am rapidly loosing hair over this one.

       

      I am loading images dynamically in a class that creates a custome menu item that is loaded into a custom menu. It works fine except the very first image never loads

       

          private function loadImage( container:MovieClip, imagePath:String ){
              trace("Loading to container: " + container); ----- Fires for All Images and returns the correct container
              var depth:Number = container.getNextHighestDepth();
             
      var cWidth:Number = container._width;
             
      var cHeight:Numbert = container._height;
              trace("cWidth: " + cWidth); ----- Fires for All Images and returns the correct container width
              trace("cHeight: " + cHeight); ----- Fires for All Images and returns the correct container height
              newImage = container.createEmptyMovieClip("image", depth);
             
              mcLoader.addListener(this);
              //mcLoader.loadClip(imagePath, newImage);
              try{
                  mcLoader.loadClip(imagePath, newImage);
              } catch(e:Error){
                  trace("The Image Failed to LOAD\r\tError: "+ e + "\r\tContainer: " + container + "\r\tPath: " + imagePath);
      ----- Never fires for any of the images
              }
          } // END loadImage()

         
          private function onLoadStart(target_mc:MovieClip) {
              trace( "\t* Loading Started for image: " + target_mc ); ----- Fires for All Images but the very First image
          } // END onLoadStart()

       

      Any ideas would be greatly appreciated...

        • 1. Re: MovieClipLoader issue
          kglad Adobe Community Professional & MVP

          how's loadImage() being called?

          • 2. Re: MovieClipLoader issue
            decpariem Level 1

            loadImage is not a built in function in flash. Use loadMovie or attachMovie instead.

            • 3. Re: MovieClipLoader issue
              kglad Adobe Community Professional & MVP

              i'm sure you mean well but, that wasn't helpful.

              • 4. Re: MovieClipLoader issue
                iamhepp Level 1

                I call it in a switch statement when the MenuImage class is instantiated. Once per each MenuItem being created

                 

                // Is This Item TEXT or ICON or COMBO Item
                            switch( mType ){
                                case 2: //TEXT
                                    mTV = new TextView(mItem, mItem.getNextHighestDepth(), mTitle, mXMargin, mYMargin );
                                    mTV.setSize(22);
                                    //mTV.setSize(18);
                                    mTV.setFont("MyriadPro");
                                    mWidth = mTV.getWidth();
                                    mHeight = mTV.getHeight();
                                   
                                    depth = mItem.getNextHighestDepth();
                                    mRightArrow = mItem.attachMovie("ArrowRight", "menuRightArrow", depth);
                                    mRightArrow._x = mWidth + 10;
                                    mRightArrow._y = mY + (mHeight / 2);
                                    mRightArrow._width = mHeight / 2;
                                    mRightArrow._height = mHeight / 2;
                                    mRightArrow._visible = false;
                                    break;
                                case 3: //ICON
                                    imageContainer = container;
                                    loadImage( imageContainer, imagePath );
                                    break;
                                case 4: //COMBO
                                    //mTV = new TextView(mItem, mItem.getNextHighestDepth(), mTitle, mX + mXMargin, mY + mYMargin );
                                    mTV = new TextView(mItem, mItem.getNextHighestDepth(), mTitle, mXMargin, mYMargin );
                                    mTV.setSize(22);
                                    //mTV.setSize(18);
                                    mTV.setFont("MyriadPro");
                                    mWidth = mTV.getWidth();
                                    mHeight = mTV.getHeight();
                                   
                                    break;
                                default:
                                    break;
                            }
                        }

                .

                • 5. Re: MovieClipLoader issue
                  iamhepp Level 1

                  During menu creation, I create a container for each menu item, add a label and then create the menu item

                   

                             var offset:Number = 15;
                              // Create A Holder For The Image & Text
                              var imageContainer:MovieClip = mContainer.createEmptyMovieClip("imageContainer" + containerCount, mContainer.getNextHighestDepth());
                              containerCount += 1;
                              trace( imageContainer );
                              trace( containerCount );
                              // Draw Initial imageContainer
                              imageContainer.lineStyle(0.5, 0x000000, 100);
                              imageContainer.beginFill(0xFFFFFF);
                              imageContainer.moveTo(0, 0);
                              imageContainer.lineTo(400, 0);
                              imageContainer.lineTo(400, 90);
                              imageContainer.lineTo(0, 90);
                              imageContainer.lineTo(0, 0);
                              imageContainer.endFill();
                              // Add Title
                              var imageTitle:TextView = new TextView(imageContainer, imageContainer.getNextHighestDepth(), name, 250, 0 );
                              //mTV.setSize(18);
                              imageTitle.setSize(22);
                              imageTitle.setFont("MyriadPro");
                              imageTitle.setColor( 0x000000 );
                              imageContainerArray.push({itemObj:imageContainer, titleObj:imageTitle} );
                              // Set Y position
                              imageContainer._y = lastY + offset;
                              lastY = imageContainer._y + imageContainer._height;
                              trace( "CONTAINER: " + imageContainer + " (MenuView)");
                              trace( "WHAT'S THE Y: " + imageContainer._y  + " (MenuView)");
                              trace( "IS IT VISIBLE: " + imageContainer._visible  + " (MenuView)");
                              // Add New Menu Item
                              menuItem = new MenuItemView(mStage, mStage.getNextHighestDepth(), name, xPos, yPos, null, MenuConsts.MENU_VERTICAL, itemType, imagePath, imageContainer);
                              menuItem.addEventListener( "loadComplete", Delegate.create(this, loadComplete) );           

                  • 6. Re: MovieClipLoader issue
                    kglad Adobe Community Professional & MVP

                    your trace statements show your first image loads?

                     

                    if yes, make sure you're not re-using the target depth and check the target's _x,_y,_alpha,_visible to make sure it's visible on-stage and nothing with higher depth is covering it.

                    • 7. Re: MovieClipLoader issue
                      iamhepp Level 1

                      that was it.... they were overwriting the first instance by hardcoding a depth... thanks, I couldn't for the life of me see it, but thanks to your help I found it.

                      • 8. Re: MovieClipLoader issue
                        kglad Adobe Community Professional & MVP

                        you're welcome.