-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
919 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testrun name="" > | ||
<testsuite name="Default Test Suite" project="Mahjong"> | ||
<testsuite name="tests:MainSuite" type="testcaseclass"/> | ||
</testsuite> | ||
<portNumber value="8765" /> | ||
</testrun> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<actionScriptProperties analytics="false" mainApplicationPath="Mahjong.as" projectUUID="f2b11b48-6554-40c2-b3be-d54660764db4" version="10"> | ||
<compiler additionalCompilerArguments="-locale en_US -use-network=false" autoRSLOrdering="true" copyDependentFiles="true" fteInMXComponents="false" generateAccessible="true" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="true" htmlPlayerVersionCheck="true" includeNetmonSwc="false" outputFolderPath="bin-debug" removeUnusedRSL="true" sourceFolderPath="src" strict="true" targetPlayerVersion="0.0.0" useApolloConfig="false" useDebugRSLSwfs="true" verifyDigests="true" warn="true"> | ||
<compilerSourcePath/> | ||
<libraryPath defaultLinkType="0"> | ||
<libraryPathEntry kind="4" path=""> | ||
<excludedEntries> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_charts.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="1" linkType="1" path="${PROJECT_FRAMEWORKS}/locale/{locale}"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/advancedgrids.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/qtp.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_air.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/charts.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/framework.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/mx/mx.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/netmon.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/spark.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/sparkskins.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/rpc.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/datavisualization.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/qtp_air.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/videoPlayer.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/spark_dmv.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_dmv.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/flash-integration.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_flashflexkit.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_agent.swc" useDefaultLinkType="false"/> | ||
</excludedEntries> | ||
</libraryPathEntry> | ||
<libraryPathEntry kind="1" linkType="1" path="${FLEXUNIT_LIB_LOCATION}/version4libs/Common"/> | ||
<libraryPathEntry kind="1" linkType="1" path="${FLEXUNIT_LIB_LOCATION}/version4libs/ASProject"/> | ||
<libraryPathEntry kind="1" linkType="1" path="${FLEXUNIT_LIB_LOCATION}/version4libs/ASProject_Extended"/> | ||
<libraryPathEntry kind="1" linkType="1" path="${FLEXUNIT_LOCALE_LOCATION}/version4locale/"/> | ||
</libraryPath> | ||
<sourceAttachmentPath/> | ||
</compiler> | ||
<applications> | ||
<application path="FlexUnitApplication.as"/> | ||
<application path="FlexUnitCompilerApplication.as"/> | ||
<application path="Mahjong.as"/> | ||
</applications> | ||
<modules/> | ||
<buildCSSFiles/> | ||
<flashCatalyst validateFlashCatalystCompatibility="false"/> | ||
</actionScriptProperties> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<preferences/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Mahjong</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.adobe.flexbuilder.project.flexbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.adobe.flexbuilder.project.actionscriptnature</nature> | ||
</natures> | ||
</projectDescription> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package | ||
{ | ||
import Array; | ||
|
||
import flash.display.Sprite; | ||
|
||
import flexunit.flexui.FlexUnitTestRunnerUIAS; | ||
|
||
import tests.MainSuite; | ||
|
||
public class FlexUnitApplication extends Sprite | ||
{ | ||
public function FlexUnitApplication() | ||
{ | ||
onCreationComplete(); | ||
} | ||
|
||
private function onCreationComplete():void | ||
{ | ||
var testRunner:FlexUnitTestRunnerUIAS=new FlexUnitTestRunnerUIAS(); | ||
testRunner.portNumber=8765; | ||
this.addChild(testRunner); | ||
testRunner.runWithFlexUnit4Runner(currentRunTestSuite(), "Mahjong"); | ||
} | ||
|
||
public function currentRunTestSuite():Array | ||
{ | ||
var testsToRun:Array = new Array(); | ||
testsToRun.push(tests.MainSuite); | ||
return testsToRun; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
*This file is automatically generated by Flash Builder to compile FlexUnit classes and is not intended for modification. | ||
*Please click on the "Refresh" icon in "FlexUnit Results" view to regenerate this file. | ||
*/ | ||
|
||
package | ||
{ | ||
import flash.display.Sprite; | ||
|
||
import tests.MainSuite; | ||
import tests.CardsImagesLoaderTest; | ||
import tests.CardsGeneratorTest; | ||
import tests.SimpleCardsPlacerTest; | ||
|
||
public class FlexUnitCompilerApplication extends Sprite | ||
{ | ||
private var tests_SimpleCardsPlacerTest_obj:tests.SimpleCardsPlacerTest; | ||
private var tests_CardGeneratorTest_obj:tests.CardsGeneratorTest; | ||
private var tests_CardsImagesLoaderTest_obj:tests.CardsImagesLoaderTest; | ||
|
||
private var tests_MainSuite_obj:tests.MainSuite; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package | ||
{ | ||
import engines.Card; | ||
import engines.CardsGenerator; | ||
import engines.RulesEngine; | ||
import engines.cardsPlacers.ICardsPlacer; | ||
import engines.cardsPlacers.SimpleCardsPlacer; | ||
|
||
import flash.display.Bitmap; | ||
import flash.display.BitmapData; | ||
import flash.display.Sprite; | ||
import flash.display.StageAlign; | ||
import flash.display.StageScaleMode; | ||
import flash.events.Event; | ||
import flash.events.MouseEvent; | ||
import flash.text.TextField; | ||
import flash.text.TextFormat; | ||
import flash.text.TextFormatAlign; | ||
|
||
import utils.CardsImagesLoader; | ||
|
||
[SWF(width="1024", height="768", frameRate="24", backgroundColor="0xBABABA")] | ||
public class Mahjong extends Sprite | ||
{ | ||
public function Mahjong() | ||
{ | ||
initStageParameters(); | ||
initPlayGround(); | ||
addRestartButton(); | ||
|
||
var loader:CardsImagesLoader = new CardsImagesLoader(); | ||
loader.addEventListener(Event.COMPLETE, onCardsImagesLoad); | ||
loader.loadImages("cards", 5); | ||
} | ||
|
||
[Embed(source="/../assets/0.png")] | ||
private var _backImage:Class; | ||
|
||
private var _playGround:Sprite; | ||
private var _cardsImages:Vector.<BitmapData>; | ||
|
||
private function initStageParameters():void | ||
{ | ||
stage.scaleMode = StageScaleMode.NO_SCALE; | ||
stage.align = StageAlign.TOP_LEFT; | ||
} | ||
|
||
private function initPlayGround():void | ||
{ | ||
_playGround = new Sprite(); | ||
_playGround.y = 25; | ||
addChild(_playGround); | ||
} | ||
|
||
private function addRestartButton():void | ||
{ | ||
var restartButton:TextField = new TextField(); | ||
restartButton.text = "Restart"; | ||
var textFormat:TextFormat = new TextFormat(null, 16, 0xffffff, true, false, false, "", "", TextFormatAlign.CENTER); | ||
restartButton.setTextFormat(textFormat); | ||
restartButton.background = true; | ||
restartButton.selectable = false; | ||
restartButton.mouseEnabled = false; | ||
restartButton.backgroundColor = 0x333333; | ||
restartButton.width = 200; | ||
restartButton.height = 20; | ||
var container:Sprite = new Sprite(); | ||
container.buttonMode = true; | ||
container.x = 5; | ||
container.y = 5; | ||
container.addChild(restartButton); | ||
container.addEventListener(MouseEvent.CLICK, onRestartButtonClick); | ||
addChild(container); | ||
} | ||
|
||
private function onRestartButtonClick(event:MouseEvent):void | ||
{ | ||
startNewGame(); | ||
} | ||
|
||
private function startNewGame():void | ||
{ | ||
if (!_cardsImages) | ||
{ | ||
throw new Error("Cards images didn't load!"); | ||
return; | ||
} | ||
|
||
_playGround.removeChildren(); | ||
var cardsGenerator:CardsGenerator = new CardsGenerator(_cardsImages, new _backImage().bitmapData); | ||
var cards:Vector.<Card> = cardsGenerator.generateRandomCards(16); | ||
var cardsPlacer:ICardsPlacer = new SimpleCardsPlacer(); | ||
cardsPlacer.placeCards(_playGround, cards); | ||
var rulerEngine:RulesEngine = new RulesEngine(_playGround, cards); | ||
} | ||
|
||
private function onCardsImagesLoad(event:Event):void | ||
{ | ||
_cardsImages = CardsImagesLoader(event.target).images; | ||
startNewGame(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package animation | ||
{ | ||
import flash.display.Sprite; | ||
import flash.events.Event; | ||
import flash.events.EventDispatcher; | ||
import flash.events.TimerEvent; | ||
import flash.utils.Timer; | ||
|
||
[Event(name="complete", type="flash.events.Event")] | ||
public class Fade extends EventDispatcher | ||
{ | ||
public function Fade(target:Sprite, time:uint, goDown:Boolean = true) | ||
{ | ||
_goDown = goDown; | ||
_target = target; | ||
_changeFactor = (time / 1000) / target.stage.frameRate; | ||
_animationTimer = new Timer(time, 1); | ||
_animationTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onAnimationEnd); | ||
} | ||
|
||
private var _animationTimer:Timer; | ||
private var _changeFactor:Number; | ||
private var _target:Sprite; | ||
|
||
public function get target():Sprite | ||
{ | ||
return _target; | ||
} | ||
|
||
private var _goDown:Boolean; | ||
|
||
private function onAnimationEnd(event:TimerEvent):void | ||
{ | ||
_target.removeEventListener(Event.ENTER_FRAME, onEnterFrame); | ||
dispatchEvent(new Event(Event.COMPLETE)); | ||
} | ||
|
||
private function onEnterFrame(event:Event):void | ||
{ | ||
if (_goDown) | ||
_target.alpha -= _changeFactor; | ||
else | ||
_target.alpha += _changeFactor; | ||
} | ||
|
||
public function play():void | ||
{ | ||
_animationTimer.start(); | ||
_target.addEventListener(Event.ENTER_FRAME, onEnterFrame); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package engines | ||
{ | ||
import engines.events.CardEvent; | ||
|
||
import flash.display.Bitmap; | ||
import flash.display.BitmapData; | ||
import flash.display.Sprite; | ||
import flash.events.MouseEvent; | ||
import flash.events.TimerEvent; | ||
import flash.utils.Timer; | ||
import flash.utils.setTimeout; | ||
|
||
[Event(name="cardOpen", type="engines.events.CardEvent")] | ||
[Event(name="cardClose", type="engines.events.CardEvent")] | ||
public class Card extends Sprite | ||
{ | ||
public function Card(front:BitmapData, back:BitmapData) | ||
{ | ||
_front = front; | ||
_back = back; | ||
|
||
initBitmap(); | ||
buttonMode = true; | ||
addEventListener(MouseEvent.CLICK, onCardClick); | ||
_closeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onCloseTimerComplete); | ||
} | ||
|
||
public var destroying:Boolean = false; | ||
|
||
private var _back:BitmapData; | ||
private var _front:BitmapData; | ||
|
||
private var _image:Bitmap; | ||
private var _isOpen:Boolean = false; | ||
|
||
private const _closeTime:uint = 1000; | ||
private var _closeTimer:Timer = new Timer(_closeTime, 1); | ||
|
||
public function close():void | ||
{ | ||
_image.bitmapData = _back; | ||
_isOpen = false; | ||
dispatchEvent(new CardEvent(CardEvent.CARD_CLOSE)); | ||
} | ||
|
||
public function get front():BitmapData | ||
{ | ||
return _front; | ||
} | ||
|
||
public function open():void | ||
{ | ||
_image.bitmapData = _front; | ||
_isOpen = true; | ||
dispatchEvent(new CardEvent(CardEvent.CARD_OPEN)); | ||
// | ||
_closeTimer.start(); | ||
} | ||
|
||
public function destroy():void | ||
{ | ||
// | ||
} | ||
|
||
private function initBitmap():void | ||
{ | ||
_image = new Bitmap(_back); | ||
addChild(_image); | ||
} | ||
|
||
private function onCardClick(event:MouseEvent):void | ||
{ | ||
if (!_isOpen) | ||
open(); | ||
} | ||
|
||
private function onCloseTimerComplete(event:TimerEvent):void | ||
{ | ||
if (!destroying) | ||
close(); | ||
} | ||
} | ||
} |
Oops, something went wrong.