Hi Steven,
You could try using arguments.caller to check if the setter was called by
the controller. Here's a little test function I whipped up on the _root:
function testCaller(){
trace (typeof arguments.caller)
trace (arguments.caller == controller.test)
trace (arguments.caller == notcontroller.test)
}
controller = new Object();
controller.test = function (){
_root.testCaller()
}
notcontroller = new Object();
notcontroller.test = function (){
_root.testCaller()
}
The output is:
function
true
false
function
false
true
This gives you a way to check if the function was called from the controller
or the notcontroller.
The downside is that this checks for a specific function within a
controller, not just any controller function. I wonder if there's a way
around it?
Karina
> -----Original Message-----
> From: Steven Sacks | BLITZ [mailto:[EMAIL PROTECTED]
> Sent: 25 August 2006 02:37
> To: Flashcoders mailing list
> Subject: [Flashcoders] Protect model setters from being
> called by any classexcept Controller
>
> Hi,
>
> I have a model class that has a bunch of getters and setters.
> Example:
>
> private var _prop:Object;
> function get prop():Object {
> return _prop;
> }
> function set prop(p:Object) {
> _prop = p;
> }
>
> I have a controller class that instantiates that model.
>
> I'm wondering if there is some way to prevent any other class
> from using the setter methods of the model except the
> controller class. They still should be able to access the getters.
>
> I want to prevent future developers from being able to access
> the model setters from anywhere except the controller in
> order to enforce proper MVC patterns.
>
> Thanks!
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com