x


#pragma strict and NotificatonCenterGenerics

Hi guys,

I have some code that plays nicely with http://www.unifycommunity.com/wiki/index.php?title=NotificationCenterGenerics as long as my code isn't set to #pragma strict. Here is the code:


function AddScore(notification: Notification)
{
	score += notification.data;
}

function AddGems(notification: Notification)
{
	gems += notification.data;
}

If I use #pragma strict, I get this error:

Assets/Game Logic/LevelStatus.js(119,15): BCE0051: Operator '+' cannot be used with a left hand side of type 'int' and a right hand side of type 'Object'.

This is because data is an untyped variable in class Notification in the wiki code link. In order to get around the strict compilation issue, the code that I wrote needs some way to determine data's datatype. What should I do?

MachCUBED

more ▼

asked May 27 '12 at 12:32 AM

MachCUBED gravatar image

MachCUBED
116 22 32 37

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

Try this:

var i : int = notification.data;
score += i;
more ▼

answered May 27 '12 at 12:36 AM

whydoidoit gravatar image

whydoidoit
33.1k 12 23 101

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5088
x825
x28
x10
x9

asked: May 27 '12 at 12:32 AM

Seen: 325 times

Last Updated: May 27 '12 at 12:36 AM