📄 cardgamescenechangecommand.as.svn-base
字号:
/**
* Project:用户场景中游戏设置与游戏场景之间的切换 命令
* Author : dmh2002 Blog:http://dmh2002.com/
* QQ:122054933 MSN:shangxinyu2002@msn.com
* Date : 2008.04.08
*/
package com.dmh2002.games.cardgame.cairngorm.command
{
import com.adobe.cairngorm.commands.ICommand;
import com.adobe.cairngorm.control.CairngormEvent;
import com.dmh2002.games.cardgame.cairngorm.model.CardGameModelLoactor;
import com.dmh2002.games.cardgame.cairngorm.view.GameBody;
import com.dmh2002.games.cardgame.cairngorm.view.GameLogin;
import com.dmh2002.games.cardgame.effects.SceneChangeEffect;
import com.dmh2002.games.cardgame.cairngorm.view.GameRoom;
import com.dmh2002.games.cardgame.cairngorm.view.GameBody;
import mx.core.UIComponent;
import mx.effects.AddChildAction;
import mx.effects.Move;
import mx.effects.Parallel;
import mx.effects.RemoveChildAction;
import mx.effects.Resize;
import mx.effects.Sequence;
import mx.controls.Alert;
public class CardGameSceneChangeCommand implements ICommand
{
[Bindable]
private var _model:CardGameModelLoactor = CardGameModelLoactor.getInstance()
public function CardGameSceneChangeCommand()
{
}
public function execute(event:CairngormEvent):void
{
//将主主场景设置为绝对模式
_model.cardGame_Application.layout = "absolute";
var _toComp:UIComponent;
var _reSize:Resize
var _parallel:Parallel
var _addChildAction:AddChildAction
var _removeChildAction:RemoveChildAction
//Alert.show(event.data.name, "titleabc", Alert.YES | Alert.NO);
//在主场景中加入另外一个场景
if (event.data.name == _model.gameLoginName)
{
_toComp = new GameRoom(); // 加入新场景
_toComp.x=(_model.cardGame_Application.width-_model.gameLogin_Width)/2;
_toComp.y=(_model.cardGame_Application.height-_model.gameLogin_Height)/2;
_toComp.visible = false;
_model.cardGame_Application.addChild(_toComp)
//设置放大效果
_reSize = new Resize()
_reSize.target = _model.cardGame_Application.getChildByName(_model.gameRoomName)
_reSize.widthTo = _model.gameBody_Width;
_reSize.heightTo = _model.gameBody_Height;
_reSize.duration = 1000 ;
} else if (event.data.name == _model.gameRoomName)
{
_toComp = new GameBody(); // 加入新场景
_toComp.x=(_model.cardGame_Application.width-_model.gameLogin_Width)/2;
_toComp.y=(_model.cardGame_Application.height-_model.gameLogin_Height)/2;
_toComp.visible = false;
_model.cardGame_Application.addChild(_toComp)
//设置放大效果
_reSize = new Resize()
_reSize.target = _model.cardGame_Application.getChildByName(_model.gameBodyName)
_reSize.widthTo = _model.gameBody_Width;
_reSize.heightTo = _model.gameBody_Height;
_reSize.duration = 1000 ;
}
else if (event.data.name == _model.gameBodyName)
{
//从游戏返回登录界面时初始化一些model中的数据
initModel()
//设置缩小效果
_reSize = new Resize()
_reSize.target = _model.cardGame_Application.getChildByName(_model.gameBodyName)
_reSize.widthTo = _model.gameLogin_Width;
_reSize.heightTo = _model.gameLogin_Height;
_reSize.duration = 1000 ;
//设置移动效果
var _move:Move = new Move();
_move.target = _model.cardGame_Application.getChildByName(_model.gameBodyName);
_move.xTo =(_model.cardGame_Application.width-_model.gameLogin_Width)/2
_move.yTo =(_model.cardGame_Application.height-_model.gameLogin_Height)/2
_move.duration = 1000;
//设置并行动画效果
_parallel = new Parallel();
_parallel.addChild(_reSize);
_parallel.addChild(_move)
//添加登录窗口
_toComp = new GameLogin()
_toComp.x=(_model.cardGame_Application.width-_model.gameLogin_Width)/2
_toComp.y=(_model.cardGame_Application.height-_model.gameLogin_Height)/2
_toComp.visible = false;
//添加登录窗口事件
_addChildAction = new AddChildAction()
_addChildAction.target = _toComp
_addChildAction.relativeTo = _model.cardGame_Application
}
//设置3D动画效果
var _sceneChangeEffect:SceneChangeEffect = new SceneChangeEffect()
_sceneChangeEffect.duration = 1000 ;
_sceneChangeEffect.target = event.data ;
_sceneChangeEffect.toComp = _toComp ;
//动画结束后删除另外一个窗口事件
_removeChildAction = new RemoveChildAction()
_removeChildAction.target = event.data
//设置一个组合效果
var _sequence:Sequence = new Sequence()
if (event.data.name == _model.gameLoginName)
{
_sequence.addChild(_sceneChangeEffect);
_sequence.addChild(_removeChildAction);
_sequence.addChild(_reSize);
}
else if (event.data.name == _model.gameRoomName)
{
_sequence.addChild(_sceneChangeEffect);
_sequence.addChild(_removeChildAction);
_sequence.addChild(_reSize);
}
else if (event.data.name == _model.gameBodyName)
{
_sequence.addChild(_parallel);
_sequence.addChild(_addChildAction);
_sequence.addChild(_sceneChangeEffect);
_sequence.addChild(_removeChildAction);
}
//执行动画
_sequence.play()
}
//从游戏返回登录界面时初始化一些model中的数据
private function initModel():void
{
_model.gameStage_UserViewArray = [];
_model.gameInfo_Banker = _model.GAME_INFO_BANKER;
_model.gameInfo_GameNums = 0;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -