Error #1009 with FlxG.sound

52 views
Skip to first unread message

ArrowTheRodgers

unread,
Jan 27, 2015, 2:29:08 AM1/27/15
to haxef...@googlegroups.com
Hey all, been having an issue I haven't been able to solve.

I'm trying to get music to play when my game starts up. In the setupGame method of my Main.hx, I have: FlxG.sound.playMusic(AssetPaths.my_song__mp3, 1, true);

When I build to a flash target, it builds successfully, but then my flash player throws the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.

My music file is in the assets/music folder, and I've checked that it is correctly named and everything. Any ideas as to what might be wrong?

Cheers,
- Arrow


Nazywam

unread,
Jan 27, 2015, 4:48:19 AM1/27/15
to haxef...@googlegroups.com
Hey,

You can try using manual path like so:
FlxG.sound.playMusic("assets/music/mySong.mp3, 1, true);
Have You tried building to other platforms/using other sound formats?

ArrowTheRodgers

unread,
Jan 27, 2015, 5:23:41 PM1/27/15
to haxef...@googlegroups.com
You can try using manual path like so:
FlxG.sound.playMusic("assets/music/mySong.mp3, 1, true);
Have You tried building to other platforms/using other sound formats?

Hey, using the manual path, building to windows as well as flash, and using wav and mp3 files. Still having the same problem :(

This is the full error file:
 TypeError: Error #1009: Cannot access a property or method of a null object reference.
at flixel.system::FlxSound/startSound()[C:\HaxeToolkit\haxe\lib\flixel\3,3,5\flixel\system\FlxSound.hx:507]
at flixel.system::FlxSound/play()[C:\HaxeToolkit\haxe\lib\flixel\3,3,5\flixel\system\FlxSound.hx:393]
at flixel.system.frontEnds::SoundFrontEnd/playMusic()[C:\HaxeToolkit\haxe\lib\flixel\3,3,5\flixel\system\frontEnds\SoundFrontEnd.hx:86]
at Main/setupGame()[C:\Users\Arrow\SkyDrive\Coding\Workspaces\game\source\Main.hx:73]
at Main/init()[C:\Users\Arrow\SkyDrive\Coding\Workspaces\game\source\Main.hx:54]
at flash.display::DisplayObjectContainer/addChild()
at Main$/main()[C:\Users\Arrow\SkyDrive\Coding\Workspaces\game\source\Main.hx:30]
at Function/<anonymous>()
at ApplicationMain$/start()[C:\Users\Arrow\SkyDrive\Coding\Workspaces\game\export\flash\haxe\ApplicationMain.hx:189]
at ApplicationMain$/init()[C:\Users\Arrow\SkyDrive\Coding\Workspaces\game\export\flash\haxe\ApplicationMain.hx:131]
at lime.app::Preloader/start()[C:\HaxeToolkit\haxe\lib\lime\2,0,0-alpha,6\lime\app\Preloader.hx:211]
at openfl.display::Preloader/display_onComplete()[C:\HaxeToolkit\haxe\lib\openfl\2,1,4\openfl\display\Preloader.hx:129]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at NMEPreloader/onLoaded()[C:\Users\Arrow\SkyDrive\Coding\Workspaces\game\export\flash\haxe\NMEPreloader.hx:98]
at flixel.system::FlxPreloaderBase/onEnterFrame()[C:\HaxeToolkit\haxe\lib\flixel\3,3,5\flixel\system\FlxPreloaderBase.hx:125]

Gama11

unread,
Jan 29, 2015, 6:00:07 AM1/29/15
to haxef...@googlegroups.com
What does the <assets> node in your xml look like?

ArrowTheRodgers

unread,
Jan 31, 2015, 3:00:05 AM1/31/15
to haxef...@googlegroups.com
<!--------------------------------PATHS SETTINGS-------------------------------->
<set name="BUILD_DIR" value="export" />
<classpath name="source" />
<assets path="assets/data" include="*.oel|*.oep" />
<assets path="assets/images" include="*.png" />

Gama11

unread,
Jan 31, 2015, 4:33:46 AM1/31/15
to haxef...@googlegroups.com
You don't seem to be embedding music anywhere? No wonder you're getting a null reference error.

ArrowTheRodgers

unread,
Jan 31, 2015, 3:58:11 PM1/31/15
to haxef...@googlegroups.com
Ah, yeah I haven't done anything to embed music. What do I need to do?
Reply all
Reply to author
Forward
0 new messages