XML Preloader
Hi all
I'm going to be faced with trying to load a 3000+ node XML
file into Flash.
With something that big, ideally, I would like to incorporate
some sort of preloader in Flash, so as the XML loads, you can see
its progress.
But I'm wondering if showing load progress for an XML file
will actually work. Its always been my experience that Flash can
only load XML as fast as the XML will load in a browser, but Flash
doesn't show anything loaded until the whole XML is loaded.
There is, in the Flash Help Files, an example of
getBytesLoaded() and getBytesTotal() for XML files, but those don't
seem to work at all.
Searches on Google only come across other people asking the
same questions with little or no answers.
So I'm wondering if this is even possible. Can Flash show the
progress of a loading XML file, before the XML file has finished
loading? If so, where can I find how to do this?
Thanks again for the help
Chris
Like I said, I've started with the method in the Flash 8 help
files:
// create a new XML document
var doc:XML = new XML();
var checkProgress = function(xmlObj:XML) {
var bytesLoaded:Number = xmlObj.getBytesLoaded();
var bytesTotal:Number = xmlObj.getBytesTotal();
var percentLoaded:Number = Math.floor((bytesLoaded /
bytesTotal )*100); //<--funny thing here, they left out the *
before the 100 in the help file, throws up a syntax error
trace ("milliseconds elapsed: " + getTimer());
trace ("bytesLoaded: " + bytesLoaded);
trace ("bytesTotal: " + bytesTotal);
trace ("percent loaded: " + percentLoaded);
trace ("---------------------------------");
doc.onLoad = function(success:Boolean) {
clearInterval(intervalID);
trace("intervalID: " + intervalID);
trace("doc: "+doc);
doc.load("
http://www.helpexamples.com/flash/xml/ds.xml");
//<--Fairly long, publicly available, XML file
var intervalID:Number = setInterval(checkProgress, 100, doc);
The trace results I get when I run this are:
milliseconds elapsed: 545
bytesLoaded: 0
bytesTotal: undefined
percent loaded: NaN
milliseconds elapsed: 711
bytesLoaded: 0
bytesTotal: undefined
percent loaded: NaN
milliseconds elapsed: 877
bytesLoaded: 0
bytesTotal: undefined
percent loaded: NaN
milliseconds elapsed: 1043
bytesLoaded: 0
bytesTotal: undefined
percent loaded: NaN
intervalID: 1
doc = [giant XML file]
So the bytesLoaded and bytesTotal are always 0 and undefined.
kglad, how does your method work?
Thanks again for the help.
Chris
Similar Messages
-
How to load 2 xml galleries in single function loop.
how to load 2 xml galleries in single function loop.
my function is--------
var myGalleryXML = new XML();
myGalleryXML.ignoreWhite = true;
myGalleryXML.load("gallery.xml");
function callThumbs()
_root.createEmptyMovieClip("wall",_root.getNextHighestDepth());
wall._x = _root.gallery_x;
wall._y = _root.gallery_y;
wall.addEventListener(MouseEvent.CLICK);
var clipLoader = new MovieClipLoader();
var preloader = new Object();
clipLoader.addListener(preloader);
for (i =0; i <6; i++)
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = wall.createEmptyMovieClip(i, wall.getNextHighestDepth());
myThumb_mc._x = _root.thumb_height * i;
myThumb_mc._x = _root.thumb_position = -3100 + (i-j) * 765;
clipLoader.loadClip("shop/" + thumbURL,myThumb_mc); // i want to load this by xml gallery "gallery1.xml"
preloader.onLoadStart = function(target)
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);
target.my_txt.selectable = false;
preloader.onLoadProgress = function(target, loadedBytes, totalBytes)
target.my_txt.text = Math.floor((loadedBytes / totalBytes) * 100);
preloader.onLoadComplete = function(target)
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function()
callFullImage(this._name);
target.onRollOver = function()
this._alpha = 100;
target.onRollOut = function()
this._alpha = 100;
for (i = 0; i < 6; i++)
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = wall.createEmptyMovieClip(i, wall.getNextHighestDepth());
myThumb_mc._x = _root.thumb_height * i;
myThumb_mc._x = _root.thumb_position = -7210 + (i-j) * 765;
myThumb_mc._y = _root.thumb_position = 180;
clipLoader.loadClip("banner/" + thumbURL,myThumb_mc); // i want to load this by xml gallery "gallery2.xml"
preloader.onLoadStart = function(target)
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);
target.my_txt.selectable = false;
preloader.onLoadProgress = function(target, loadedBytes, totalBytes)
target.my_txt.text = Math.floor((loadedBytes / totalBytes) * 100);
preloader.onLoadComplete = function(target)
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function()
callFullImage(this._name);
target.onRollOver = function()
this._alpha = 100;
target.onRollOut = function()
this._alpha = 100;combine the two xml files into one if you want to create one gallery.
if you want two different galleries that display at different times, remove the movieclip wall after you're done with gallery1 and execute myGalleryXML.load("gallery2.xml"); -
I'm trying to redesign a Flash web app so that others can use
it for their purposes and update it themselves.
So, the question is: if I change the app to read all content
from an XML file and load JPG backgrounds as dictated by vars in
the XML file - will it slow the loading time down significantly
(compared to the original app in which the FLA was built in the
standard fashion with all string values and images ebedded)?
Thanks, Nathanyes, but that shouldn't be a major issue unless the xml file
is large. and if it is large you can always display an xml
preloader so users are entertained and/or informed while the xml
file is loading. -
XML not showing load progress...
I have a fla file that loads a slide show from an XML file. The xml file contains info about each slide. There's over a 100 slides so the loading takes some time. However I'm not getting actual load progress. It traces nothing until after the load is complete and then it shows the progress that it should have traced one by one, however it traced them all at once on the complete. Because it's not firing the onProgress correctly my preloader is rendered useless. Am I doing something wrong on is this a bug in Flash?
//======================================================================================== =================================================
// load xml
//======================================================================================== =================================================
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.addEventListener(ProgressEvent.PROGRESS, LoadingXML);
function LoadXML(e:Event):void {
trace("complete");
xmlData = new XML(e.target.data);
ParseSlides(xmlData);
xmlLoader.removeEventListener( ProgressEvent.PROGRESS, LoadXML);
xmlLoader.removeEventListener( Event.COMPLETE, LoadingXML);
MovieClip(root).loading_mc.x = 1500;
MovieClip(root).loading_mc.bar.width = 1;
MovieClip(root).loading_mc.loading_txt.text = "";
function LoadingXML(e:ProgressEvent):void {
//trace("Loading..." + Math.ceil(e.bytesLoaded * 100 / e.bytesTotal) + "%");
var loaded:Number = e.target.bytesLoaded;
var total:Number = e.target.bytesTotal;
var pct:Number = loaded / total;
trace(pct);
MovieClip(root).loading_mc.x = 500;
MovieClip(root).loading_mc.bar.width = pct * 194;
MovieClip(root).loading_mc.loading_txt.text = "Loading XML... " + (Math.round(pct * 100)) + "%";
xmlLoader.load(new URLRequest("XML/SectionII.xml"));
HERE IS THE OUTPUT: All at once when the complete fires
0.149821570227718
0.299643140455436
0.44946471068315397
0.599286280910872
0.74910785113859
0.8989294213663079
1
completeActually it still doesn't work like I need it to. The loading of the xml preloader only works if the temporary internet files are gone. Which means that the time I need the loader is during the parsing of the xml process. I have a function that creates an object for each slide after the xml loads. It runs through a for loop, however the loader won't appear and work during the for loop. It only works after its finished.
function ParseSlides(slideInput:XML):void {
// create a list of slide items
var slideList:XMLList = slideInput.Slide;
var slideSize:Number = slideList.length();
var buildPct:Number;
// run through list to build each slide object
for (var i:Number = 0; i < slideList.length(); i++) {
// get progress of building slides
buildPct = Math.ceil(i / slideSize);
MovieClip(root).loading_mc.bar.width = buildPct * loadBarWidth;
MovieClip(root).loading_mc.loading_txt.text = "Building Slides... " + (Math.round(buildPct * 100)) + "%";
// build slide id and name
var idElement:XML = slideInput.Slide.attribute("ID")[i];
var headerElement:XML = slideInput.Slide.header.copy[i];
var headerAnimationElement:XML = slideInput.Slide.header.animation[i];
var headerStartXElement:XML = slideInput.Slide.header.startx[i];
var headerStartYElement:XML = slideInput.Slide.header.starty[i];
var headerFinishXElement:XML = slideInput.Slide.header.finishx[i];
var headerFinishYElement:XML = slideInput.Slide.header.finishy[i];
var headerStartAlphaElement:XML = slideInput.Slide.header.startAlpha[i];
var headerFinishAlphaElement:XML = slideInput.Slide.header.finishAlpha[i];
var headerDelayElement:XML = slideInput.Slide.header.delay[i];
var headerSecondsElement:XML = slideInput.Slide.header.seconds[i];
var subheaderElement:XML = slideInput.Slide.subheader.copy[i];
var subheaderAnimationElement:XML = slideInput.Slide.subheader.animation[i];
var subheaderStartXElement:XML = slideInput.Slide.subheader.startx[i];
var subheaderStartYElement:XML = slideInput.Slide.subheader.starty[i];
var subheaderFinishXElement:XML = slideInput.Slide.subheader.finishx[i];
var subheaderFinishYElement:XML = slideInput.Slide.subheader.finishy[i];
var subheaderStartAlphaElement:XML = slideInput.Slide.subheader.startAlpha[i];
var subheaderFinishAlphaElement:XML = slideInput.Slide.subheader.finishAlpha[i];
var subheaderDelayElement:XML = slideInput.Slide.subheader.delay[i];
var subheaderSecondsElement:XML = slideInput.Slide.subheader.seconds[i];
var audioElement:XML = slideInput.Slide.audio[i];
var videoElement:XML = slideInput.Slide.video[i];
// create new slide object
slide[idElement] = new Object();
slide[idElement].name = idElement;
// set header information
slide[idElement].header = headerElement;
slide[idElement].headerAnimation = headerAnimationElement;
slide[idElement].headerStartX = headerStartXElement;
slide[idElement].headerStartY = headerStartYElement;
slide[idElement].headerFinishX = headerFinishXElement;
slide[idElement].headerFinishY = headerFinishYElement;
slide[idElement].headerStartAlpha = headerStartAlphaElement;
slide[idElement].headerFinishAlpha = headerFinishAlphaElement;
slide[idElement].headerDelay = headerDelayElement;
slide[idElement].headerSeconds = headerSecondsElement;
slide[idElement].subheader = subheaderElement;
slide[idElement].subheaderAnimation = subheaderAnimationElement;
slide[idElement].subheaderStartX = subheaderStartXElement;
slide[idElement].subheaderStartY = subheaderStartYElement;
slide[idElement].subheaderFinishX = subheaderFinishXElement;
slide[idElement].subheaderFinishY = subheaderFinishYElement;
slide[idElement].subheaderStartAlpha = subheaderStartAlphaElement;
slide[idElement].subheaderFinishAlpha = subheaderFinishAlphaElement;
slide[idElement].subheaderDelay = subheaderDelayElement;
slide[idElement].subheaderSeconds = subheaderSecondsElement;
// set the audio in the slide
slide[idElement].audio = audioElement;
// set the video in the slide
slide[idElement].video = videoElement;
// push new slide to the array of slide names
slidesArray.push(slide[idElement].name);
//MovieClip(root).loading_mc.x = 1500;
//MovieClip(root).loading_mc.bar.width = 1;
//MovieClip(root).loading_mc.loading_txt.text = "";
// start slide
buildSlide(); -
Preloader for xml image gallery
Hi,
I am a little stuck as to where to begin; I have created a
photo gallery and now need to add some preloader capability to it.
The images are brought in via XMLList etc... What I have in mind, I
would like to display a preloader untill all the images are ready
for viewing - not wanting to preload individual images one by one
I also have a document class within the gallery swf file, I
beleive that this may cause conflicts with attaching a preloader to
frame 1 - I have tried preloading the gallery swf file via a
preloader.swf; the end result still leaves me with having to
provide a preloader within the gallery swf.
Can anyone point me to any good examples, for me to get on
with it. Any help would be really appreciated folks ;)
Kind Regards,
Boxing BoomHi Kglad,
Thank you for your response: my images are loading sequentially via the following code segment;
//initialize the loader object
loader=new Loader();
//add an onInit event to the contentLoadedInfo
loader.contentLoaderInfo.addEventListener(Event.INIT, onImageLoaded);
//create the fake holder
fakeHolder=new Sprite();
//and add to it the loader
fakeHolder.addChild(loader);
//no need to add it to the stage
//force the resizeHandler to be called
resizeHandler(null);
//Load the XML file
xmlLoader=new URLLoader();
//assign the Complete loading event
xmlLoader.addEventListener(Event.COMPLETE,parseXML);
//load the file
xmlLoader.load(new URLRequest("data.xml"));
//initialize the url request
urlRequest=new URLRequest();
What I would like to do now is preload these,
Would the code to acheive this be:
xmlLoader.addEventListener(ProgressEvent.PROGRESS ,onProgress);
private function onProgress(pe:ProgressEvent):void
// this bit is what I do not understand; i.e. your x/n + bl/(bt*n) fraction example
Any further help on this on, would be really appreciated Kglad.
Kind Regards,
Boxing Boom -
Preloader for xml file and stage assets
I have a Flash app that shows a map with different regions
colored depending on values in an external xml file. I also have a
simple preloader that I want to appear until all the elements of
the app are ready to be displayed. However, when I use the
preloader, the results are the same as if I hadn't use it. My map
comes up immediately with no colors, there is a pause, and then the
colors come in (as calculated from the data in my xml file). Can
anyone tell me what I'm doing wrong? Do I have to have code in my
xml loader that tells the user what percent of the file is
loaded?XML files are really small. If that is all you are loading,
it should happen instantly, or close to it depending on the size.
Also if you are running it on your local machine, it will load very
fast unless you simulate the download.
But incase that is not the issue, your code looks incomplete,
or just headed down the wrong path. You should be useing a loader
class that has a series of events associated with it. Events like
"PROGRESS" and "COMPLETE". These events will fire automatically
when a file loads, and when a file is done loading. The Enter frame
event is not meant to handle loading. I would suggest using a class
like BulkLoader to handle all your loading needs.
http://code.google.com/p/bulk-loader/ -
Flex 4 - is it possible to load xml data into the preloader and pass it to the application?
or is there a similar method to load XML data while the preloader is active, so the XML data will be ready when the main application loads?
i'm having great difficulty finding any relevant info from the forum and the web about accessing preloader variables from the application.
is there a way to access the preloader itself from the application?
It seems logical that the systemManager garbage collects it. If that's the case, how can i access the systemManager from the preloader and possible pass variables to it, then later access them from the application? this seems to be the best direction to tackle this problem. but maybe i'm overlooking another way? -
My web.xml loads on startup first before getting any request to initialise attributes in servlet by fetching from properties file. In Weblogic 8.1 it works fine but not in Weblogic 10.3 while setting attribute its getting null values and throws error in another jsp page.
The actual error is like :
[HTTP:101216]Servlet: "bbbbb" failed to preload on startup in Web application: "aaaaa.war". javax.servlet.ServletException: Error in Log4j File at com.z.y.bbbbb.init(bbbbb.java:49)
Log4j in 10.3 are by default. I changed the configuration from default to Log4j. The application loads successfully if I do vice versa the application fails. If i delete the line load on startup from web.xml the application starts successfully.
Any idea to deal with this situation?
Thanks.
I guess this is new kind of error which very less have came across but it will be a lesson learnt if someone could throw some light as to why such errors are resulted and how it can be prevented.
Thanks a bunch!
Edited by: jennifer123 on Aug 7, 2009 7:38 AM
Hello, Any idea whats goin on?
Edited by: jennifer123 on Aug 12, 2009 1:37 PMContact the Weblogic guys. This problem is unrelated to Servlet API.
All I can do here is to suggest you to get rid of the buggy Weblogic appserver and go for a more robust implementation. For example Tomcat or one of its clones or Glassfish. -
Hey guys,
I've almost finished my flash website for a friend and just want to add a simple MP3 player.
I have the following code which reads an XML file and loads the mp3s referred to in it and plays them... this is all cool...(i've removed the bits for the buttons as i didnt think they were relevant)
what I really really want to be able to do is buffer the MP3 files so that they begin playing when 1/2 loaded or similar (ideally preload 1/2 of track 1, play track 1, when track 1 loading is complete start preloading track 2 etc.)
I just cant work out how to do it...
Any advice would be very gratefully received!
var my_songs:XMLList;
var my_total:Number;
var my_sound:Sound;
var my_channel:SoundChannel;
var current_song:Number = 0;
var song_position:Number;
var song_paused:Boolean;
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("playlist.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
var myXML:XML = new XML(e.target.data);
my_songs = myXML.SONG;
my_total = my_songs.length();
playSong(0); // Simply remove this line to stop automatic playback.
myXMLLoader.removeEventListener(Event.COMPLETE, processXML);
myXMLLoader = null;
function playSong(mySong:Number):void{
var myTitle = my_songs[mySong].@TITLE;
var myArtist = my_songs[mySong].@ARTIST;
var info = myTitle+" - "+myArtist;
var myURL = my_songs[mySong].@URL;
title_txt.text = info;
if (my_channel){
my_channel.stop();
my_channel.removeEventListener(Event.SOUND_COMPLETE, onNext);
my_sound = new Sound();
my_sound.load(new URLRequest(myURL));
my_channel = my_sound.play();
my_channel.addEventListener(Event.SOUND_COMPLETE, onNext);thanks for the help but I now have another error :*(
slightly different error:
ArgumentError: Error #2068: Invalid sound.
at flash.media::Sound/play()
at mp3_fla::MainTimeline/MP3_LOADING()[mp3_fla.MainTimeline::frame1:47]
line 47 is "my_channel = my_sound.play();"
var my_songs:XMLList;
var my_total:Number;
var my_sound:Sound=new Sound();
var my_channel:SoundChannel;
var current_song:Number = 0;
var song_position:Number;
var song_paused:Boolean;
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("playlist.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
var myXML:XML = new XML(e.target.data);
my_songs = myXML.SONG;
my_total = my_songs.length();
playSong(0); // Simply remove this line to stop automatic playback.
myXMLLoader.removeEventListener(Event.COMPLETE, processXML);
myXMLLoader = null;
function playSong(mySong:Number):void{
var myTitle = my_songs[mySong].@TITLE;
var myArtist = my_songs[mySong].@ARTIST;
var info = myTitle+" - "+myArtist;
var myURL = my_songs[mySong].@URL;
title_txt.text = info;
if (my_channel){
my_channel.stop();
my_channel.removeEventListener(Event.SOUND_COMPLETE, onNext);
//my_sound = new Sound();
my_sound.load(new URLRequest(myURL));
this.loaderInfo.addEventListener(
ProgressEvent.PROGRESS, MP3_LOADING
var alreadyStarted:Boolean=false;
function MP3_LOADING(e:ProgressEvent):void {
var loaded:Number =e.bytesLoaded;
var total:Number=e.bytesTotal;
bytes.text=int(loaded*100/total)+"%";
if(loaded*2>=total&&!alreadyStarted){
alreadyStarted=true;
my_channel = my_sound.play();
my_channel.addEventListener(Event.SOUND_COMPLETE, onNext);
next_btn.addEventListener(MouseEvent.CLICK, onNext);
function onNext(e:Event):void{ //This used to have MouseEvent, change it to Event.
current_song++;
if (current_song>=my_total){
current_song=0;
playSong(current_song);
prev_btn.addEventListener(MouseEvent.CLICK, onPrev);
function onPrev(e:MouseEvent):void{
current_song--;
if (current_song<0){
current_song = my_total-1;
playSong(current_song);
pause_btn.addEventListener(MouseEvent.CLICK, onPause);
function onPause(e:MouseEvent):void{
if (my_channel){
song_position = my_channel.position;
my_channel.stop();
song_paused=true;
play_btn.addEventListener(MouseEvent.CLICK, onPlay);
function onPlay(e:MouseEvent):void{
if (song_paused){
my_channel = my_sound.play(song_position);
song_paused=false;
} else if (!my_channel){
playSong(current_song); -
XML slideshow with preloader bar
I'm using the following code to create a simple slideshow:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var my_speed:Number;
var my_count:Number;
var my_images:XMLList;
var my_loaders_array:Array=[];
var my_success_counter:Number=0;
var my_playback_counter:Number=0;
var my_slideshow:Sprite = new Sprite();
var my_image_slides:Sprite = new Sprite();
var my_preloader:TextField;
var my_timer:Timer;
var my_prev_tween:Tween;
var my_tweens_array:Array=[];
var my_xml_loader:URLLoader = new URLLoader();
my_xml_loader.load(new URLRequest("theme1.xml"));
my_xml_loader.addEventListener(Event.COMPLETE, preXML);
next_mc.addEventListener(MouseEvent.CLICK, timerListener);
prev_mc.addEventListener(MouseEvent.CLICK, goBack);
function preXML(e:Event):void {
var my_xml:XML=new XML(e.target.data);
my_speed=my_xml.@SPEED;
my_images=my_xml.IMAGE;
my_count=my_images.length();
loadImages();
my_xml_loader.removeEventListener(Event.COMPLETE, preXML);
my_xml_loader=null;
function loadImages():void {
for (var i:Number = 0; i < my_count; i++) {
var my_url:String=my_images[i].@URL;
var my_loader:Loader = new Loader();
my_loader.load(new URLRequest(my_url));
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
my_loaders_array.push(my_loader);
my_preloader = new TextField();
my_preloader.text="Loading";
my_preloader.autoSize=TextFieldAutoSize.CENTER;
my_preloader.x = (stage.stageWidth - my_preloader.width)/2;
my_preloader.y = (stage.stageHeight - my_preloader.height)/2;
addChild(my_preloader);
function onComplete(e:Event):void {
my_success_counter++;
if (my_success_counter==my_count) {
startShow();
var my_loaderInfo:LoaderInfo=LoaderInfo(e.target);
my_loaderInfo.removeEventListener(Event.COMPLETE, onComplete);
function startShow():void {
removeChild(my_preloader);
my_preloader=null;
addChild(my_slideshow);
my_slideshow.addChild(my_image_slides);
nextImage();
my_timer=new Timer(my_speed*2000);
my_timer.addEventListener(TimerEvent.TIMER, timerListener);
my_timer.start();
function nextImage():void {
var my_image:Loader=Loader(my_loaders_array[my_playback_counter]);
my_image_slides.addChild(my_image);
my_image.x = (stage.stageWidth - my_image.width)/2;
my_image.y = (stage.stageHeight - my_image.height)/2;
my_tweens_array[0]=new Tween(my_image,"alpha",Strong.easeOut,0,1,1,true);
function timerListener(e:Event):void {
hidePrev();
my_playback_counter++;
if (my_playback_counter==my_count) {
my_playback_counter=0;
if(e.currentTarget is MovieClip)
my_timer.reset();
my_timer.start();
nextImage();
function goBack(e:MouseEvent):void
hidePrev();
my_playback_counter--;
if (my_playback_counter<0) {
my_playback_counter=my_count-1;
nextImage();
my_timer.reset();
my_timer.start();
function hidePrev():void {
var my_image:Loader=Loader(my_image_slides.getChildAt(0));
my_prev_tween=new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true);
my_prev_tween.addEventListener(TweenEvent.MOTION_FINISH, onFadeOut);
function onFadeOut(e:TweenEvent):void {
my_image_slides.removeChildAt(0);
I would like change "loading" to a preloader bar. How can i insert a preloader bar in this code? I add this lines:
var total:Number=this.stage.loaderInfo.bytesTotal;
var loaded:Number=this.stage.loaderInfo.bytesLoaded;
var percent:Number=loaded/total;[/b]
my_preloader = new TextField();
my_preloader.text=(Math.round(percent * 100)) + "%";
my_preloader.autoSize=TextFieldAutoSize.CENTER;
my_preloader.x = (stage.stageWidth - my_preloader.width)/2;
my_preloader.y = (stage.stageHeight - my_preloader.height)/2;
addChild(my_preloader);
But only show a static "100%".
Thanks guys!you'll need to change your basic setup from loading all those images in a for-loop to loading them sequentially. so, to start:
var loadIndex:int;
function preXML(e:Event):void {
var my_xml:XML=new XML(e.target.data);
my_speed=my_xml.@SPEED;
my_images=my_xml.IMAGE;
my_count=my_images.length();
loadIndex=0;
loadImages();
my_xml_loader.removeEventListener(Event.COMPLETE, preXML);
my_xml_loader=null;
function loadImages():void {
var i:int=loadIndex;
var my_url:String=my_images[i].@URL;
var my_loader:Loader = new Loader();
my_loader.load(new URLRequest(my_url));
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
my_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
my_loaders_array.push(my_loader);
y_preloader = new TextField();
my_preloader.x = (stage.stageWidth - my_preloader.width)/2;
my_preloader.y = (stage.stageHeight - my_preloader.height)/2;
addChild(my_preloader);
function onProgress(e:ProgressEvent):void{
var total:Number=e.bytesTotal;
var loaded:Number=e.bytesLoaded;
var percent:Number=loaded/total;[/b]
my_preloader.text=100*loadIndex/my_count+(Math.round(percent * 100))/my_count + "%";
my_preloader.autoSize=TextFieldAutoSize.CENTER;
function onComplete(e:Event):void {
loadIndex++;
if (loadIndex==my_count) {
startShow();
var my_loaderInfo:LoaderInfo=LoaderInfo(e.target);
my_loaderInfo.removeEventListener(Event.COMPLETE, onComplete);
loadImage(); -
Hi!
I've managed to preload an image with getBytes.../...total
properties but what about my XML document. Can I get statusinfo
while it loads into FlashPlayer?!?
PS I'm publishing to AS2.
Thanks<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Sudip Karnavat ([email protected]):
I need to parse an XML document consisting of metadata and actual content and load the same into database columns with the body content into a CLOB.
e.g.
<AUTHOR> Mike <AUTHOR>
<HEADLINE> About XML </HEADLINE>
<DOCUMENT>
This document outlines the details of the XML parser for PL/SQL .........
</DOCUMENT>
I need to load the author and headline fields to author and headline fields in the database and DOCUMENT field to a CLOB column.
What approach should I follow? Should I use the XML Parser for PL/SQL ? Are there any sample examples.
Thanks
Sudip<HR></BLOCKQUOTE>
Sudip,
I forgot to add that really what you need to
do is write a transformation using XSLT and
only pick the information you need to store.
If you want just e-mail me the xml file and I
will do that-:) -
Preload an image thats called with XML
is there a simple way to do this ...
all my research on "xml preloaders"
always refers to preloading the xml --- obviously
but not the content the xml is calling...
im dealing with some high qualityu photos - and need
something to kill the white space while they load.
any help is greatly appreciated.
best,
antonactually, i am using struts. I have an action servlet and with a few helper classes those do the generating. I mentioned jsp's to simplify the problem and to explain it.
Message was edited by:
spear_arrow -
Preloading all images from xml
Well, i've been at this for quite a while now.
I made a small photoalbum and i want all the images to be
preloaded before the movie begins. I've been struggling with this
for almost 2days.
The images load from an xml. How can I preload all the images
and then start the movie?
Thanks a lot.
This is the code for the xml:Well, I'm kinda guessing at what's in your xml.
Let's say its similar to this;
<document>
<images>
<image>myimage.jpg</image>
<image>myimage2.jpg</image>
</images>
</document>
Then I think the following would work. I haven't tested it,
but it should work in principle based on things I've done in the
past. If you have a fixed number of holder clips (ie. the xml will
always contain 5 images for example) then you can approach things
this way. Otherwise you'd need the code to create empty holderclips
for loading into as well, once the number of images has been
counted. -
Preloading pictures through XML.
Hello,
I am building a dynamic photogallery which load pictures out
of an XML-file in a movieclip.
The problem is that my preload script not work proper. The
preloader stops by picture 2. Is there anybody here who has the
experience to help me? Any improvements or suggestions for my
script are very welcome.
This is my script:
var xml:XML = new XML();
xml.ignoreWhite = true;
var mcl:MovieClipLoader = new MovieClipLoader;
var bronnen:Array = new Array();
var nodes:Array = new Array();
xml.onLoad = function() {
nodes = xml.firstChild.childNodes;
for(var i=0;i<nodes.length;i++) {
bronnen.push(nodes
.attributes.bron);
var foto:MovieClip =
houder.createEmptyMovieClip("foto"+i,houder.getNextHighestDepth());
mcl.loadClip(bronnen,foto);
var mclL:Object = new Object();
mclL.onLoadProgress =
function(doel:MovieClip,geladen:Number,totaal:Number):Void {
var procent:Number = geladen/totaal;
if(procent==1) {
g++;
if(g==nodes.length*nodes.length) {
trace("Alle foto's zijn geladen.");
mcl.addListener(mclL);
var i:Number = new Number();
mclL.onLoadInit = function() {
foto_b.push(houder["foto"+i]._width);
foto_l.push(houder["foto"+i]._height);
foto_x.push(foto_b
*i);
foto_y.push((houder._height - foto_l)/2);
if(i==0) {
foto_x
= 0;
} else {
foto_x = foto_x[i-1] + foto_b[i-1];
houder["foto"+i]._x = foto_x
houder["foto"+i]._y = foto_y;
if(i>nodes.length-(nodes.length-1)) {
var hoogsteNummer:Number = zoekHoogsteNummer(foto_l);
masker.lineTo(foto_b[0],0);
masker.lineTo(foto_b[0],foto_l[0]);
masker.lineTo(0,foto_l[0]);
masker.endFill();
masker._x = (Stage.width/2) - (masker._width/2);// + (foto_b
/2);
masker._y = foto_y[0];
i++;
houder_x = Stage.width/2 - foto_b[i-nodes.length]/2;
houder_y = Stage.height/2 - foto_l[hoogsteNummer]/2;
houder._x = houder_x;
houder._y = houder_y;
masker._y += houder_y;
xml.load("zonder_zon.xml");
Greetings,
AlbusDoes nobody has any suggestions?
-
Downloading and parsing XML during preload
Apologies if this topic has already been covered but the
search function on the forums doesn't appear to be working for me.
My problem is this. I have a flex app that needs to download
a couple of xml files during initialization that are approximately
2-3 MB each. I'd like for the progress bar to continue showing
until the files are downloaded and parsed and only after the files
are downloaded and parsed, would the components start to be
rendered since some of them will require the files to determine
their look and feel.
Any ideas or places I should look to in order to figure this
out?
Thanks
SangGreg_B,
You could try and access the XML file via a file:// URI rather than an http:// one - this would not need the server to be started in order to get the xml/dtd loaded. You know the relative path to the dtd and xml files, and you can create a File object from there, so you can parse the xml file that way if you like.
Here's some code to help:
String filename = getServletContext().getRealPath("myXML.xml");
You can then pass the filename string as a parameter to the XML (I'm assuming you're using DOM but if you aren't I think you'll still get my point) parse method.
You can do all of this in the servlet's init() method, so it'll do that before it all loads up.
Hope it helps
Daniel
Maybe you are looking for
-
updated to new 2014 cc. In bridge when I go to tools/Photoshop/Image Processor....I get this message "adobe photoshop 2014 CC has quit working" Anyone have a fix for this??
-
Hi guys. We're having a problem with an application set this morning. A new application set was created last night and so far, 2 new applications have been added to it. This morning though, when we try to create another application (of ANY type), we
-
Question about the Contacts application...
I'm trying to organize my contact list. I have an All contacts, and separate for my husbands phone and mine. I also have a Christmas list and I'd like to keep The XYZ Family as the name for that but not in my other contact lists. Is that possible??
-
Public Site Manager - GIF files
It appears the PSM will only accept JPG or PNG files for album art. Since our current site uses GIF file in many feeds, I assume I'll have to convert all to a supported format. Question: Do I also have to manually replace each image that was manually
-
Import pics from iPhone5s to iPhoto
Hello, I've just got an iPhone 5S and having some trouble to import the photos to iPhoto. I used to connect my iPhone 4S via USB and opening iPhoto see the pictures automatically imported into the windows. Now, iPhoto see that my iPhone is connected