5 Replies Latest reply on Dec 26, 2008 10:30 AM by ntsiii

    I need help please

    pr-flex Level 1
      All,

      I am trying to get this code to run and am getting error #1119: Access of possibly undefined property height through a reference with static type Class. My code is below, any input would be great.
        • 1. Re: I need help please
          ntsiii Level 3
          First, please use descriptive subjects for all posts. Many contributors will ignore "Help Me" posts.

          Next, which line is throwing the error?

          Tracy
          • 2. Re: I need help please
            pr-flex Level 1
            Tracy,

            Thanks for the info! The code that is throwing the is

            var cv:Canvas = new Canvas();
            cv.width = canvasWidth; <------------- I get the error here
            cv.height = canvasHeight;
            • 3. Re: I need help please
              ntsiii Level 3
              Ok, in your original post you show:
              cv.width = Canvas.width;
              This will cause the error because you are trying to get "width" from "Canvas". "Canvas" is a data type (Class), and you cannot access properties of a class, only of an *instance* of that class.

              Where are you wanting to get the value for the width and height from?

              Change the line to:
              cv.width = 200;
              The error will go away.

              Tracy
              • 4. Re: I need help please
                pr-flex Level 1
                here is the code that i started with, I am trying to get the canvas width from the image rss feed from photobucket.

                <!--[CDATA[
                public function addURL(url:String) : void {
                <!--
                Creates a canvas to display the image on
                and adds the canvas with the image as a
                Child of the coverflow component
                -->
                var cv:Canvas = new Canvas();
                cv.width = canvasWidth;
                cv.height = canvasHeight;
                cv.verticalScrollPolicy="off";
                cv.horizontalScrollPolicy="off";
                var thisImage:Image = new Image();
                thisImage.setStyle("verticalCenter","0");
                thisImage.setStyle("horizontalCenter","0");
                thisImage.addEventListener(Event.COMPLETE, imageLoaded);
                thisImage.load(url);
                cv.addChild(thisImage);
                coverflow.addChild(cv);
                numChildrenAdded++;
                scrollbar.setScrollProperties(1,0,numChildrenAdded-1,1);
                scrollbar.scrollPosition=coverflow.selectedIndex = Math.round(scrollbar.scrollPosition);
                coverflow.selectedIndex = numChildrenAdded-1;
                }

                private function imageLoaded(event:Event):void{
                <!--
                Image Loader function to center the image
                after it has been loaded
                -->
                var thisImage:Image = event.target as Image;
                if(thisImage.contentWidth>(canvasWidth-20) || thisImage.contentHeight>(canvasHeight-10)){
                var scaleAmt:Number = 1.0;
                if(pbImg.contentWidth>pbImg.contentHeight){
                scaleAmt = canvasWidth /(pbImg.contentWidth-10);
                }else{
                scaleAmt = canvasHeight /(pbImg.contentHeight-10);
                }
                pbImg.scaleX = scaleAmt;
                pbImg.scaleY = scaleAmt;
                }
                }
                ]]-->
                • 5. Re: I need help please
                  ntsiii Level 3
                  Where is "canvasWidth" getting set? Have you determined that it has a value?

                  And that code is not giving the reference error you posted originally, is it?

                  Tracy