Go4muze
%Europe/Berlin %672 %2006, 16:08
Ik heb MovieClip met hierin de code van Creating a progress animation for loading SWF and image files (http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001580.html#179821) .
Wat ik echter wil is dat deze afbeelding en preloadbar in de _root wordt getoond (en dus niet in de MovieClip zoals standaard).
Met de afbeelding zelf is het gelukt door this.createEmptyMovieClip("image_mc", 100); te veranderen in _root.createEmptyMovieClip("image_mc", 100); en
image_mcl.loadClip("http://www.helpexamples.com/flash/images/gallery1/images/pic3.jpg", image_mc); te veranderen in image_mcl.loadClip("http://www.helpexamples.com/flash/images/gallery1/images/pic3.jpg", _root.image_mc);.
De preloader op de goede plek zetten wil mij helaas nog niet lukken. Kan iemand daar mee helpen?
De volledige code tot nu toe:
//create clips to hold your content
this.createEmptyMovieClip("progressBar_mc", 0);
progressBar_mc.createEmptyMovieClip("bar_mc", 1);
progressBar_mc.createEmptyMovieClip("stroke_mc", 2);
//use drawing methods to create a progress bar
with (progressBar_mc.stroke_mc) {
lineStyle(0, 0x000000);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
}
with (progressBar_mc.bar_mc) {
beginFill(0xFF0000, 100);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
endFill();
_xscale = 0;
}
progressBar_mc._x = 2;
progressBar_mc._y = 2;
// load progress
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
progressBar_mc.bar_mc._xscale = 0;
};
mclListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
progressBar_mc.bar_mc._xscale = Math.round(bytesLoaded/bytesTotal*100);
};
mclListener.onLoadComplete = function(target_mc:MovieClip) {
progressBar_mc.removeMovieClip();
};
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc._height = 500;
target_mc._width = 700;
};
//Create a clip to hold the image.
_root.createEmptyMovieClip("image_mc", 100);
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
/* Load the image into the clip.
You can change the following URL to a SWF or another image file. */
image_mcl.loadClip("http://www.helpexamples.com/flash/images/gallery1/images/pic3.jpg", _root.image_mc);
Wat ik echter wil is dat deze afbeelding en preloadbar in de _root wordt getoond (en dus niet in de MovieClip zoals standaard).
Met de afbeelding zelf is het gelukt door this.createEmptyMovieClip("image_mc", 100); te veranderen in _root.createEmptyMovieClip("image_mc", 100); en
image_mcl.loadClip("http://www.helpexamples.com/flash/images/gallery1/images/pic3.jpg", image_mc); te veranderen in image_mcl.loadClip("http://www.helpexamples.com/flash/images/gallery1/images/pic3.jpg", _root.image_mc);.
De preloader op de goede plek zetten wil mij helaas nog niet lukken. Kan iemand daar mee helpen?
De volledige code tot nu toe:
//create clips to hold your content
this.createEmptyMovieClip("progressBar_mc", 0);
progressBar_mc.createEmptyMovieClip("bar_mc", 1);
progressBar_mc.createEmptyMovieClip("stroke_mc", 2);
//use drawing methods to create a progress bar
with (progressBar_mc.stroke_mc) {
lineStyle(0, 0x000000);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
}
with (progressBar_mc.bar_mc) {
beginFill(0xFF0000, 100);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
endFill();
_xscale = 0;
}
progressBar_mc._x = 2;
progressBar_mc._y = 2;
// load progress
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
progressBar_mc.bar_mc._xscale = 0;
};
mclListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
progressBar_mc.bar_mc._xscale = Math.round(bytesLoaded/bytesTotal*100);
};
mclListener.onLoadComplete = function(target_mc:MovieClip) {
progressBar_mc.removeMovieClip();
};
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc._height = 500;
target_mc._width = 700;
};
//Create a clip to hold the image.
_root.createEmptyMovieClip("image_mc", 100);
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
/* Load the image into the clip.
You can change the following URL to a SWF or another image file. */
image_mcl.loadClip("http://www.helpexamples.com/flash/images/gallery1/images/pic3.jpg", _root.image_mc);