 	# TODO: Make sure it's the correct SM
 	transition: (sm, from, to)=>
 		if to == Controller.STATE_ACTIVATED
+			@beforeActivate()
 			@trigger "activating", @
 			@doActivate()
 		else if to == Controller.STATE_DEACTIVATED
+			@beforeDeactivate()
 			@trigger "deactivating", @
 			@doDeactivate()
 	

		c.setParent(@)
		if options.default
			@setDefaultChild(c)	
		@children.push c
	
	removeChild: (c) ->

	# defaultChild		Controller
	#
	
	constructor: (options={}) ->
		@sm = new StateMachine
		
		defaultState = options.defaultState
		
		@sm.addState Controller.STATE_DEACTIVATED, defaultState == Controller.STATE_ACTIVATED ? false : true
		@sm.addState Controller.STATE_ACTIVATED, defaultState == Controller.STATE_ACTIVATED ? true : false
		
		@sm.bind "on_transition", @transition
		@children = []
