Jump to content
Search Community

mark_vdi

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by mark_vdi

  1. Thanks Carl I will give that a go - quite simple really i guess i should have picked this out of the documentation. . . just for info: the loads all work fine nearly all of the time so that this is merely covering all the bases as it were. Cheers, Mark
  2. I would really like some help to do this the 'right' way. So all comments very welcome. Problem: LoaderMax is set up and the queue is given the command to load. eg: queue = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); queue.append( new XMLLoader(Object(parent).currentCity +".xml", {name:"currentCity"}) ); queue.load(); loadProgressBar.scaleX=0; loadProgressBar.visible=true; loadProgressBarBG.alpha=1; //returns removed for forum function progressHandler(event:LoaderEvent):void { loadProgressBar.scaleX=event.target.progress; } function completeHandler(event:LoaderEvent):void { //actions when load complete } but connection is good = no error and data name is correct = no error data is available = no error but due to busy traffic or other problem the data loads only v. v. slowly or not at all. Effectively killing the site since no error is generated. In the absence of a 'TimeOut' function in the loader itself the solution I thought up was to set up a timer to check after, in this case, 10 seconds how far the load has progressed. If it is less than say 5% then to try and reload. If the load completes well in advance of the timer then the completeHandler function must, of course, kill the timer: .... queue.load(); loadProgressBar.scaleX=0; loadProgressBar.visible=true; loadProgressBarBG.alpha=1; //returns removed for forum var timeOut:Timer = new Timer(10000,1); function timeOutListener (e:TimerEvent):void { if (loadProgressBar.scaleX <= 0.05) { // HERE I NEED TO THE CORRECT CODE TO STOP / DISPOSE OF AND RESTART A SECOND LOAD ATTEMPT } timeOut.removeEventListener(TimerEvent.TIMER, timeOutListener); timeOut.stop(); } timeOut.addEventListener(TimerEvent.TIMER, timeOutListener); timeOut.start(); function progressHandler(event:LoaderEvent):void { loadProgressBar.scaleX=event.target.progress; } function completeHandler(event:LoaderEvent):void { timeOut.removeEventListener(TimerEvent.TIMER, timeOutListener); timeOut.stop(); // actions when load complete } Ideally I would actually further modify the timer so that It would retry once or twice and the final time would perhaps simply stop the load and return to another area of the site displaying the appropriate warning (just mentioned for info) the code I have used for the restart = if (loadProgressBar.scaleX <= 0.05) { queue.empty(true, true); queue.append( new XMLLoader(Object(parent).currentCity +".xml", {name:"currentCat"}) ); queue.load(); loadProgressBar.scaleX=0; } Would such a sequence of actions stop, empty and restart a load? Feedback and improvements gratefully accepted! Mark
  3. Hi just a small point which might help somebody: If I want a loadProgressBar as a rectangle at say x=20 and y= 20 and create it using . . . loadProgressBar.graphic.drawRect(20,20,100,10); . . . rather than: . . . loadProgressBar.graphic.drawRect(0,20,100,10); loadProgressBar.x = 20; . . . when loadProgress scales the loadProgressBar.scaleX from 0 to 100 the actual bar migrates from x = 0 to the final x set by the graphic.drawRect command in this case 20 . . . I don't know why it does this but 'hard' setting the .x to 20 removes the behavior. Mark
  4. Hi Carl, thanks for having a look after several frustrating hours I finally worked out that, as usual, the weakest link in the chain is the one typing into the keyboard and can only apologies for wasting your time. I used all the traces I could think of for all the properties of soundBv as specified for the MP3Loader to make sure that soundSecondHalf was still pointing to an 'intact' soundfile etc. and also that soundFirstHalf was moving and leaving the pointer at the right place (playProgress, channel, etc etc.) + for all timing events and triggers and everything looked frustratingly ok - interestingly there was some a difference between the Timers version of 1,3 secs. and a TweenMaxs version of 1,3 secs. Thus although soundSecondHalf was separated from soundFirstHalf by loading events checked by onComplete calls at the end of a Tween (1,3 secs away from the start of soundFirstHalf that was paused after 1,3 secs.) locally where the loads were almost instantly available the soundSecondHalf was being triggered miliseconds before the pause command in soundFirstHalf . . . as it turns out effectively killing the playback of soundSecondHalf. Thanks again for checking, Mark
  5. Hi cheers for the looking at it for me I got round it in the end by defining a var functionCall:Boolean = false and then toggling it in the function so that the active part of the function only ever runs the second time: function myFunction ():void { if (functionCall) { functionCall = !functionCall; //do action } else { functionCall = !functionCall; } } This works fine. It just seemed a bit of a 'fudge' and I usually work on the pricinple that if i'm having to 'fudge' the code them I'm not understanding something Thanks again, Mark
  6. Hi, I wanted to add a single 1 x Callback to an already played timeline prior to reverse playing the timeline back to beginning. myTimelineUnload = new TimelineMax({tweens:[new TweenMax( . . . (totalduration =1.2 secs) has been called and played through to end. Later a function is called which plays timeline back to beginning (over twice the time): public function loadSelf():void { trace(myTimelineUnload.totalProgress);//as debugging check - traces "1" = timeline has played and is at end! myTimelineUnload.timeScale=0.5; myTimeLineUnload.addCallback(myFunction, 0.6); myTimelineUnload.reverse(); } What is surprising is that the myFunction is triggered twice by this code. The first time immediately that LoadSelf is called even though the timeline has already run and when the playhead reaches 0.6 seconds = halfway point of timeline. swapping the order of the call to reverse() and addCallback still result in myFunction being called twice . . .Is there a work round or am i missing something obvious (duuh) . . . Your help would be greatly appreciated. In general these tools are so massively brilliant and can do so much . . . its sometimes a bit tricky to work out all the syntax variations required to really exploit some of the more complex tween combos. Thanks again, Mark
  7. Hi to begin: wow the whole loader stuff and tweens stuff and . . . thanks! I am am no jedi coder and therefore have some problem seeing passed what is probably a trivial problem - I load a sound using LoadMax mp3 loader (as part of multiple load) all is working fine I can access and play the whole sound (if i re-initialize: gotoSoundTime(0) took me a while to sort that one! - probably could do with being mentioned in the documentation) as many times as I need triggered by various coding events. The sound actually consists to 'two halves' so that sometimes I want to play both parts = full length, sometime only the first half and sometimes only the second half. To make this easier I buried the sound in three self explanatory function calls (the sound is ca. 2,6 secs in length): (soundBv is an MP3Loader) public function soundFull():void { soundBv.gotoSoundTime(0); soundBv.soundPaused=false; soundBv.playSound(); } public function soundFirstHalf():void { soundBv.gotoSoundTime(0); soundBv.soundPaused=false; soundBv.playSound(); var timer:Timer = new Timer(1300,1); function timerListener (e:TimerEvent):void { soundBv.soundPaused=true; // I get the same effect If I use soundBv.pauseSound(); } timer.addEventListener(TimerEvent.TIMER, timerListener); timer.start(); } public function soundSecondHalf():void { soundBv.soundPaused=false; soundBv.gotoSoundTime(1.30, true); } However: after calling soundFirstHalf which plays the first half of the sound as required no matter what i do I cannot get the sound to replay when I call soundFull or soundSecondHalf afterwards. (This doesn't matter whether I call pauseSound or use soundPaused=true;) I can in contrast call soundSecondHalf as many times as I want without problem as long as the soundFirstHalf has not been called. [As far as I can tell from the documentation setting soundPaused=false shouldn't actually be needed anyway.] The solution I'm sure is very trivial but a nudge in the right direction would be very helpful. Thanks Mark
×
×
  • Create New...