2 registered members (TipmyPip, 1 invisible),
18,731
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Dynamically calling objects from arguments?
#115446
03/06/07 05:10
03/06/07 05:10
|
Joined: Jul 2004
Posts: 59
ToddWorld
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2004
Posts: 59
|
Is it possible in c-script to pass an object name in an argument so you can dynamically reference an object in a function? example: Let's say I have 2 panels "message_panel" and "warning_panel". And I want to create a function called showPanel() to display...fadeup...whatever a specific panel. Either the message_panel OR the warning_panel in our example. I'd love to pass the panel name as an argument, let's say showPanel("message_panel"); ...and then have the function change the alpha of the panel to fade it up or down. Sort of like: function showPanel(whichPanel) { whichPanel.alpha = 50; } Of course, this tanks in c-script  . Hopefully there's a way to do this...without a bunch of if/then statements inside the showPanel function to account for every possible panel. Thanks, Todd
|
|
|
Re: Dynamically calling objects from arguments?
[Re: Lion_Ts]
#115450
03/07/07 18:44
03/07/07 18:44
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
Quote:
Is it possible in c-script to pass an object name in an argument so you can dynamically reference an object in a function?
Todd has his own world. For rare instances, where I actually want get/set element by name behavior, I use a dll plugin.
Code:
panel* pnl0_; function showPanel(whichPanel) { // whichPanel parameter might be considered a var or long at this point // whichPanel.alpha = 50; // do sort of cast to (panel*) pnl0_ = whichPanel; pnl0_.alpha = 50; }
//... showPanel(message_panel); showPanel(warning_panel); //...
|
|
|
Re: Dynamically calling objects from arguments?
[Re: testDummy]
#115451
03/09/07 04:41
03/09/07 04:41
|
Joined: Jul 2004
Posts: 59
ToddWorld
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2004
Posts: 59
|
Thanks again for the suggestions, I'll see if I can try them out. Now, preparing to get flamed here, but...passing object names like my example is pretty common in Action Script 2.0. But then again, since AS 2 doesn't have pointers...they may have something to do with it. Did I mention I'm mainly a design guy...but anyhow, my programming background goes way back, but I haven't spent any time with C or C++. Basic...like 1.0 back in '78, Logo (pointless), Pascal, Lingo (Director, and pointless), PERL, javascript and Action Script 1 and 2. So, bring on the flames...but I do genuinely appreciate the advice. Thanks, Todd p.s. and yes, I do tend to live in my own happy world...my site is www.toddworld.com 
|
|
|
Re: Dynamically calling objects from arguments?
[Re: ToddWorld]
#115452
03/09/07 04:50
03/09/07 04:50
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
"A5 2" ?...
You have to use pointers to panels (and everything else), not the name's of their defined name...
xXxGuitar511 - Programmer
|
|
|
Re: Dynamically calling objects from arguments?
[Re: xXxGuitar511]
#115453
03/09/07 06:17
03/09/07 06:17
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
Quote:
Now, preparing to get flamed here, but...passing object names like my example is pretty common in Action Script 2.0. But then again, since AS 2 doesn't have pointers...they may have something to do with it.
Quote:
So, bring on the flames...but I do genuinely appreciate the advice.
Quoted ToddWorld ignitable. I can't determine why you should be flamed for that specifically, and not just for suggesting that you should be flamed, but in the meantime, if you feel you actually deserve to be flamed, perhaps, because you have strong masochistic tendencies, you can start offending and/or insulting yourself in this very thread, right now (no need to pause for effect), but keep in mind, at this time, as a 'pseudo-professional', assuming that I have redefined the term of course, I can not officially recommend that you start flaming yourself.
Wait...if you really, really, like PERL, maybe I can find a match...
Last edited by testDummy; 03/09/07 06:21.
|
|
|
Re: Dynamically calling objects from arguments?
[Re: testDummy]
#115454
03/09/07 13:21
03/09/07 13:21
|
Joined: Jul 2004
Posts: 59
ToddWorld
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2004
Posts: 59
|
...well...there was this one time, in band camp.  But seriously, your example looks like it should straighten things out. I was just trying to make a point that even though I'm new to c-script I have had a little experience with programming. Most "hard core" programmers I know are very...opinionated about the langauge they're currently using. As a result I get a nice set of 'eye rolls' if I mention several years of Action Script experience. It looks like you're not of that mindset. Which is great. My hope is, even though I'm asking a number of noob questions that things will click relativly quickly, and so far with help from the 3DGS community and other tutorials and examples online, that's pretty much been the case. I just figured there'd be come virtual eye-rolling going on. But a brothers got to learn somehow. I'll post screens of what I'm working on pretty soon. It's just a small side-scroller/platformer. Thanks, Todd p.s. now I'm just curious as to what you edited...
|
|
|
|