made it simpler...and working
This commit is contained in:
parent
52105472d0
commit
a2db062d07
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
*~
|
*~
|
||||||
*.n
|
*.n
|
||||||
*.swf
|
*.swf
|
||||||
|
.DS_Store
|
||||||
|
@ -1,17 +1,90 @@
|
|||||||
|
import flash.MovieClip;
|
||||||
|
|
||||||
class HubbleSiteDailyImageChumby {
|
class HubbleSiteDailyImageChumby {
|
||||||
|
private static var imageHolder:MovieClip;
|
||||||
|
private static var logoHolder:MovieClip;
|
||||||
|
private static var myClip:MovieClip;
|
||||||
|
private static var logoWidth:Int = 280;
|
||||||
|
|
||||||
static public function main() {
|
static public function main() {
|
||||||
var xml:Xml = Xml.createElement("gallery");
|
var initialized:Bool = false;
|
||||||
var myClip:flash.MovieClip = flash.Lib.current;
|
|
||||||
|
myClip = flash.Lib.current;
|
||||||
var t:flash.TextField = myClip.createTextField("test", 1, 0, 0, 200, 200);
|
|
||||||
|
myClip.onEnterFrame = function() {
|
||||||
flash.XMLRequest.load('http://hubblesite.org/gallery/album/daily_image.php',
|
initialized = true;
|
||||||
xml,
|
myClip.onEnterFrame = function():Void {};
|
||||||
onData
|
loadLogo();
|
||||||
);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadImage() {
|
||||||
|
imageHolder = myClip.createEmptyMovieClip("imageholder", myClip.getNextHighestDepth());
|
||||||
|
|
||||||
|
var loadVars = new flash.LoadVars();
|
||||||
|
loadVars.onData = function(s:String) {
|
||||||
|
var xmlfast = new haxe.xml.Fast(Xml.parse(s).firstElement());
|
||||||
|
|
||||||
|
var loader:flash.MovieClipLoader = new flash.MovieClipLoader();
|
||||||
|
loader.onLoadComplete = function(target:MovieClip) {
|
||||||
|
target.onEnterFrame = function() {
|
||||||
|
target._alpha = 0;
|
||||||
|
if (target._width > target._height) {
|
||||||
|
var newHeight:Float = (target._height * flash.Stage.width) / target._width;
|
||||||
|
target._width = flash.Stage.width;
|
||||||
|
target._y = (flash.Stage.height - newHeight) / 2;
|
||||||
|
target._height = newHeight;
|
||||||
|
} else {
|
||||||
|
var newWidth:Float = (target._width * flash.Stage.height) / target._height;
|
||||||
|
target._height = flash.Stage.height;
|
||||||
|
target._x = (flash.Stage.width - newWidth) / 2;
|
||||||
|
target._width = newWidth;
|
||||||
|
}
|
||||||
|
target.onEnterFrame = function() {};
|
||||||
|
|
||||||
|
fadeIn(target, function(){});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loader.loadClip(xmlfast.node.image_url.innerHTML, imageHolder);
|
||||||
|
}
|
||||||
|
loadVars.load('http://hubblesite.org/gallery/album/daily_image.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadLogo() {
|
||||||
|
logoHolder = myClip.createEmptyMovieClip("logoholder", myClip.getNextHighestDepth());
|
||||||
|
|
||||||
|
var loader:flash.MovieClipLoader = new flash.MovieClipLoader();
|
||||||
|
loader.onLoadComplete = function(target:MovieClip) {
|
||||||
|
target.onEnterFrame = function() {
|
||||||
|
target.onEnterFrame = function() {};
|
||||||
|
|
||||||
|
var newHeight:Float = (target._height * logoWidth) / target._width;
|
||||||
|
target._width = logoWidth;
|
||||||
|
target._x = (flash.Stage.width - logoWidth) / 2;
|
||||||
|
target._y = (flash.Stage.height - newHeight) / 2;
|
||||||
|
target._height = newHeight;
|
||||||
|
|
||||||
|
fadeIn(target, function() {
|
||||||
|
var t:haxe.Timer = new haxe.Timer(1500);
|
||||||
|
t.run = function() {
|
||||||
|
t.stop();
|
||||||
|
loadImage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loader.loadClip("http://hubblesite.org/gallery/graphics/gallery_nav_logo.gif", logoHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fadeIn(target:MovieClip, c:Void->Void) {
|
||||||
|
var timer:haxe.Timer = new haxe.Timer(40);
|
||||||
|
target._alpha = 0;
|
||||||
|
timer.run = function() {
|
||||||
|
target._alpha += 10;
|
||||||
|
if (target._alpha >= 100) {
|
||||||
|
timer.stop();
|
||||||
|
c();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static private function onData(data : Null<String>):Void {
|
|
||||||
trace("made it here");
|
|
||||||
}
|
|
||||||
}
|
}
|
6
Makefile
6
Makefile
@ -1,6 +0,0 @@
|
|||||||
test: force_look
|
|
||||||
haxe test.hxml && neko HubbleSiteDailyImageChumbyTestRunner.n
|
|
||||||
rm HubbleSiteDailyImageChumbyTestRunner.n
|
|
||||||
|
|
||||||
force_look:
|
|
||||||
true
|
|
@ -1,5 +0,0 @@
|
|||||||
class XMLReader {
|
|
||||||
public function new() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
5
swf.hxml
Normal file
5
swf.hxml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
-main HubbleSiteDailyImageChumby
|
||||||
|
-swf chumby.swf
|
||||||
|
-D network-sandbox
|
||||||
|
-sef-version 7
|
||||||
|
-swf-header 320:240:12:000000
|
@ -1,4 +0,0 @@
|
|||||||
-main HubbleSiteDailyImageChumbyTestRunner
|
|
||||||
-neko HubbleSiteDailyImageChumbyTestRunner.n
|
|
||||||
-cp classes
|
|
||||||
-cp test
|
|
@ -1,7 +0,0 @@
|
|||||||
class HubbleSiteDailyImageChumbyTestRunner {
|
|
||||||
static function main() {
|
|
||||||
var r = new haxe.unit.TestRunner();
|
|
||||||
r.add(new RemoteXMLReaderTest());
|
|
||||||
r.run();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
class RemoteXMLReaderTest extends haxe.unit.TestCase {
|
|
||||||
private var xr : XMLReader;
|
|
||||||
|
|
||||||
override function setup() {
|
|
||||||
this.xr = new XMLReader();
|
|
||||||
}
|
|
||||||
|
|
||||||
function testParseXML() {
|
|
||||||
assertTrue(true);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user