Skip to content

Commit c5b2fa2

Browse files
committed
Embed pix
1 parent c096db7 commit c5b2fa2

File tree

8 files changed

+92
-20
lines changed

8 files changed

+92
-20
lines changed

.actionScriptProperties

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<actionScriptProperties analytics="false" mainApplicationPath="soundracer2.as" projectUUID="ab442b27-e3a1-4a0c-88d4-13e1e63140aa" version="10">
33
<compiler additionalCompilerArguments="-locale en_US" autoRSLOrdering="true" copyDependentFiles="true" fteInMXComponents="false" generateAccessible="true" htmlExpressInstall="true" htmlGenerate="true" 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">
4-
<compilerSourcePath/>
4+
<compilerSourcePath>
5+
<compilerSourcePathEntry kind="1" linkType="1" path="assets"/>
6+
</compilerSourcePath>
57
<libraryPath defaultLinkType="0">
68
<libraryPathEntry kind="4" path="">
79
<excludedEntries>
@@ -11,19 +13,24 @@
1113
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/qtp.swc" useDefaultLinkType="false"/>
1214
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_air.swc" useDefaultLinkType="false"/>
1315
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/charts.swc" useDefaultLinkType="false"/>
14-
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/framework.swc" useDefaultLinkType="false"/>
16+
<libraryPathEntry applicationDomain="default" forceLoad="false" index="3" kind="3" linkType="4" path="${PROJECT_FRAMEWORKS}/libs/framework.swc" useDefaultLinkType="true">
17+
<crossDomainRsls>
18+
<crossDomainRslEntry autoExtract="true" policyFileUrl="http://fpdownload.adobe.com/pub/swz/crossdomain.xml" rslUrl="http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/framework_4.6.0.23201.swz"/>
19+
<crossDomainRslEntry autoExtract="true" policyFileUrl="" rslUrl="framework_4.6.0.23201.swz"/>
20+
</crossDomainRsls>
21+
</libraryPathEntry>
1522
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/mx/mx.swc" useDefaultLinkType="false"/>
1623
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/netmon.swc" useDefaultLinkType="false"/>
1724
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/spark.swc" useDefaultLinkType="false"/>
1825
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/sparkskins.swc" useDefaultLinkType="false"/>
1926
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/rpc.swc" useDefaultLinkType="false"/>
27+
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/videoPlayer.swc" useDefaultLinkType="false"/>
2028
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/datavisualization.swc" useDefaultLinkType="false"/>
2129
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/qtp_air.swc" useDefaultLinkType="false"/>
22-
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/videoPlayer.swc" useDefaultLinkType="false"/>
2330
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/spark_dmv.swc" useDefaultLinkType="false"/>
2431
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation.swc" useDefaultLinkType="false"/>
25-
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_dmv.swc" useDefaultLinkType="false"/>
2632
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/flash-integration.swc" useDefaultLinkType="false"/>
33+
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_dmv.swc" useDefaultLinkType="false"/>
2734
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_flashflexkit.swc" useDefaultLinkType="false"/>
2835
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_agent.swc" useDefaultLinkType="false"/>
2936
</excludedEntries>

.flexProperties

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<flexProperties enableServiceManager="false" flexServerFeatures="0" flexServerType="0" toolCompile="true" useServerFlexSDK="false" version="2"/>
33

4+

assets/config/pieces.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<game_pieces>
3-
<collision_obj image="parrotOnGrass.jpg" off_image="parrotOnGrass.jpg" audio="beep.mp3" channel="4"
3+
<collision_obj image="lives.png" off_image="snake.png" audio="beep.mp3" channel="4"
44
role="decrease_vol" life="-1" points="40"/>
5-
<collision_obj image="parrotOnGrass.jpg" off_image="parrotOnGrass.jpg" audio="beep.mp3" channel="5"
5+
<collision_obj image="penguin.png" off_image="car_sprites.png" audio="beep.mp3" channel="5"
66
role="pan_left" life="1" points="4000"/>
77
</game_pieces>

src/model/CollisionObj.as

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package model
33
import flash.display.Loader;
44
import flash.media.Sound;
55

6+
import org.flixel.FlxSprite;
7+
68
public class CollisionObj
79
{
810
public static const ROLE_PLAY : String = "PLAY";
@@ -12,12 +14,11 @@ package model
1214
public static const ROLE_PAN_LEFT : String = "LEFT";
1315
public static const ROLE_PAN_RIGHT : String = "LEFT";
1416

15-
public var isOn : Boolean;
16-
public var onImage : Loader;
17+
public var onImage : Class;
1718
/**
1819
* Optional arg if the image changes based on whether it's been hit
1920
*/
20-
public var offImage : Loader;
21+
public var offImage : Class;
2122
/**
2223
* Which channel (track in MusicManager) is effected by collision
2324
*/

src/model/Game.as

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package model
22
{
33
import flash.events.Event;
4+
import flash.events.EventDispatcher;
45
import flash.net.URLLoader;
56
import flash.net.URLRequest;
67
import flash.utils.Timer;
78

8-
public class Game
9+
public class Game extends EventDispatcher
910
{
1011
public var lapDuration : int;
1112
public var lapTimer : Timer;
@@ -40,9 +41,11 @@ package model
4041
if (String(configXml.name().localName).toLowerCase() == MUSIC_XML_NAME) {
4142
musicManager = new MusicManager(configXml);
4243
lapDuration = parseInt(configXml.duration);
44+
if (pieceLibrary) dispatchEvent(new Event(Event.COMPLETE));
4345
}
4446
else if (String(configXml.name().localName).toLowerCase() == GAME_XML_NAME) {
4547
pieceLibrary = new PieceLibrary(configXml);
48+
if (musicManager) dispatchEvent(new Event(Event.COMPLETE));
4649
}
4750
else {
4851
trace("Unkonwn tag: " + configXml.name());

src/model/PieceLibrary.as

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package model
22
{
3-
import flash.display.Loader;
4-
import flash.events.Event;
53
import flash.media.Sound;
64
import flash.net.URLRequest;
75

6+
import sprites.GameAssets;
7+
88
public class PieceLibrary
99
{
1010
public var library : Array = new Array();
@@ -16,16 +16,12 @@ package model
1616
var collisionSpec : XML = configXml.collision_obj[i];
1717

1818
library[i] = collision;
19-
trace(collisionSpec.attribute("image"));
2019
if (collisionSpec.attribute("image").length() > 0) {
21-
var imageLoader :Loader = new Loader();
22-
imageLoader.load(new URLRequest("images/" + collisionSpec.@image));
23-
collision.onImage = imageLoader;
20+
trace(collisionSpec.@image + GameAssets.getClassByFilename(collisionSpec.@image));
21+
collision.onImage = GameAssets.getClassByFilename(collisionSpec.@image);
2422
}
2523
if (collisionSpec.attribute("off_image").length() > 0) {
26-
var imageLoader2 :Loader = new Loader();
27-
imageLoader2.load(new URLRequest("images/" + collisionSpec.@off_image));
28-
collision.offImage = imageLoader;
24+
collision.offImage = GameAssets.getClassByFilename(collisionSpec.@off_image);
2925
}
3026
if (collisionSpec.attribute("audio").length() > 0) {
3127
collision.audio = new Sound(new URLRequest("sound/" + collisionSpec.@audio));

src/sprites/GameAssets.as

+31
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,37 @@ package sprites
55

66
public class GameAssets
77
{
8+
9+
public static function getClassByFilename( filename : String ) : Class {
10+
switch(filename)
11+
{
12+
case "background.png":
13+
{
14+
return LevelSprite;
15+
break;
16+
}
17+
case "lives.png": { return LivesSprite; break; }
18+
case "snake.png": { return SnakeSprite; break; }
19+
case "penguin.png": { return PenguinSprite; break; }
20+
case "alligator_sprites.png": { return AlligatorSprite; break; }
21+
case "car_sprites.png": { return CarSpriteImage; break; }
22+
case "frog_sprites.png": { return FrogSpriteImage; break; }
23+
case "bonus_sprites.png": { return HomeSpriteImage; break; }
24+
case "tree_1.png": { return LogSpriteImage1; break; }
25+
case "tree_2.png": { return LogSpriteImage2; break; }
26+
case "tree_3.png": { return LogSpriteImage3; break; }
27+
case "truck.png": { return TruckSpriteImage; break; }
28+
case "turtle_2_sprites.png": { return TurtlesSpriteImage; break; }
29+
case "turtle_3_sprites.png": { return TurtlesBSpriteImage; break; }
30+
31+
default:
32+
{
33+
return AlligatorSprite;
34+
break;
35+
}
36+
}
37+
}
38+
839
[Embed(source="assets/background.png")]
940
public static var LevelSprite:Class;
1041

src/states/StartState.as

+34-1
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
package states
22
{
3+
import flash.display.Bitmap;
4+
import flash.events.Event;
35
import flash.events.MouseEvent;
6+
import flash.media.Sound;
47

8+
import model.CollisionObj;
9+
import model.Game;
510

611
import org.flixel.FlxG;
712
import org.flixel.FlxSprite;
813
import org.flixel.FlxState;
914
import org.flixel.FlxText;
1015

11-
import states.PlayState;
1216
import sprites.GameAssets;
1317

18+
import states.PlayState;
19+
1420
public class StartState extends FlxState
1521
{
22+
public var game : Game;
23+
1624
public function StartState()
1725
{
1826
super();
@@ -36,6 +44,31 @@ package states
3644
var title:FlxSprite = new FlxSprite(0, 100, GameAssets.AlligatorSprite);
3745
title.x = (FlxG.width * .5) - (title.width * .5);
3846
add(title);
47+
48+
game = new Game("config/game.xml", "config/pieces.xml");
49+
game.addEventListener(Event.COMPLETE, showGameData);
50+
51+
}
52+
53+
protected function showGameData(event:Event):void
54+
{
55+
add(new FlxText(0, 0, FlxG.width, "Duration: " + game.lapDuration));
56+
var msg : String = "Music Manager: ";
57+
for each (var track : Sound in game.musicManager) {
58+
msg += track.bytesTotal + "bytes ";
59+
}
60+
add(new FlxText(0, 20, FlxG.width, msg));
61+
62+
msg = "Pieces: ";
63+
var y : int = 0;
64+
for each (var obj : CollisionObj in game.pieceLibrary) {
65+
msg += "C" + obj.channel + " Life " + obj.life + " points: " + obj.points + obj.role;
66+
trace(obj.onImage, obj.offImage);
67+
add(new FlxSprite(300, y, obj.onImage));
68+
add(new FlxSprite(500, y, obj.offImage));
69+
y += 200;
70+
}
71+
add(new FlxText(0, 40, FlxG.width, msg));
3972
}
4073

4174
/**

0 commit comments

Comments
 (0)