1 Reply Latest reply on Feb 13, 2009 1:50 AM by Cesare Rocchi

    Beginner help needed

    dunc1215
      I have been using a lynda.com tutorial to learn ActionScript. I have written some simple code to display a thumbnail and, on mouseover and enlarge it. The Thumbnail.as code is as follows:

      package com.lynda.as3et.photoviewer.ui
      {
      import flash.display.Sprite;
      import flash.display.Loader;
      import flash.net.URLRequest;
      import flash.events.MouseEvent;
      import flash.events.Event;
      import flash.filters.DropShadowFilter;

      public class Thumbnail extends Sprite {

      private var _loader:Loader;
      private var _width:Number;
      private var _height:Number;
      private var _mainAssetUrl:String;

      public function Thumbnail(url:String, mainUrl:String, defaultWidth:Number, defaultHeight:Number);
      {
      _width = defaultWidth;
      _height = defaultHeight;
      _mainAssetUrl = mainUrl;
      _loader = new Loader();
      var request:URLRequest = new URLRequest(url);
      _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, goToDefaultState);
      _loader.load(request);
      addChild(_loader);
      _loader.addEventListener(MouseEvent.MOUSE_OVER, goToMouseOverState);
      _loader.addEventListener(MouseEvent.MOUSE_OUT, goToDefaultState);
      }

      private function goToDefaultState(event:Event):void
      {
      _loader.scaleX = .9;
      _loader.scaleY = .9;
      _loader.filters = [new DropShadowFilter()];
      }

      private function goToMouseOverState(event:Event):void
      {
      _loader.scaleX = 1;
      _loader.scaleY = 1;
      _loader.filters = [new DropShadowFilter(10,45,0x222222,1,10,10)]
      }

      }
      }

      The PhotoViewer.as code is as follows:

      package {

      import flash.display.Sprite;
      import com.lynda.as3et.photoviewer.ui.Thumbnail;

      public class PhotoViewer extends Sprite
      {
      public function PhotoViewer()
      {
      var thumbnail:Thumbnail = new Thumbnail("Images/CronoCrossThumbnail.jpg", "Images/CronoCross.jpg", 90, 90);
      addChild(thumbnail);
      }
      }
      }

      The error codes I am getting are as follows:

      Severity and Description Path Resource Location Creation Time Id
      1120: Access of undefined property _loader. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 26 1234493943147 293

      1180: Call to a possibly undefined method addChild. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 26 1234493943147 292

      1120: Access of undefined property _loader. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 25 1234493943147 290

      1120: Access of undefined property request. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 25 1234493943147 291

      1120: Access of undefined property _loader. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 24 1234493943146 288

      1120: Access of undefined property goToDefaultState. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 24 1234493943146 289

      1120: Access of undefined property url. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 23 1234493943149 298

      1120: Access of undefined property url. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 23 1234493943149 299

      1120: Access of undefined property _loader. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 22 1234493943146 287

      1120: Access of undefined property _mainAssetUrl. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 21 1234493943144 285

      1120: Access of undefined property mainUrl. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 21 1234493943145 286

      1120: Access of undefined property _height. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 20 1234493943144 283

      1120: Access of undefined property defaultHeight. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 20 1234493943144 284

      1120: Access of undefined property _width. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 19 1234493943143 281

      1120: Access of undefined property defaultWidth. PhotoViewer/com/lynda/as3et/photoviewer/ui Thumbnail.as line 19 1234493943144 282

      I have absolutely no idea what I am doing wrong. Can someone help?

      Thanks.