working again, yay

This commit is contained in:
John Bintz 2009-06-11 15:41:43 -04:00
parent a2db062d07
commit b1063616cd
2 changed files with 91 additions and 36 deletions

View File

@ -5,6 +5,8 @@ class HubbleSiteDailyImageChumby {
private static var logoHolder:MovieClip; private static var logoHolder:MovieClip;
private static var myClip:MovieClip; private static var myClip:MovieClip;
private static var logoWidth:Int = 280; private static var logoWidth:Int = 280;
private static var xmlFast:haxe.xml.Fast;
private static var textBlock:flash.TextField;
static public function main() { static public function main() {
var initialized:Bool = false; var initialized:Bool = false;
@ -18,36 +20,40 @@ class HubbleSiteDailyImageChumby {
} }
} }
public static function loadXml() {
var loadVars = new flash.LoadVars();
loadVars.onData = function(s:String) {
xmlFast = new haxe.xml.Fast(Xml.parse(s).firstElement());
showTitle();
}
loadVars.load('http://hubblesite.org/gallery/album/daily_image.php');
}
public static function loadImage() { public static function loadImage() {
imageHolder = myClip.createEmptyMovieClip("imageholder", myClip.getNextHighestDepth()); imageHolder = myClip.createEmptyMovieClip("imageholder", myClip.getNextHighestDepth());
var loadVars = new flash.LoadVars(); var loader:flash.MovieClipLoader = new flash.MovieClipLoader();
loadVars.onData = function(s:String) { loader.onLoadComplete = function(target:MovieClip) {
var xmlfast = new haxe.xml.Fast(Xml.parse(s).firstElement()); target.onEnterFrame = function() {
target._alpha = 0;
var loader:flash.MovieClipLoader = new flash.MovieClipLoader(); if (target._width > target._height) {
loader.onLoadComplete = function(target:MovieClip) { var newHeight:Float = (target._height * flash.Stage.width) / target._width;
target.onEnterFrame = function() { target._width = flash.Stage.width;
target._alpha = 0; target._y = (flash.Stage.height - newHeight) / 2;
if (target._width > target._height) { target._height = newHeight;
var newHeight:Float = (target._height * flash.Stage.width) / target._width; } else {
target._width = flash.Stage.width; var newWidth:Float = (target._width * flash.Stage.height) / target._height;
target._y = (flash.Stage.height - newHeight) / 2; target._height = flash.Stage.height;
target._height = newHeight; target._x = (flash.Stage.width - newWidth) / 2;
} else { target._width = newWidth;
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(){});
} }
textBlock._visible = false;
fadeIn(target, function(){});
target.onEnterFrame = function() {};
} }
loader.loadClip(xmlfast.node.image_url.innerHTML, imageHolder);
} }
loadVars.load('http://hubblesite.org/gallery/album/daily_image.php'); loader.loadClip(xmlFast.node.image_url.innerHTML, imageHolder);
} }
public static function loadLogo() { public static function loadLogo() {
@ -68,23 +74,72 @@ class HubbleSiteDailyImageChumby {
var t:haxe.Timer = new haxe.Timer(1500); var t:haxe.Timer = new haxe.Timer(1500);
t.run = function() { t.run = function() {
t.stop(); t.stop();
loadImage(); loadXml();
} }
}); });
} }
} }
loader.loadClip("http://hubblesite.org/gallery/graphics/gallery_nav_logo.gif", logoHolder); loader.loadClip("http://hubblesite.org/gallery/album/graphics/hs_logo_image_ofthe_day.jpg", logoHolder);
}
public static function fade(target:MovieClip, c:Void->Void, ?out:Bool = false) {
var timer:haxe.Timer = new haxe.Timer(40);
if (out) {
target._alpha = 100;
timer.run = function() {
target._alpha -= 10;
if (target._alpha <= 0) {
timer.stop(); c();
}
}
} else {
target._alpha = 0;
timer.run = function() {
target._alpha += 10;
if (target._alpha >= 100) {
timer.stop(); c();
}
}
}
} }
public static function fadeIn(target:MovieClip, c:Void->Void) { public static function fadeIn(target:MovieClip, c:Void->Void) {
var timer:haxe.Timer = new haxe.Timer(40); fade(target, c, false);
target._alpha = 0; }
timer.run = function() {
target._alpha += 10; public static function fadeOut(target:MovieClip, c:Void->Void) {
if (target._alpha >= 100) { fade(target, c, true);
timer.stop(); }
c();
} public static function showTitle() {
} myClip.createTextField("title",
50,
20,
50,
flash.Stage.width - 40,
flash.Stage.height - 100);
textBlock = Reflect.field(myClip, "title");
var textFormat:flash.TextFormat = new flash.TextFormat();
textFormat.align = "center";
textBlock._visible = false;
textBlock.multiline = true;
textBlock.wordWrap = true;
textBlock.selectable = false;
textBlock.html = true;
textBlock.setNewTextFormat(textFormat);
textBlock.htmlText = "<p align='center'><font face='Helvetica' size='22' color='#ffffff'><b>" + xmlFast.node.title.innerHTML + "</b></font></p>";
fadeOut(logoHolder, function() {
textBlock._visible = true;
var t:haxe.Timer = new haxe.Timer(xmlFast.node.title.innerHTML.length * 50);
t.run = function() {
loadImage();
t.stop();
};
});
} }
} }

View File

@ -1,5 +1,5 @@
-main HubbleSiteDailyImageChumby -main HubbleSiteDailyImageChumby
-swf chumby.swf -swf chumby.swf
-D network-sandbox -D network-sandbox
-sef-version 7 -swf-version 7
-swf-header 320:240:12:000000 -swf-header 320:240:12:000000