Re: How to - multiple instances of similar systems / objects

Sunday, January 29, 2012
That's probably where I'm going wrong. I was declaring them in
CF.userMain, which didn't seem like the right scope. I'll give that a shot.

Heath Volmer
Digital Domain Systems
303-517-9714


On 1/29/12 4:29 PM, Jarrod Bell wrote:
> And make sure the object is defined globally (ie. outside of
> CF.userMain) first so that it can be referenced from buttons.
>
> eg.
>
> // Create the object here
> var myObject;
>
> CF.userMain = function() {
> // instantiate the object here
> myObject = new myDevice();
> };
>
> Jarrod
>
> On 30/01/12 6:26 AM, Heath Volmer wrote:
>> If I have a class "MyDevice" and I create a couple instances of it
>> (say myDevice1 and myDevice2) can I make calls, from buttons, like:
>>
>> myDevice1("play");
>>
>> or do I have to use a singleton pattern and only have one class
>> object to call on?
>>
>> I've been trying different non-singleton things with no luck so far...
>>
>> Thanks
>>
>> Heath Volmer
>> Digital Domain Systems
>> 303-517-9714
>>
>>
>> On 1/28/12 7:09 PM, Jarrod Bell wrote:
>>> You can assign JS calls directly to buttons, no need to use join
>>> numbers unless showing real feedback.
>>>
>>> So you could have one system defined, and then change what device it
>>> is talking to by modifying its IP address/port at runtime using
>>> CF.setSystemProperties.
>>>
>>> The button that you use to change what device you want to control
>>> could have JS attached to it to perform the system properties
>>> changes, then each button could just have something like:
>>>
>>> myDevice.command("play");
>>>
>>> With JavaScript it's really capable of doing pretty much anything
>>> you like - just up to you to program it in a way that suits your
>>> requirements.
>>>
>>> You could even use the same join numbers for each system, and just
>>> make sure to set the joins to a default state when changing systems,
>>> and then request the new data from the system each time you change.
>>>
>>> Jarrod
>>>
>>> On 29/01/12 10:22 AM, Heath Volmer wrote:
>>>> Going to ramble a tad here:
>>>>
>>>> I have a JS file designed to talk to a media server. I could have
>>>> multiple media servers, so I might need multiple systems and
>>>> multiple JS objects to handle them. My JS is building the multiple
>>>> instances with no problem, but now that I'm to the point of
>>>> connecting the buttons on the server's gui page to the JS objects
>>>> that talk to the system, I realize that I have no idea how to
>>>> access a given object from a button and call a function on it.
>>>>
>>>> One method (which I don't like) is to watch joins and route them to
>>>> the currently-selected system.
>>>>
>>>> Another way is to route different ranges of joins to different
>>>> systems (I like this even less, being a big proponent of reusing
>>>> things.)
>>>>
>>>> Either way, I'm assuming that I have to do this routing to the
>>>> appropriate object outside of my objects.
>>>>
>>>> My main questions:
>>>> Please tell me there is a better way that gets me out of
>>>> join-number-ville. I'd like to say command("Play") on a button
>>>> press and have that button talk to the server it's supposed to. Do
>>>> I need to have a central catcher of commands that says "He pressed
>>>> play, and he's on media server 4. Send the command to that one"?
>>>> That might not be too messy.
>>>>
>>>> Is there a way to attach a JS object to a subpage or page? It's
>>>> buttons would refer to a certain instance. (Venturing into
>>>> Mac-Xcode land here again folks) Like a page built in Interface
>>>> Builder has a controller object attached to it.
>>>>
>>>> Thanks
>>>>
>>>
>>
>

--
You received this message because you are subscribed to the Google Groups "CommandFusion" group.
To post to this group, send email to commandfusion@googlegroups.com.
To unsubscribe from this group, send email to commandfusion+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/commandfusion?hl=en.

0 comments:

Post a Comment