Permalink
Browse files

youttutuuututeutetu

  • Loading branch information...
1 parent f648572 commit f23c131a12d49ca0d80978bba8d0b2fce062dc7e @Saqoosha committed Feb 27, 2012
View
@@ -36,13 +36,13 @@ package sh.saqoo.display {
private static var _delayResized:Signal;
private static var _clicked:NativeRelaySignal;
private static var _doubleClicked:NativeRelaySignal;
- private static var _mouseDowned:NativeRelaySignal;
- private static var _mouseUpped:NativeRelaySignal;
+ private static var _mousePressed:NativeRelaySignal;
+ private static var _mouseReleased:NativeRelaySignal;
private static var _mouseMoved:NativeRelaySignal;
private static var _mouseWheeled:NativeRelaySignal;
private static var _mouseLeft:NativeRelaySignal;
- private static var _keyDowned:NativeRelaySignal;
- private static var _keyUpped:NativeRelaySignal;
+ private static var _keyPressed:NativeRelaySignal;
+ private static var _keyReleased:NativeRelaySignal;
public static function init(stage:flash.display.Stage, scaleMode:String = StageScaleMode.NO_SCALE, align:String = StageAlign.TOP_LEFT, quality:String = StageQuality.HIGH):void {
@@ -206,15 +206,15 @@ package sh.saqoo.display {
}
- public static function get mouseDowned():NativeRelaySignal {
+ public static function get mousePressed():NativeRelaySignal {
_checkRef();
- return _mouseDowned ||= new NativeRelaySignal(_ref, MouseEvent.MOUSE_DOWN, MouseEvent);
+ return _mousePressed ||= new NativeRelaySignal(_ref, MouseEvent.MOUSE_DOWN, MouseEvent);
}
- public static function get mouseUpped():NativeRelaySignal {
+ public static function get mouseReleased():NativeRelaySignal {
_checkRef();
- return _mouseUpped ||= new NativeRelaySignal(_ref, MouseEvent.MOUSE_UP, MouseEvent);
+ return _mouseReleased ||= new NativeRelaySignal(_ref, MouseEvent.MOUSE_UP, MouseEvent);
}
@@ -236,15 +236,15 @@ package sh.saqoo.display {
}
- public static function get keyDowned():NativeRelaySignal {
+ public static function get keyPressed():NativeRelaySignal {
_checkRef();
- return _keyDowned ||= new NativeRelaySignal(_ref, KeyboardEvent.KEY_DOWN, KeyboardEvent);
+ return _keyPressed ||= new NativeRelaySignal(_ref, KeyboardEvent.KEY_DOWN, KeyboardEvent);
}
- public static function get keyUpped():NativeRelaySignal {
+ public static function get keyReleased():NativeRelaySignal {
_checkRef();
- return _keyUpped ||= new NativeRelaySignal(_ref, KeyboardEvent.KEY_UP, KeyboardEvent);
+ return _keyReleased ||= new NativeRelaySignal(_ref, KeyboardEvent.KEY_UP, KeyboardEvent);
}
}
}
@@ -72,7 +72,7 @@ package sh.saqoo.format.fbx {
tokenizer.parseError( "Expecting key but found " + token.value );
}
- root = parseChildren(new FBXNode() );
+ root = parseChildren( new FBXNode() );
// Make sure the input stream is empty
if ( nextToken() != null )
@@ -0,0 +1,77 @@
+package sh.saqoo.geom {
+
+ import flash.geom.Vector3D;
+
+ /**
+ * @author Saqoosha
+ */
+ public class Quaternion {
+
+
+ public static const EPS:Number = 1e-8;
+
+
+ /**
+ * @see https://github.com/Papervision3D/Papervision3D/blob/master/src/org/papervision3d/core/math/Quaternion.as#L390
+ */
+ public static function slerp(a:Vector3D, b:Vector3D, alpha:Number, out:Vector3D = null):Vector3D {
+ out ||= new Vector3D();
+
+ var ax:Number, ay:Number, az:Number, aw:Number;
+ var bx:Number, by:Number, bz:Number, bw:Number;
+
+ var angle:Number = a.w * b.w + a.x * b.x + a.y * b.y + a.z * b.z;
+ if (angle < 0.0) {
+ ax = a.x * -1.0;
+ ay = a.y * -1.0;
+ az = a.z * -1.0;
+ aw = a.w * -1.0;
+ angle *= -1.0;
+ } else {
+ ax = a.x;
+ ay = a.y;
+ az = a.z;
+ aw = a.w;
+ }
+
+ var scale:Number;
+ var invscale:Number;
+
+ if (angle + 1.0 > EPS) { // Take the shortest path
+ bx = b.x;
+ by = b.y;
+ bz = b.z;
+ bw = b.w;
+
+ if (1.0 - angle >= EPS) { // spherical interpolation
+ var theta:Number = Math.acos(angle);
+ var invsintheta:Number = 1.0 / Math.sin(theta);
+ scale = Math.sin(theta * (1.0 - alpha)) * invsintheta;
+ invscale = Math.sin(theta * alpha) * invsintheta;
+ } else { // linear interploation
+ scale = 1.0 - alpha;
+ invscale = alpha;
+ }
+
+ } else { // long way to go...
+ by = -ay;
+ bx = ax;
+ bw = -aw;
+ bz = az;
+
+ scale = Math.sin(Math.PI * (0.5 - alpha));
+ invscale = Math.sin(Math.PI * alpha);
+ }
+
+ out.x = scale * ax + invscale * bx;
+ out.y = scale * ay + invscale * by;
+ out.z = scale * az + invscale * bz;
+ out.w = scale * aw + invscale * bw;
+ if (isNaN(out.x)) {
+ throw new Error('something wrong!!!!!!!!!!!!!!!!');
+ }
+
+ return out;
+ }
+ }
+}
View
@@ -1,6 +1,7 @@
package sh.saqoo.math {
import flash.geom.Point;
+ import flash.geom.Vector3D;
public class MathUtil {
@@ -23,7 +24,7 @@ package sh.saqoo.math {
/**
* @see http://www.phys.cs.is.nagoya-u.ac.jp/~watanabe/pdf/prob.pdf
*/
- public static function randomPointInCircle(radius:Number, center:Point = null):Point {
+ public static function randomInCircle(radius:Number, center:Point = null):Point {
var th:Number = Math.random() * Math.PI * 2;
var r:Number = Math.sqrt(Math.random()) * radius;
var p:Point = new Point(Math.cos(th) * r, Math.sin(th) * r);
@@ -33,5 +34,44 @@ package sh.saqoo.math {
}
return p;
}
+
+
+ /**
+ * @see http://www.phys.cs.is.nagoya-u.ac.jp/~watanabe/pdf/prob.pdf
+ */
+ public static function randomOnSphereSurface(radius:Number, center:Vector3D = null):Vector3D {
+ var z:Number = Math.random() * 2 - 1;
+ var zz:Number = Math.sqrt(1 - z * z);
+ var th:Number = Math.random() * Math.PI * 2;
+
+ var v:Vector3D = new Vector3D();
+ v.x = zz * Math.cos(th);
+ v.y = zz * Math.sin(th);
+ v.z = z;
+
+ v.scaleBy(radius);
+ if (center) v.incrementBy(center);
+ return v;
+ }
+
+
+ /**
+ * @see http://www.phys.cs.is.nagoya-u.ac.jp/~watanabe/pdf/prob.pdf
+ */
+ public static function randomInSphere(radius:Number, center:Vector3D = null):Vector3D {
+ var z:Number = Math.random() * 2 - 1;
+ var th:Number = Math.random() * Math.PI * 2;
+ var r:Number = Math.pow(Math.random(), 1 / 3);
+
+ var v:Vector3D = new Vector3D();
+ v.z = r * z;
+ r *= Math.sqrt(1 - z * z);
+ v.x = r * Math.cos(th);
+ v.y = r * Math.sin(th);
+
+ v.scaleBy(radius);
+ if (center) v.incrementBy(center);
+ return v;
+ }
}
}
@@ -5,6 +5,7 @@ package sh.saqoo.minimalcomps {
import com.bit101.components.ComboBox;
import flash.display.DisplayObjectContainer;
+ import flash.events.Event;
/**
* @author Saqoosha
@@ -50,9 +51,12 @@ package sh.saqoo.minimalcomps {
public function get selectedEasing():Function { return selectedItem ? selectedItem.func : Linear.easeNone; }
- public function EasingComboBox(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number = 0) {
+ public function EasingComboBox(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number = 0, defaultHandler:Function = null) {
super(parent, xpos, ypos, EASINGS[0].label, EASINGS);
width = 120;
+ if(defaultHandler != null) {
+ addEventListener(Event.SELECT, defaultHandler);
+ }
}
}
}
View
@@ -48,18 +48,18 @@ package sh.saqoo.net {
//
- private var _gateway:String;
- private var _useNetConnection:Boolean;
- private var _loader:URLLoader;
- private var _isError:Boolean = false;
- protected var _result:Object;
+ protected var _gateway:String;
+ protected var _useNetConnection:Boolean;
+ protected var _loader:URLLoader;
+ protected var _isError:Boolean = false;
+ protected var _result:*;
public function get gateway():String { return _gateway; }
public function set gateway(value:String):void { _gateway = value; }
public function get useNetConnection():Boolean { return _useNetConnection; }
public function set useNetConnection(value:Boolean):void { _useNetConnection = value; }
- public function get result():Object { return _result; }
+ public function get result():* { return _result; }
public function AMFRPC(gateway:String = null, useNetConnection:Boolean = false) {
@@ -125,7 +125,9 @@ package sh.saqoo.net {
private function _onComplete0(result:Object):void {
- dump(result);
+ _result = result;
+ _isError = false;
+ dispatchEvent(new Event(Event.COMPLETE));
}
@@ -19,7 +19,7 @@ package sh.saqoo.signal {
public static function init(listener:Function = null):void {
- Stage.keyDowned.add(_onKeyDown);
+ Stage.keyPressed.add(_onKeyDown);
if (listener is Function) _signal.add(listener);
}
@@ -1,5 +1,6 @@
package sh.saqoo.util {
+ import flash.display.Bitmap;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.InteractiveObject;
@@ -77,5 +78,28 @@ package sh.saqoo.util {
f(object);
for each (var o:InteractiveObject in objs) f(o);
}
+
+
+ public static function setSmoothingAll(container:DisplayObjectContainer, smoothing:Boolean):void {
+ for (var i:int = 0, n:int = container.numChildren; i < n; ++i) {
+ var obj:DisplayObject = container.getChildAt(i);
+ if (obj is Bitmap) {
+ Bitmap(obj).smoothing = smoothing;
+ } else if (obj is DisplayObjectContainer) {
+ setSmoothingAll(DisplayObjectContainer(obj), smoothing);
+ }
+ }
+ }
+
+
+ public static function dumpTree(container:DisplayObjectContainer, padding:String = ''):void {
+ for (var i:int = 0, n:int = container.numChildren; i < n; ++i) {
+ var obj:DisplayObject = container.getChildAt(i);
+ trace(padding + obj);
+ if (obj is DisplayObjectContainer) {
+ dumpTree(DisplayObjectContainer(obj), padding + ' ');
+ }
+ }
+ }
}
}
@@ -1,4 +1,5 @@
package sh.saqoo.youtube {
+
import sh.saqoo.logging.dump;
import flash.display.Loader;
@@ -62,6 +63,26 @@ package sh.saqoo.youtube {
}
+ //----- Queueing function for lists
+
+ public function cuePlaylist(playlist:*, index:Number = 0, startSeconds:Number = 0, suggestedQuality:String = 'default'):void {
+ _player.cuePlaylist(playlist, index, startSeconds, suggestedQuality);
+ }
+
+ public function loadPlaylist(playlist:*, index:Number = 0, startSeconds:Number = 0, suggestedQuality:String = 'default'):void {
+ _player.loadPlaylist(playlist, index, startSeconds, suggestedQuality);
+ }
+
+
+ //----- Playing a video in a playlist -----
+
+ public function nextVideo():void { _player.nextVideo(); }
+
+ public function previousVideo():void { _player.previousVideo(); }
+
+ public function playVideoAt(index:int):void { _player.playVideoAt(index); }
+
+
//----- Changing the player volume -----
public function mute():void { _player.mute(); }
@@ -80,6 +101,13 @@ package sh.saqoo.youtube {
public function setSize(width:Number, height:Number):void { _player.setSize(width, height); }
+ //----- Setting playback behavior for playlists -----
+
+ public function setLoop(loopPlaylists:Boolean):void { _player.setLoop(loopPlaylists); }
+
+ public function setShuffle(shufflePlaylists:Boolean):void { _player.setShuffle(shufflePlaylists); }
+
+
//----- Playback status -----
public function getVideoBytesLoaded():Number { return _player.getVideoBytesLoaded(); }
@@ -111,6 +139,13 @@ package sh.saqoo.youtube {
public function getVideoEmbedCode():String { return _player.getVideoEmbedCode(); }
+ //----- Retrieving playlist information -----
+
+ public function getPlaylist():Array { return _player.getPlaylist(); }
+
+ public function getPlaylistIndex():int { return _player.getPlaylistIndex(); }
+
+
//----- Special Functions -----
public function destroy():void { _player.destroy(); }

0 comments on commit f23c131

Please sign in to comment.