Cannot access a property or method of a null object reference.
at DummyAvatarMovieClip/onCustomAction()
at com.smartfoxserver.openspace.mvc::IsoEngineModel/playCustomAvatarAction()
at com.smartfoxserver.openspace::OpenSpace/setMyAvatarAction()
at tokiworld_fla::MainTimeline/onActionBtClick()
Is the button embedded in another movie clip? If so, did you give it an instance name? If not, did you make sure to check off the 'export for actionscript' in the movie clip's properties?
If yes to both of these, could you please post your code? Maybe I can help out.
As reported in the stack trace, it seems that in your onCustomAction() method on the AvatarMovieClip class you are trying to get a property out of a null object. Check every object you are trying to access to find out the one which is null.
public function onCustomAction(evt:AvatarEvent):void
{
var action:Object = evt["params"].action
if (action != null)
{
trace ("'onCustomAction' method called on DummyAvatarMovieClip")
var test:MovieClip = getChildByName("testMC") as MovieClip
trace(test);
test.visible = true
}
}
I know I get the Null value for "test". This is a problem which I don't find the problem.
Here is a funny thing. I use balloon movieclip and it works fine. I can just display the bubble and I can pass object value. (I am working with the openspace sample files). However, if I create a new movieclip, it didn't work. I got the NULL value. Is there any secret that I have to use to create Movie Clip as a custom action?
No secrets... there must be something wrong in your code.
When you call getChildByName("testMC") are you sure that you have the testMC movieclip in the root displaylist of your avatar class?
"balloon" is an instance inside the DummyAvatarMovieClip movieclip (which is the "root displaylist" of your avatar).
"highlight" is a movieclip in the library, which must be instantiated before you can access it.
AS3 is very new for me and i have yet to fully grasp the full understanding.
Bax, i must say that some part in the OpenSpace documentation is very hard to understand and get around. I seriously have to crack my head to figure out how to use all the functions and events implemented in the API. it will be helpful if someone can show MORE and USABLE examples.
right now i'm trying to do the onCustomAction event, so i would appreciate if someone can come to the rescue and enlighten us all noobs.
I will try my best to explain in numbering order of what I am trying to achieve here.
1. i uses 2 files, namely ABC.as and ABC.fla
2. i've created a movieclip of a menu button in the ABC.fla file.
3. this menu button will appear only when the avatar is clicked.
4. this menu button should execute a custom action.
5. the custom action code is reside in the onCustomAction(evt:AvatarEvent), of course.
6. inside the onCustomAction function, i have added the custom actions that i wanted such as jump, swim, etc.
7. this is my BIG question: how do you link that menu button (ABC.fla) to the onCustomAction function (ABC.as) and make the avatar to perform the action?
This is up to OpenSpace. If your main application code resides in map.as, there is where you need to call the os.setMyAvatarAction. OpenSpace (which internally creates an instance of avatar.as) will take care of calling the onCustomAction in your avatar.as class.
As reported in the stack trace, it seems that in your onCustomAction() method on the AvatarMovieClip class you are trying to get a property out of a null object.