SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    actionscript files aren't loading when linked to external swf

    Hey, I've been looking around and I can't fix this problem. well 2 problems.

    1. I have two .swf files, individually they work perfect. but I have it so my main page trys tries connect to my contact.swf. When I click the button for my contact.swf this appears:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at Drawing/::init()
    at Drawing$iinit()

    The contact.swf has a Drawing.as file attached to it. here is the code
    Code:
    package
    {
    	import flash.display.Sprite;
    	import flash.display.Bitmap;
    	import flash.display.BitmapData;
    	import flash.events.MouseEvent;
    	import flash.events.Event;
    	import flash.filters.BlurFilter;
    	
    	public class Drawing extends Sprite
    	{
    		private var canvas:BitmapData;
    		private var color:uint;
    		private var size:Number = 20;
    		private var density:Number = 500;
    		
    		public function Drawing()
    		{
    			init();
    		}
    		
    		private function init():void
    		{
    			canvas = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x00000000);
    			var bmp:Bitmap = new Bitmap(canvas);
    			bmp.filters = [new BlurFilter(2, 2, 3)];
    			addChild(bmp);
    			stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
    			stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp);
    		}
    		
    		public function mouseDown(event:MouseEvent):void
    		{
    			color = Math.random() * 0xffffff + 0xff000000;
    			addEventListener(Event.ENTER_FRAME, onEnterFrame);
    		}
    
    		private function mouseUp(event:MouseEvent):void
    		{
    			removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    		}
    
    		private function onEnterFrame(event:Event):void
    		{
    			for(var i:int = 0; i < density; i++)
    			{
    	math stuff
    			}
    		}
    	}
    }
    the class is a documented class. here is how I call contact.swf from my mainPage.swf

    Code:
    contact.addEventListener(MouseEvent.ROLL_OVER, overContact);
    contact.addEventListener(MouseEvent.ROLL_OUT, outContact);
    contact.addEventListener(MouseEvent.MOUSE_DOWN, downContact);
    
    function downContact(MouseEvent):void{
    	var request:Loader = new Loader();
    request.load(new URLRequest ("Contact.swf"));
    loadMC.addChild(request)
    }
    
    function overContact(MouseEvent):void{
    	contact.gotoAndPlay(2);
    }
    function outContact(MouseEvent):void{
    	contact.gotoAndStop(1);
    }
    my other question is about in dreamweaver, nothing seems to work, even connecting to .swf that have no actionscript classes. the mainPage.swf only remains on the same page.

  2. #2
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ei: MainSite can open Portfolio(because it doesnt have a .AS class) Mainsite can't open contact which has a .as class called drawing.as

    any ideas?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •