Trax
%Europe/Berlin %469 %2009, 12:15
Hi iedereen,
ik heb een site waarbij ik een afbeelding inlaad als achtergrond én die afbeelding wordt gesmooth. Wel, dit was al een opgave maar nu rest er me nog één ding. Hoe kan ik nu die afbeelding proportioneel laten resizen zodat deze zich aanpast aan de grootte van het broswervenster? De code die ik daarvoor vroeger gebruikte werkt niet bij deze methode. Waarom weet ik echter niet. Kan iemand me op het probleem wijzen aub?
Alvast bedankt!
Dit heb ik nu:
Stage.align = "LT";
//Dit is voor de smoothing
import flash.display.*;
function loadBitmapSmoothed(url:String, target:MovieClip) {
// Create a movie clip which will contain our
// unsmoothed bitmap
var bmc:MovieClip = target.createEmptyMovieClip(
"bmc",
target.getNextHighestDepth());
// Create a listener which will notify us when
// the bitmap loaded successfully
var listener:Object = new Object();
// Track the target
listener.tmc = target;
// If the bitmap loaded successfully we redraw the
// movie into a BitmapData object and then attach
// that BitmapData to the target movie clip with
// the smoothing flag turned on.
listener.onLoadInit = function(mc:MovieClip) {
mc._visible = false;
var bitmap:BitmapData = new BitmapData(
mc._width,
mc._height,
true);
this.tmc.attachBitmap(
bitmap,
this.tmc.getNextHighestDepth(),
"auto",
true);
bitmap.draw(mc);
};
// Do it, load the bitmap now
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}
createEmptyMovieClip("myMC",getNextHighestDepth());
loadBitmapSmoothed("test.jpg",myMC);
//Dit is om te resizen
a = this.myMC._width;
b = this.myMC._height;
c = Stage.width/a;
_root.myMC._width = Stage.width;
_root.myMC._height = b*c;
resizeListener = new Object();
resizeListener.onResize = function() {
c = Stage.width/a;
_root.myMC._width = Stage.width;
_root.myMC._height = b*c;
};
Stage.addListener(resizeListener);
stop();
ik heb een site waarbij ik een afbeelding inlaad als achtergrond én die afbeelding wordt gesmooth. Wel, dit was al een opgave maar nu rest er me nog één ding. Hoe kan ik nu die afbeelding proportioneel laten resizen zodat deze zich aanpast aan de grootte van het broswervenster? De code die ik daarvoor vroeger gebruikte werkt niet bij deze methode. Waarom weet ik echter niet. Kan iemand me op het probleem wijzen aub?
Alvast bedankt!
Dit heb ik nu:
Stage.align = "LT";
//Dit is voor de smoothing
import flash.display.*;
function loadBitmapSmoothed(url:String, target:MovieClip) {
// Create a movie clip which will contain our
// unsmoothed bitmap
var bmc:MovieClip = target.createEmptyMovieClip(
"bmc",
target.getNextHighestDepth());
// Create a listener which will notify us when
// the bitmap loaded successfully
var listener:Object = new Object();
// Track the target
listener.tmc = target;
// If the bitmap loaded successfully we redraw the
// movie into a BitmapData object and then attach
// that BitmapData to the target movie clip with
// the smoothing flag turned on.
listener.onLoadInit = function(mc:MovieClip) {
mc._visible = false;
var bitmap:BitmapData = new BitmapData(
mc._width,
mc._height,
true);
this.tmc.attachBitmap(
bitmap,
this.tmc.getNextHighestDepth(),
"auto",
true);
bitmap.draw(mc);
};
// Do it, load the bitmap now
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}
createEmptyMovieClip("myMC",getNextHighestDepth());
loadBitmapSmoothed("test.jpg",myMC);
//Dit is om te resizen
a = this.myMC._width;
b = this.myMC._height;
c = Stage.width/a;
_root.myMC._width = Stage.width;
_root.myMC._height = b*c;
resizeListener = new Object();
resizeListener.onResize = function() {
c = Stage.width/a;
_root.myMC._width = Stage.width;
_root.myMC._height = b*c;
};
Stage.addListener(resizeListener);
stop();