getSkinByName

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

croftie
Posts: 49
Joined: 24 Jul 2013, 08:35
Location: Algarve Portugal
Contact:

getSkinByName

Postby croftie » 08 Apr 2015, 14:28

I want to be able to call a function in a dynamic skin using getSkinBy Name. The skin has an associated class functions of which can be called when MapInteractionEvent is used to call the skin as a MovieClip. The class therefore has therefore been tested as interactive and working.

If I try to call the function using getSkinByName I am getting a null.

Code: Select all

private function onOpenSpaceMapRendered(evt:OpenSpaceEvent) {
         trace(openSpace.getAllSkinsByName("TileName")); // returns the name of the associated class
         var SkinMC:MovieClip = openSpace.getSkinByName("TileName", "SkiinName") as MovieClip; //no error message
         
         SkinMC.somefunction();//throws a null error - Error #1009: Cannot access a property or method of a null object reference.
         
      }


from the above code the trace message returns an object with a type of the class name of the skin. So the tile is referencing the skin but does not seem to return the instance name.

IN the skin editor, the skin has been named in the title field. In the tile editor, the skin instance properties have been set with the name, in this case the same as the TileName, and there are various triggers set with targets and params. Whether I use the class name, the skin name or the skin instance name I get a null return . Which am I supposed to use to reference the skin and is it possible to call a function using getSkinByName?
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: getSkinByName

Postby Bax » 08 Apr 2015, 15:46

First of all, make sure you are passing the correct skin name in the openSpace.getSkinByName method.
Also, try tracing the return object of the method, before casting it to MovieClip.
In fact, if the object instance is not a MovieClip (and for example it's a Sprite), the cast will make it null.
Paolo Bax
The SmartFoxServer Team

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 7 guests