Okay, so I'm making this game and and it has 3 separate parts:
1. The preloader for the menu
2. The menu
3. The actual game
The menu is supposed to preload the game. It works fine except when it's finished, it returns this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at song1_fla::MainTimeline/frame1()
an then the game wont work properly ( there are images that are should turn around and move randomly using Tweener but they don't. They also should leave a fading trail behind them.
Here is the AS3 code for the menu ( I only have one button as of now)
Frame 1:
Frame 2:
Now the game:
1. The preloader for the menu
2. The menu
3. The actual game
The menu is supposed to preload the game. It works fine except when it's finished, it returns this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at song1_fla::MainTimeline/frame1()
an then the game wont work properly ( there are images that are should turn around and move randomly using Tweener but they don't. They also should leave a fading trail behind them.
Here is the AS3 code for the menu ( I only have one button as of now)
Frame 1:
Code:
stop(); // make sure you have these imported. import flash.media.Sound; import flash.media.SoundChannel; // create your variables for your sound instance and one for a sound channel var Bgm:SSBBT = new SSBBT; var sndChannel:SoundChannel = Bgm.play(); // then to stop your sound all you have to do is this. //sndChannel.stop(); Song_text.text == "Choose your song" //Add Event Handler and add function to it. Song1.addEventListener( MouseEvent.CLICK, Song1_evt); function Song1_evt(evt:MouseEvent):void { sndChannel.stop(); play(); }
Code:
import flash.media.Sound; import flash.media.SoundChannel; stop(); var l:Loader = new Loader(); l.contentLoaderInfo.addEventListener(P... l.contentLoaderInfo.addEventListener(E... done); l.load(new URLRequest("song1.swf")); function loop(e:ProgressEvent):void { var perc:Number = e.bytesLoaded / e.bytesTotal; percent.text = Math.ceil(perc*100).toString(); } function done(e:Event):void { removeChildAt(0); percent = null; addChild(l); }
Code:
stop(); import caurina.transitions.*; import flash.media.Sound; import flash.media.SoundChannel; var bmd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x000000); var bm:Bitmap = new Bitmap(bmd); addChild(bm); var bf:BlurFilter = new BlurFilter(0, 0, 3); //R,G,B,A,? var cmf:ColorMatrixFilter = new ColorMatrixFilter([ 1,0,0,0,0, 0,1,0,0,0, 0,0,2,0,0, 0,0,0,0.3,0]); var Bgm:Sou = new Sou; var sndChannel:SoundChannel = Bgm.play(); var isDead:Boolean = false; function mover() { Tweener.addTween( red, {x:Math.random()*stage.stageWidth, y:Math.random()*stage.stageHeigh... time:1, rotation:Math.random()*300, onComplete:mover}); Tweener.addTween( arches, {x:Math.random()*stage.stageWidth, y:Math.random()*stage.stageHeigh... time:1, rotation:Math.random()*300, onComplete:mover, transition:"easeInOutBounce"}); Tweener.addTween( utah, {x:Math.random()*stage.stageWidth, y:Math.random()*stage.stageHeigh... time:1, rotation:Math.random()*300, onComplete:mover, transition:"easeOutQuad"}); } mover(); addEventListener(Event.ENTER_FRAME, loop) function loop(e:Event):void { bmd.draw(this); bmd.applyFilter(bmd, bmd.rect, new Point(0,0), bf); bmd.applyFilter(bmd, bmd.rect, new Point(0,0), cmf); if (isDead = true) { play(); } }