Browse files

Cleaned up build some more and added better support for changing scre…

…en resolution. Also added compiler var for mobile.
  • Loading branch information...
1 parent 0f0f636 commit c7e99e68ad1093cfcb34aea04e13727043240c00 @jessefreeman jessefreeman committed Jun 18, 2010
Showing with 46 additions and 41 deletions.
  1. +1 −0 build.xml
  2. +1 −1 build/build-includes/compile-swf.xml
  3. +42 −34 src/BitmapScrollerApp.as
  4. +2 −6 src/com/flashartofwar/BitmapScroller.as
View
1 build.xml
@@ -43,5 +43,6 @@
</target>
<target name="deploy-to-emulator" depends="package-apk,android.deploy-to-emulator" />
+
<target name="deploy-to-phone" depends="package-apk,android.deploy-to-phone" />
</project>
View
2 build/build-includes/compile-swf.xml
@@ -58,7 +58,7 @@
<arg value="-headless-server=true"/>
<arg value="-use-network=false"/>
<arg value="-default-frame-rate=31"/>
-
+ <arg value="-define=CONFIG::mobile,${mobile}"/>
</java>
<echo>[compile] Debug SWF ${project.name.versioned}.swf created successfully</echo>
View
76 src/BitmapScrollerApp.as
@@ -21,15 +21,14 @@ package {
public class BitmapScrollerApp extends Sprite {
protected var preloadList:Array = ["image1.jpg","image2.jpg","image3.jpg","image4.jpg","image5.jpg","image6.jpg","image7.jpg","image8.jpg","image9.jpg","image10.jpg","image11.jpg","image12.jpg","image13.jpg","image14.jpg","image15.jpg","image16.jpg","image17.jpg","image18.jpg","image19.jpg","image20.jpg","image21.jpg","image22.jpg","image23.jpg","image24.jpg","image25.jpg","image26.jpg","image27.jpg","image28.jpg","image29.jpg"];
- protected static const BASE_URL:String = "/images/";
+ protected var baseURL:String = "images/";
protected var currentlyLoading:String;
protected var loader:Loader = new Loader();
private var bitmapScroller:BitmapScroller;
private var scrubber:HSlider;
private var images:Vector.<BitmapData> = new Vector.<BitmapData>();
protected var previewScale:Number = .25;
- private var bitmapDisplay:Bitmap;
- protected var sampleArea:Rectangle = new Rectangle(0, 0, 480, 800);
+ protected var sampleArea:Rectangle;
private var easeScrollBehavior:EaseScrollBehavior;
private var stats:Stats;
private var isMouseDown:Boolean;
@@ -48,16 +47,24 @@ package {
protected function init():void
{
+ sampleArea = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
+
createBitmapScroller();
createScrubber();
createEaseScrollBehavior();
createStats();
- //This method is here for mobile testing
- fingerTouch();
-
- // calls stage resize once to put everything in its correct place
- onStageResize();
+ if(CONFIG::mobile)
+ {
+ baseURL = "/"+baseURL;
+ //This method is here for mobile testing
+ fingerTouch();
+ }
+ else
+ {
+ // calls stage resize once to put everything in its correct place
+ onStageResize();
+ }
// Once everything is set up add stage resize listeners
this.stage.addEventListener(Event.RESIZE, onStageResize);
@@ -69,33 +76,10 @@ package {
{
sampleArea.width = scrubber.width = stage.stageWidth;
+ bitmapScroller.internalSampleArea = sampleArea;
}
- private function fingerTouch():void
- {
- stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
- stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
- stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
- }
-
- private function onMouseDown(event:MouseEvent):void {
- isMouseDown = true;
- }
-
- private function onMouseUp(event:MouseEvent):void {
- isMouseDown = false;
- }
-
- private function onMouseMove(event:MouseEvent):void
- {
- if(isMouseDown){
-
- var percent:Number = event.localX/stage.stageWidth * 100;
- scrubber.value = percent;
- }
- }
-
private function createStats():void {
stats = addChild(new Stats({ bg: 0x000000 })) as Stats;
stats.y = 30;
@@ -164,7 +148,7 @@ package {
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
- loader.load(new URLRequest(BASE_URL + currentlyLoading));
+ loader.load(new URLRequest(baseURL + currentlyLoading));
}
private function onError(event:*):void {
@@ -187,7 +171,6 @@ package {
public function loop():void
{
- //mouseScrollBehavior.calculateTargetPos(mouseX, mouseY);
var percent:Number = scrubber.value / 100;
var s:Number = bitmapScroller.totalWidth;
@@ -200,5 +183,30 @@ package {
bitmapScroller.sampleBitmapData();
}
+ // This is for mobile touch support
+
+ private function fingerTouch():void
+ {
+ stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
+ stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
+ stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
+ }
+
+ private function onMouseDown(event:MouseEvent):void {
+ isMouseDown = true;
+ }
+
+ private function onMouseUp(event:MouseEvent):void {
+ isMouseDown = false;
+ }
+
+ private function onMouseMove(event:MouseEvent):void
+ {
+ if(isMouseDown){
+
+ var percent:Number = event.localX/stage.stageWidth * 100;
+ scrubber.value = percent;
+ }
+ }
}
}
View
8 src/com/flashartofwar/BitmapScroller.as
@@ -62,14 +62,9 @@ package com.flashartofwar
public function sampleBitmapData():void
{
- // We clone this so it will not modify the ordinal sampleArea Rectangle that is passed in
- //internalSampleArea = sampleAreaSrc.clone();
-
- //TODO this needs to be optimized
bitmapData.fillRect(internalSampleArea, 0);
sample(internalSampleArea.clone(), bitmapData);
-
}
protected function init():void
@@ -217,7 +212,8 @@ package com.flashartofwar
public function set internalSampleArea(value:Rectangle):void
{
_internalSampleArea = value;
- bitmapData = new BitmapData(_internalSampleArea.width, _internalSampleArea.height, false, 0x000000)
+ bitmapData = new BitmapData(_internalSampleArea.width, _internalSampleArea.height, false, 0x000000);
+ sampleBitmapData();
}
}
}

0 comments on commit c7e99e6

Please sign in to comment.