Resizing bitmaps loaded from XML?

Hey all - it’s been a while. Got into CS3 for a side project at work. I don’t know jack dookie about AS3.0 but I’m trying. I’m sure my code is pretty *******, so if there is a more elegant solution I can find somewhere, let me know!

Thanks!

I am loading some bitmaps into a FLA via XML. I want to re-use the big bitmaps for thumbnails because that’s what I’m told to do (they don’t want to create bitmap thumbnails)

Here is my XML loading code:

[AS]
var myXML:XML = new XML();
XML.ignoreWhitespace = true;
var XML_URL:String = “Untitled-3_en.xml”;
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener(“complete”, xmlLoaded);
function xmlLoaded(event:Event):void {
myXML = XML(myLoader.data);
this.head1.text=myXML.tab[0].headline;
this.box1.htmlText=myXML.tab[0].headline;
this.head2.text=myXML.tab[1].headline;
this.head3.text=myXML.tab[2].headline;
this.head4.text=myXML.tab[3].headline;
this.titleText.htmlText=myXML.title[0];
this.mainText.htmlText=myXML.tab[0].bullet;
this.bkg1.source="…"+myXML.tab[0].bgimage;
this.bkg2.source="…"+myXML.tab[1].bgimage;
this.bkg3.source="…"+myXML.tab[2].bgimage;
this.bkg4.source="…"+myXML.tab[3].bgimage;
this.thumb1.source="…"+myXML.tab[0].bgimage;
this.thumb2.source="…"+myXML.tab[1].bgimage;
this.thumb3.source="…"+myXML.tab[2].bgimage;
this.thumb4.source="…"+myXML.tab[3].bgimage;
}
[/AS]

At this point I’m loading the bitmaps into ScrollPanes, but I’m completely open to better solutions!

Here’s the full AS (WARNING: it’s really ugly right now)

[AS]
import flash.display.Sprite;
import flash.events.MouseEvent;
import fl.transitions.Tween;
import fl.transitions.easing.;
import flash.display.
;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
//
var bkg:String =“zero”;
//

// define functions
function tweener(clip, begin, finish) {
var myTween:Tween = new Tween(clip,“scaleY”,Regular.easeOut,begin,finish,.175,true);
}
function tweenerLeft(clip, begin, finish) {
var myTween2:Tween = new Tween(clip,“x”,Regular.easeOut,begin,finish,.175,true);
}
function tweenerSee(clip, begin, finish) {
var myTween2:Tween = new Tween(clip,“alpha”,Regular.easeInOut,begin,finish,.5,true);
}
function buttonOver(clip, action) {
clip.addEventListener(MouseEvent.ROLL_OVER,action);
}
function buttonOut(clip, action) {
clip.addEventListener(MouseEvent.ROLL_OUT,action);
}
function scaler(prop1,prop2,prop3,prop4,prop5, prop6) {
prop1.scaleY = 1;
prop2.scaleY = 1;
prop3.scaleY = 1;
prop4.scaleY = 1;
prop5.scaleY = 1;
prop6.scaleY = 1;
}
this.thumb1.mask=this.mask1;
this.thumb2.mask=this.mask2;
this.thumb3.mask=this.mask3;
this.thumb4.mask=this.mask4;

this.bkg1.alpha=0;
this.bkg2.alpha=0;
this.bkg3.alpha=0;
this.bkg4.alpha=0;

// begin button actions----------------------------------------------------
this.b1.buttonMode = true;
//
buttonOver(this.b1, b1roll);
//
function b1roll(event:MouseEvent):void {
scaler(this.w2, this.w3, this.w4, this.mask2, this.mask3, this.mask4);
tweener(this.w1,1,1.25);
tweener(this.mask1,1,1.4);
tweenerLeft(this.thumb1, 0, -50);
tweenerSee(this.bkg1,0,1);
if (bkg!=“one”) {
this.mainText.htmlText=myXML.tab[0].bullet;
this.box1.htmlText=myXML.tab[0].headline;
bkg=“one”;
}
}
//
buttonOut(this.b1,b1off);
//
function b1off(event:MouseEvent):void {
tweener(this.w1, 1.25, 1);
tweener(this.mask1, 1.4, 1);
tweenerLeft(this.thumb1, -50, 0);
tweenerSee(this.bkg1,1,0);
}
///////////////////////////////////
this.b2.buttonMode = true;
//
buttonOver(this.b2,b2roll);
//
function b2roll(event:MouseEvent):void {
scaler(this.w1, this.w3, this.w4, this.mask1, this.mask3, this.mask4);
tweener(this.w2, 1, 1.25);
tweener(this.mask2,1,1.4);
tweenerLeft(this.thumb2, 152, 102);
tweenerSee(this.bkg2,0,1);
if (bkg!=“two”) {
this.mainText.htmlText=myXML.tab[1].bullet;
this.box1.htmlText=myXML.tab[1].headline;
bkg=“two”;
}
}
//
buttonOut(this.b2,b2off);
//
function b2off(event:MouseEvent):void {
tweener(this.w2, 1.25, 1);
tweener(this.mask2,1.4,1);
tweenerLeft(this.thumb2, 102, 152);
tweenerSee(this.bkg2,1,0);
}
//////////////////////////////////
this.b3.buttonMode = true;
//
buttonOver(this.b3,b3roll);
//
function b3roll(event:MouseEvent):void {
scaler(this.w1, this.w2, this.w4, this.mask1, this.mask2, this.mask4);
tweener(this.w3, 1, 1.25);
tweener(this.mask3,1,1.4);
tweenerLeft(this.thumb3, 291, 241);
tweenerSee(this.bkg3,0,1);
if (bkg!=“three”) {
this.mainText.htmlText=myXML.tab[2].bullet;
this.box1.htmlText=myXML.tab[2].headline;
bkg=“three”;
}
}
//
buttonOut(this.b3,b3off);
//
function b3off(event:MouseEvent):void {
tweener(this.w3, 1.25, 1);
tweener(this.mask3,1.4,1);
tweenerLeft(this.thumb3, 241, 291);
tweenerSee(this.bkg3,1,0);
}
///////////////////
this.b4.buttonMode = true;
//
buttonOver(this.b4,b4roll);
//
function b4roll(event:MouseEvent):void {
scaler(this.w1, this.w2, this.w3, this.mask1, this.mask2, this.mask3);
tweener(this.w4, 1, 1.25);
tweener(this.mask4,1,1.4);
tweenerLeft(this.thumb4, 430, 380);
tweenerSee(this.bkg4,0,1);
if (bkg!=“four”) {
this.mainText.htmlText=myXML.tab[3].bullet;
this.box1.htmlText=myXML.tab[3].headline;
bkg=“four”;
}
}
//
buttonOut(this.b4,b4off);
//
function b4off(event:MouseEvent):void {
tweener(this.w4, 1.25, 1);
tweener(this.mask4,1.4,1);
tweenerLeft(this.thumb4, 380, 430);
tweenerSee(this.bkg4,1,0);
}
// end button actions---------------------------------------------------
//begin XML actions ----------------------------------------------------
var myXML:XML = new XML();
XML.ignoreWhitespace = true;
var XML_URL:String = “Untitled-3_en.xml”;
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener(“complete”, xmlLoaded);
function xmlLoaded(event:Event):void {
myXML = XML(myLoader.data);
this.head1.text=myXML.tab[0].headline;
this.box1.htmlText=myXML.tab[0].headline;
this.head2.text=myXML.tab[1].headline;
this.head3.text=myXML.tab[2].headline;
this.head4.text=myXML.tab[3].headline;
this.titleText.htmlText=myXML.title[0];
this.mainText.htmlText=myXML.tab[0].bullet;
this.bkg1.source="…"+myXML.tab[0].bgimage;
this.bkg2.source="…"+myXML.tab[1].bgimage;
this.bkg3.source="…"+myXML.tab[2].bgimage;
this.bkg4.source="…"+myXML.tab[3].bgimage;
this.thumb1.source="…"+myXML.tab[0].bgimage;
this.thumb2.source="…"+myXML.tab[1].bgimage;
this.thumb3.source="…"+myXML.tab[2].bgimage;
this.thumb4.source="…"+myXML.tab[3].bgimage;
}
/*var rect:Sprite = new Sprite();
rect.graphics.beginFill(0xFFFFFF);
rect.graphics.drawRect(50, 50, 400, 400);
addChild(rect);
var ldr:Loader = new Loader();
//ldr.mask = rect;
var url:String = “thumb2.jpg”;
var urlReq:URLRequest = new URLRequest(url);
ldr.load(urlReq);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded1);
addChild(ldr);

function loaded1(event:Event):void {
var content:Bitmap = event.target.content;
content.scaleX = .35;
content.scaleY = .35;
//content.x = 155;
//content.y = 160;
//content.mask=this.mask2;
}
*/

// end XML actions ----------------------------------------------------
[/AS]