<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>Cycling 74  &#187;  Topic: maxclasswrap</title>
		<atom:link href="http://cycling74.com/forums/topic/maxclasswrap/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/maxclasswrap/feed</link>
		<description></description>
		<pubDate>Thu, 20 Jun 2013 03:17:04 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/maxclasswrap/#post-44985</guid>
					<title><![CDATA[maxclasswrap]]></title>
					<link>http://cycling74.com/forums/topic/maxclasswrap/#post-44985</link>
					<pubDate>Sat, 01 Aug 2009 17:01:27 +0000</pubDate>
					<dc:creator>oli larkin</dc:creator>

					<description>
						<![CDATA[
						<p><a href="http://www.cycling74.com/forums/index.php?t=msg&#038;goto=160274&#038;rid=1876&#038;S=0d2e85251e5eb656429d35673c9c869a&#038;srch=class+wrap#msg_160274">http://www.cycling74.com/forums/index.php?t=msg&#038;goto=160274&#038;rid=1876&#038;S=0d2e85251e5eb656429d35673c9c869a&#038;srch=class+wrap#msg_160274</a></p>
<p>in this thread JKC wrote:</p>
<p>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td class="SmallText"><b>Quote:</b></td>
</tr>
<tr>
<td class="quote">&#8230;Just make a .js file (name isn&#8217;t important), and <br />
put it in the jsextensions folder. For each &#8220;nobox&#8221; class you&#8217;d like <br />
to wrap with a JS interface, add a line like the following:</td></tr></table></p>
<p>maxclasswrap(&#8220;mymaxclassname&#8221;,&#8221;MyJavascriptClassName&#8221;);</p>
<p>This will automatically create a class definition wrapped with the <br />
appropriate methods and instantiable in JS like this</p>
<p>var mything = new MyJavascriptClassName();


</p><p>I modified the simplemax example to be a NOBOX. And then i added this to a js file in jsextensions:</p>
<p>maxclasswrap(&#8220;simplemax&#8221;,&#8221;TriggerPopup&#8221;);</p>
<p>but when i try and call this from a js file i get an error:</p>
<p>js: Macintosh HD:/Users/oli/Desktop/poptest.js: Javascript ReferenceError: TriggerPopup is not defined, line 9</p>
<p>Does anyone know what the problem is?</p>
<p>thanks,</p>
<p>oli</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/maxclasswrap/#post-162053</guid>
					<title><![CDATA[Re: maxclasswrap]]></title>
					<link>http://cycling74.com/forums/topic/maxclasswrap/#post-162053</link>
					<pubDate>Mon, 03 Aug 2009 11:59:59 +0000</pubDate>
					<dc:creator>Timothy Place</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Oli, </p>
<p>Has you nobox object been loaded by Max prior to trying to use it from js?  For example, have you put the .mxo/.mxe into the Cycling &#8217;74/extensions folder prior to launching Max?  </p>
<p>JS should be able to wrap the class this way, but the class has to be loaded first.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/maxclasswrap/#post-162054</guid>
					<title><![CDATA[Re: maxclasswrap]]></title>
					<link>http://cycling74.com/forums/topic/maxclasswrap/#post-162054</link>
					<pubDate>Mon, 03 Aug 2009 12:09:33 +0000</pubDate>
					<dc:creator>oli larkin</dc:creator>

					<description>
						<![CDATA[
						<p>yes, i did that. It turns out you have to do:</p>
<p>c->c_flags = CLASS_FLAG_POLYGLOT;<br />
class_register(CLASS_NOBOX, c);</p>
<p>(thanks ej)</p>
<p>without setting CLASS_FLAG_POLYGLOT, JS wasn&#8217;t seeing my object</p>
<p>oli</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/maxclasswrap/#post-162055</guid>
					<title><![CDATA[Re: maxclasswrap]]></title>
					<link>http://cycling74.com/forums/topic/maxclasswrap/#post-162055</link>
					<pubDate>Mon, 03 Aug 2009 17:29:01 +0000</pubDate>
					<dc:creator>Emmanuel Jourdan</dc:creator>

					<description>
						<![CDATA[
						<p>And for the record, you can then access to attributes of your nobox object:</p>
<p>
<div class="pre"></div></p>
<pre>var toto = new MyClass()
post(toto.myattribute, "n");
toto.myattribute = 74;
post(toto.myattribute, "n");</pre>
<p>and if you want to make methods that returns something, you need to use the A_GIMMEBACK signature. For instance:</p>
<p>
<div class="pre"></div></p>
<pre>class_addmethod(c, (method)simplemax_doabs,				"doabs",		A_GIMMEBACK, 0);

t_max_err simplemax_doabs(t_simplemax *x, t_symbol *s, long ac, t_atom *av, t_atom *rv)
{
	t_atom a;
	double f = 0;

	if (ac) {
		if (atom_gettype(av) == A_LONG)
			f = fabs(atom_getlong(av));
		else if( atom_gettype(av) == A_FLOAT)
			f = fabs(atom_getfloat(av));
	} else
		error("missing argument for method doabs()");

	atom_setfloat(&#038;a, f);

	atom_setobj(rv, object_new(gensym("nobox"), gensym("atomarray"), 1, &#038;a));
	return MAX_ERR_NONE;
}</pre>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/maxclasswrap/#post-162056</guid>
					<title><![CDATA[Re: maxclasswrap]]></title>
					<link>http://cycling74.com/forums/topic/maxclasswrap/#post-162056</link>
					<pubDate>Mon, 03 Aug 2009 18:24:14 +0000</pubDate>
					<dc:creator>oli larkin</dc:creator>

					<description>
						<![CDATA[
						<p>perfect! thankyou</p>
<p>oli</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

