PageRenderTime 66ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/v0.8.0/Test_Red2D_V0.8.0/src/particle_ex/Controller.as

http://red2d-agal2d.googlecode.com/
ActionScript | 315 lines | 196 code | 72 blank | 47 comment | 4 complexity | 694900a37579dee97517a25b0d8ee732 MD5 | raw file
  1. package particle_ex
  2. {
  3. import com.bit101.components.CheckBox;
  4. import com.bit101.components.ComboBox;
  5. import com.bit101.components.HUISlider;
  6. import com.bit101.components.Label;
  7. import com.bit101.components.PushButton;
  8. import com.bit101.components.Style;
  9. import com.bit101.components.TextArea;
  10. import flash.display.Sprite;
  11. import flash.events.Event;
  12. import flash.events.MouseEvent;
  13. import red2D_Particle.ParticleEmitter;
  14. /**
  15. * <p>?? ??? ??? ???</p>
  16. * <p>Last update - Oct 16, 2011</p>
  17. * @author ???(seon ki, paik) / http://redcamel-studio.tistory.com
  18. *
  19. * @langversion ActionScript 3.0
  20. * @playerversion Flash 11
  21. * @playerversion AIR 3.0
  22. */
  23. public class Controller extends Sprite
  24. {
  25. private var _target:ParticleEmitter;
  26. private var huiSlider_randomAngle:CheckBox;
  27. private var huiSlider_waveStartRotationRandom:CheckBox;
  28. private var huiSlider_liftTime:HUISlider;
  29. private var huiSlider_angle:HUISlider;
  30. private var huiSlider_Particle:HUISlider;
  31. private var huiSlider_moveSpeed:HUISlider;
  32. private var huiSlider_emitterWidth:HUISlider;
  33. private var huiSlider_emitterHeight:HUISlider;
  34. private var huiSlider_angleRandomMin:HUISlider;
  35. private var huiSlider_angleRandomMax:HUISlider;
  36. private var huiSlider_scale_first:HUISlider;
  37. private var huiSlider_scale_last:HUISlider;
  38. private var huiSlider_scale_speed:HUISlider;
  39. private var huiSlider_alpha_first:HUISlider;
  40. private var huiSlider_alpha_last:HUISlider;
  41. private var huiSlider_alpha_speed:HUISlider;
  42. private var huiSlider_gravity:HUISlider;
  43. /**
  44. * ????? ?????? ??
  45. */
  46. private var propertyArray:Array = []
  47. private var propertyTxt:TextArea;
  48. private var huiSlider_wave_first:HUISlider;
  49. private var huiSlider_last_first:Object;
  50. private var huiSlider_wave_speed:Object;
  51. private var huiSlider_rotation_first:HUISlider;
  52. private var huiSlider_rotation_last:Object;
  53. private var huiSlider_rotation_speed:Object;
  54. private var huiSlider_wave_direction:ComboBox;
  55. public function Controller( $target:ParticleEmitter )
  56. {
  57. _target = $target
  58. addEventListener(Event.ADDED_TO_STAGE, setUI)
  59. }
  60. private function setUI(e:Event):void
  61. {
  62. var gui:Sprite = new Sprite
  63. stage.addChild(gui)
  64. // ?????
  65. huiSlider_liftTime=new HUISlider(gui,10,10,"particle_liftTime",setValue)
  66. huiSlider_liftTime.setSliderParams(0,4,_target.particle_liftTime)
  67. propertyArray.push(huiSlider_liftTime)
  68. huiSlider_liftTime.labelPrecision=4
  69. // ????
  70. huiSlider_angle=new HUISlider(gui,150,87,"particle_angle",setValue)
  71. huiSlider_angle.setSliderParams(0,360,_target.particle_angle)
  72. propertyArray.push(huiSlider_angle)
  73. huiSlider_angle.labelPrecision=4
  74. // ?? ?????
  75. huiSlider_Particle=new HUISlider(gui,10,50,"maxParticleNum",setValue)
  76. huiSlider_Particle.setSliderParams(0,150,_target.maxParticleNum)
  77. propertyArray.push(huiSlider_Particle)
  78. // ???
  79. huiSlider_moveSpeed=new HUISlider(gui,200,10,"particle_moveSpeed",setValue)
  80. huiSlider_moveSpeed.setSliderParams(0,20,_target.particle_moveSpeed)
  81. huiSlider_moveSpeed.width=250
  82. propertyArray.push(huiSlider_moveSpeed)
  83. huiSlider_moveSpeed.labelPrecision=4
  84. // ??????
  85. huiSlider_emitterWidth=new HUISlider(gui,200,30,"emitterAreaWidth",setValue)
  86. huiSlider_emitterWidth.setSliderParams(0,1680,_target.emitterAreaWidth)
  87. huiSlider_emitterWidth.width=250
  88. propertyArray.push(huiSlider_emitterWidth)
  89. // ??????
  90. huiSlider_emitterHeight=new HUISlider(gui,200,50,"emitterAreaHeight",setValue)
  91. huiSlider_emitterHeight.setSliderParams(0,1280,_target.emitterAreaHeight)
  92. huiSlider_emitterHeight.width=250
  93. propertyArray.push(huiSlider_emitterHeight)
  94. //////////////////////////////////////////////////////////////////////////////////////
  95. // ???? ????
  96. huiSlider_randomAngle=new CheckBox(gui,10,90,"particle_randomAngle", HD_randomAngle)
  97. huiSlider_randomAngle.selected=_target.particle_randomAngle
  98. propertyArray.push(huiSlider_randomAngle)
  99. // ???? ??
  100. huiSlider_angleRandomMin=new HUISlider(gui,10,110,"particle_randomAngleMin",setValue)
  101. huiSlider_angleRandomMin.width=350
  102. huiSlider_angleRandomMin.setSliderParams(-360,360,_target.particle_randomAngleMin)
  103. propertyArray.push(huiSlider_angleRandomMin)
  104. // ???? ??
  105. huiSlider_angleRandomMax=new HUISlider(gui,10,130,"particle_randomAngleMax",setValue)
  106. huiSlider_angleRandomMax.width=350
  107. huiSlider_angleRandomMax.setSliderParams(-360,360,_target.particle_randomAngleMax)
  108. propertyArray.push(huiSlider_angleRandomMax)
  109. //////////////////////////////////////////////////////////////////////////////////////
  110. //////////////////////////////////////////////////////////////////////////////////////
  111. // ??? ??
  112. huiSlider_scale_first=new HUISlider(gui,10,170,"particle_firstScale",setValue)
  113. huiSlider_scale_first.labelPrecision=4
  114. huiSlider_scale_first.width=350
  115. huiSlider_scale_first.setSliderParams(0,5,_target.particle_firstScale)
  116. propertyArray.push(huiSlider_scale_first)
  117. // ??? ??
  118. huiSlider_scale_last=new HUISlider(gui,10,190,"particle_lastScale",setValue)
  119. huiSlider_scale_last.labelPrecision=4
  120. huiSlider_scale_last.width=350
  121. huiSlider_scale_last.setSliderParams(0,5,_target.particle_lastScale)
  122. propertyArray.push(huiSlider_scale_last)
  123. // ??? ??
  124. huiSlider_scale_speed=new HUISlider(gui,10,210,"particle_speedScale",setValue)
  125. huiSlider_scale_speed.labelPrecision=4
  126. huiSlider_scale_speed.width=350
  127. huiSlider_scale_speed.setSliderParams(0,1,_target.particle_speedScale)
  128. propertyArray.push(huiSlider_scale_speed)
  129. //////////////////////////////////////////////////////////////////////////////////////
  130. // ?? ??
  131. huiSlider_alpha_first=new HUISlider(gui,10,250,"particle_firstAlpha",setValue)
  132. huiSlider_alpha_first.labelPrecision=4
  133. huiSlider_alpha_first.width=350
  134. huiSlider_alpha_first.setSliderParams(0,1,_target.particle_firstAlpha)
  135. propertyArray.push(huiSlider_alpha_first)
  136. // ?? ??
  137. huiSlider_alpha_last=new HUISlider(gui,10,270,"particle_lastAlpha",setValue)
  138. huiSlider_alpha_last.labelPrecision=4
  139. huiSlider_alpha_last.width=350
  140. huiSlider_alpha_last.setSliderParams(0,1,_target.particle_lastAlpha)
  141. propertyArray.push(huiSlider_alpha_last)
  142. // ?? ??
  143. huiSlider_alpha_speed=new HUISlider(gui,10,290,"particle_speedAlpha",setValue)
  144. huiSlider_alpha_speed.labelPrecision=4
  145. huiSlider_alpha_speed.width=350
  146. huiSlider_alpha_speed.setSliderParams(0,1,_target.particle_speedAlpha)
  147. propertyArray.push(huiSlider_alpha_speed)
  148. huiSlider_alpha_speed.labelPrecision=4
  149. //////////////////////////////////////////////////////////////////////////////////////
  150. // rotation ??
  151. huiSlider_rotation_first=new HUISlider(gui,10,330,"particle_firstRotation",setValue)
  152. huiSlider_rotation_first.labelPrecision=4
  153. huiSlider_rotation_first.width=350
  154. huiSlider_rotation_first.setSliderParams(0,360,_target.particle_firstRotation)
  155. propertyArray.push(huiSlider_rotation_first)
  156. // rotation ??
  157. huiSlider_rotation_last=new HUISlider(gui,10,350,"particle_lastRotation",setValue)
  158. huiSlider_rotation_last.labelPrecision=4
  159. huiSlider_rotation_last.width=350
  160. huiSlider_rotation_last.setSliderParams(0,360,_target.particle_lastRotation)
  161. propertyArray.push(huiSlider_rotation_last)
  162. // rotation ??
  163. huiSlider_rotation_speed=new HUISlider(gui,10,370,"particle_speedRotation",setValue)
  164. huiSlider_rotation_speed.labelPrecision=4
  165. huiSlider_rotation_speed.width=350
  166. huiSlider_rotation_speed.setSliderParams(0,1,_target.particle_speedRotation)
  167. propertyArray.push(huiSlider_rotation_speed)
  168. //////////////////////////////////////////////////////////////////////////////////////
  169. // wave??
  170. huiSlider_wave_first=new HUISlider(gui,10,410,"particle_waveRotation",setValue)
  171. huiSlider_wave_first.labelPrecision=4
  172. huiSlider_wave_first.width=350
  173. huiSlider_wave_first.setSliderParams(0,360,_target.particle_waveRotation)
  174. propertyArray.push(huiSlider_wave_first)
  175. // wave ??
  176. huiSlider_last_first=new HUISlider(gui,10,430,"particle_waveAmplitude",setValue)
  177. huiSlider_last_first.labelPrecision=4
  178. huiSlider_last_first.width=350
  179. huiSlider_last_first.setSliderParams(0,100,_target.particle_waveAmplitude)
  180. propertyArray.push(huiSlider_last_first)
  181. // wave ??
  182. huiSlider_wave_speed=new HUISlider(gui,10,450,"particle_waveSpeed",setValue)
  183. huiSlider_wave_speed.labelPrecision=4
  184. huiSlider_wave_speed.width=350
  185. huiSlider_wave_speed.setSliderParams(0,100,_target.particle_waveSpeed)
  186. propertyArray.push(huiSlider_wave_speed)
  187. new Label(gui,10,470,"waveDirection")
  188. // wave ??
  189. huiSlider_wave_direction=new ComboBox(gui,105,470,"VERTICAL",["HORIZON","VERTICAL"])
  190. huiSlider_wave_direction.width=200
  191. propertyArray.push(huiSlider_wave_direction)
  192. huiSlider_wave_direction.addEventListener(Event.SELECT, HD_select)
  193. // ??
  194. huiSlider_gravity=new HUISlider(gui,10,530,"gravity",setValue)
  195. huiSlider_gravity.setSliderParams(0,10,_target.gravity)
  196. huiSlider_gravity.width=350
  197. propertyArray.push(huiSlider_gravity)
  198. var propertyBt:PushButton = new PushButton(gui,10,560,"getEmitterProperty", HD_getProperty)
  199. propertyTxt = new TextArea(gui,10,580,"click getEmitterProperty Button")
  200. }
  201. /********************************************************************************/
  202. /** ?? ?? ??? **/
  203. /********************************************************************************/
  204. public function getEmitterPropertyArray():String{
  205. var str:String ="Propery List! - use make Particle Preset\n"
  206. str+="var obj:Object = new Object();\n"
  207. for each(var child:* in propertyArray){
  208. if(child is HUISlider){
  209. str += "obj."+child.label + "='" + child.value +"'\n"
  210. }else if(child is CheckBox){
  211. str += "obj."+child.label + "=" + child.selected +"\n"
  212. }else if(child is ComboBox){
  213. str += "obj.particle_randomAngle" + "=" + huiSlider_randomAngle.selected +"\n"
  214. }else{
  215. throw new Error("minimacomp ??? ????? ???????????")
  216. }
  217. }
  218. return str
  219. }
  220. /********************************************************************************/
  221. /** ??? **/
  222. /********************************************************************************/
  223. protected function HD_select($event:Event):void
  224. {
  225. _target.particle_waveDirection = String(huiSlider_wave_direction.selectedItem)
  226. }
  227. private function HD_randomAngle( $e:Event = null):void
  228. {
  229. propertyTxt.text="click getEmitterProperty Button!"
  230. _target.particle_randomAngle = huiSlider_randomAngle.selected
  231. }
  232. private function setValue($e:Event=null):void
  233. {
  234. propertyTxt.text="click getEmitterProperty Button!"
  235. _target[$e.currentTarget.label] = $e.currentTarget.value
  236. }
  237. protected function HD_getProperty(event:MouseEvent):void
  238. {
  239. trace(getEmitterPropertyArray())
  240. propertyTxt.text = getEmitterPropertyArray()
  241. }
  242. }
  243. }