Advertisement

05.20.2008 at 08:42AM PDT, ID: 23417633
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

I have a coding problem with a flash xml image gallery.  How can I change the code so it does not use so much system memory?

Asked by tomwaclo in Macromedia Flash

Tags: , ,

I am manipulating a flash file I purchased.  The file creates an xml gallery.  The gallery works well but seems to continually use more and more memory.  I think the problem has to do with the how the animation is created.  If you watch the flash animation and check your processes under windows task manager you can see the memory usage continues until it crashed the system.  Does anybody have any recommendations?  The Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
//------------------------------Imports
import com.mosesSupposes.fuse.*;
import flash.display.BitmapData;
ZigoEngine.register(Fuse,PennerEasing,FuseFMP,Shortcuts);
 
//------------------------------Memory & Other Variables
 
var currentIndice:Number = 0;
var plim:Fuse;
 
//Images Animations
var initialWidth:Number = 0;
var initialHeight:Number = 0;
var finalWidth:Number = 0;
var finalHeight:Number = 0;
var initialX:Number = 0;
var initialY:Number = 0;
var finalX:Number = 0;
var finalY:Number = 0;
 
//Container Animations
var containerTPInitX:Number = 0;
var containerTPInitY:Number = 0;
var containerTPFinalX:Number = 0;
var containerTPFinalY:Number = 0;
var containerTRFinalX:Number = 0;
var containerTRFinalY:Number = 0;
 
//BitmapDatas
var myBitmapData:BitmapData;
var myBitmapData2:BitmapData;
var isFirstBitmapData:Boolean = true;
 
//---------------------------------------------------------------------------------------- Loading Images System
 
//Variables
 
var containerToLoad:Object;
var previousContainer:Object;
 
var mcl2;
var mclL2;
 
 
 
 
mcl2 = new MovieClipLoader();
mclL2 = new Object();
 
var mainIndice:Number;
 
function loadImage(indice){
	//Initialisation
	mainIndice = indice;
	mcl2.addListener(mclL2);
	var sourceToLoad = images[indice]['Path'];
	mcl2.loadClip(sourceToLoad,containerToLoad.loader);
}
 
 
mclL2.onLoadProgress = function(target,loaded,total) {
	part = Math.round((loaded/total) * 100);
	preloader._width = (loaded/total) * slideshowWidth;
}
mclL2.onLoadInit = function (target){
	currentIndice = mainIndice;
	recordInitInfo(containerToLoad,mainIndice);
	fadeMc(preloader, 0, elementsTransitionTime, "easeOutCirc");
	placeContainers(containerToLoad,previousContainer);
	playSlideShow(imageTime,mainIndice+1);
	rmvListener();
}
mclL2.onLoadStart = function (target){
	freezeAllNavigationButtons(true);
	preloader._width = 0;
	fadeMc(preloader, 100, elementsTransitionTime, "easeOutCirc");
}
 
rmvListener = function(){
		mcl2.removeListener(mclL2);
		mclL2.dispose ();
		mcl2.dispose ();
}
 
//---------------------------------------------------------------------------------------- Container Animation
 
 
function placeContainers(container,containerToRemove){
	startAnimImage(container);
	fadeContainer(container,containerToRemove);
}
 
function fadeContainer(container,containerToRemove){
	//Animation
	var n:Fuse = new Fuse();
	//Initialisation Container
	n.push({target:container, alpha:0, seconds:0, ease:easeType});
	n.push({func:makeElementVisible, args:[container,true]});
	n.push({func:makeElementHighestDepth, args:container});
	//Animation
	n.push({target:container, alpha: 100, seconds:transitionTime, ease:easeType});
	//Initialisation Container to Remove
	n.push({func:makeAllOtherContainersInvisible, args:currentIndice});
	n.push({func:freezeAllNavigationButtons, args:false});
	//wait(freezeAllNavigationButtons,.5,false);
	n.start();
	
}
function creationContainers(){
	for(v=0;v<images.length;v++){
		theContainers.attachMovie("Container", "container"+v, getDepth()+v);
	}
}
 
function makeAllOtherContainersInvisible(indice){
	for(v=0;v<images.length;v++){
		if(v!=indice){
			var tmpCt:MovieClip;
			tmpCt = eval ("theContainers.container"+v);
			//tmpCt.unloadMovie()
			tmpCt._visible = false;
		}
	}
}
 
//---------------------------------------------------------------------------------------- Image Animation
 
function recordInitInfo(container,indice){
	//Record the initial size of the picture(Only once).
	if(images[indice]['InitWidth'] == 0){
		setImagesSize(container,indice);
	}
	updateDescriptions(indice);
}
 
function setImagesSize(container,indice){
	if(container._height < slideshowHeight || container._width < slideshowWidth){
		errorOutput.htmlText = "Alert message:<br/>"
		errorOutput.htmlText += "Your image must have a wider and a higher size than this slideshow.<br/> Please change your image, or adapt the slideshow size.";
	}else{
		images[indice]['InitHeight']= container._height; 
		images[indice]['InitWidth']= container._width; 
	}
}
 
function startAnimImage(container){
	//Positions & sizes calculations
	adaptImageForAnim(container);
	randomImageAnim();
 
	var a:Fuse = new Fuse();
	//Initialisation
	a.push([{target:container.loader2, width:initialWidth, height:initialHeight , seconds:0, ease:easeType},
			{target:container.loader2, x:initialX, y:initialY, seconds:0, ease:easeType}
			]);
	a.push({delay:transitionWaitingTime});
	//Animation
	a.push([{target:container.loader2, width:finalWidth, height:finalHeight , seconds:imageTime, ease:easeType},
			{target:container.loader2, x:finalX, y:finalY , seconds:imageTime, ease:easeType}
			]);
	a.start();
	
}
 
function randomImageAnim(){
	var zoomMode:Number = getRandomInteger(1);
	if(zoomMode == 0){
		zoomOut();
		trace("zoom out");
	}
	if(zoomMode == 1){
		zoomIn();
		trace("zoom in");
	}
	var posMode:Number = getRandomInteger(6);
	if(posMode == 0){
		centerPos();
		trace("center pos");
	}
	if(posMode == 1){
		leftToRightPos();
		trace("left to right");
	}
	if(posMode == 2){
		rightToLeftPos();
		trace("right to left");
	}
	if(posMode == 3){
		bottomRightDiagonalPos();
		trace("bottom right to top");
	}
	if(posMode == 4){
		topLeftDiagonalPos();
		trace("top left");
	}
	if(posMode == 5){
		topRightDiagonalPos();
		trace("top right");
	}
	if(posMode == 6){
		bottomLeftDiagonalPos();
		trace("bottom left");
	}
	
	
}
function zoomOut(){
	// sizes calculations
	initialWidth = images[currentIndice]['InitWidth'];
	initialHeight = images[currentIndice]['InitHeight'];
	if(slideshowWidth/slideshowHeight > initialWidth/initialHeight){
		finalWidth = slideshowWidth;
		finalHeight = getProportionalSize(initialHeight,initialWidth, slideshowWidth);
		
	}else{
		finalHeight = slideshowHeight; 
		finalWidth = getProportionalSize(initialWidth,initialHeight, slideshowHeight);
	}
}
 
function zoomIn(){
	// sizes calculations
	finalWidth = images[currentIndice]['InitWidth'];
	finalHeight = images[currentIndice]['InitHeight'];
	if(slideshowWidth/slideshowHeight > finalWidth/finalHeight){
		initialWidth = slideshowWidth; 
		initialHeight = getProportionalSize(finalHeight,finalWidth, slideshowWidth);
	}else{
		initialWidth = getProportionalSize(finalWidth,finalHeight, slideshowHeight);
		initialHeight = slideshowHeight;
	}
}
function centerPos(){
	initialX = (slideshowWidth - initialWidth)/2;
	initialY = (slideshowHeight - initialHeight)/2;
	finalX = (slideshowWidth - finalWidth)/2;
	finalY = (slideshowHeight - finalHeight)/2;
}
function leftToRightPos(){
	initialX = 0;
	initialY = (slideshowHeight - initialHeight)/2;
	finalX = slideshowWidth - finalWidth;
	finalY = (slideshowHeight - finalHeight)/2;
}
function rightToLeftPos(){
	initialX = slideshowWidth - initialWidth;
	initialY = (slideshowHeight - initialHeight)/2;
	finalX = 0;
	finalY = (slideshowHeight - finalHeight)/2;
}
 
function bottomRightDiagonalPos(){
	initialX = slideshowWidth - initialWidth;
	initialY = slideshowHeight - initialHeight;
	finalX = 0;
	finalY = 0;
}
 
function topLeftDiagonalPos(){
	initialX = 0;
	initialY = 0;
	finalX = slideshowWidth - finalWidth;
	finalY = slideshowHeight - finalHeight;
}
 
function topRightDiagonalPos(){
	initialX = slideshowWidth - initialWidth;
	initialY = 0;
	finalX = 0;
	finalY = slideshowHeight - finalHeight;
}
 
function bottomLeftDiagonalPos(){
	initialX = 0;
	initialY = slideshowHeight - initialHeight;
	finalX = slideshowWidth - finalWidth;
	finalY = 0;
}
 
function adaptImageForAnim(container){
	// Image Adaptation For Animation 
	
	if(isFirstBitmapData){
		myBitmapData.dispose ();
		myBitmapData = new BitmapData(images[currentIndice]['InitWidth'],images[currentIndice]['InitHeight'], false, 0x00FF0000);
		container.loader2.attachBitmap(myBitmapData, container.loader2.getNextHighestDepth(), "auto", true);
		myBitmapData.draw(container.loader);
 
	}else{
		myBitmapData2.dispose ();
		myBitmapData2 = new BitmapData(images[currentIndice]['InitWidth'],images[currentIndice]['InitHeight'], false, 0x00FF0000);
		container.loader2.attachBitmap(myBitmapData2, container.loader2.getNextHighestDepth(), "auto", true);
		myBitmapData2.draw(container.loader);
 
	}
	isFirstBitmapData = !isFirstBitmapData;
}
 
function getProportionalSize(sizeToAdapt,oldSize,newSize):Number{
	var prop:Number = sizeToAdapt / oldSize;
	return prop*newSize;
}
 
//---------------------------------------------------------------------------------------- General Functions
 
function makeElementVisible(element,isVisible){
	element._visible = isVisible;
}
 
function makeElementHighestDepth(element){
	element.swapDepths(getNextHighestDepth());
}
 
function wait(functionToCall,timeToWait,theArguments){
	var m:Fuse = new Fuse();
	m.push({delay:timeToWait});
	m.push({func:functionToCall, args:theArguments});
	m.start();
}
 
function getRandomInteger(highestValue){
	return Math.floor(Math.random()*(highestValue+1));
}
 
 
function fadeMc(movieClip, toAlpha, effectTime, theEaseType){
	var f:Fuse = new Fuse();
	f.push({target:movieClip, alpha:toAlpha, seconds:effectTime, ease:theEaseType});
	f.start();
}
 
function initElements(){
	if(!enableImageLink){
		linkButton._visible = false;
	}
	
	descriptions._y = slideshowHeight;
	//descriptions._width = 720;
	linkButton._width = slideshowWidth;
	linkButton._height = slideshowHeight;
	navigation._y = -navigation._height;
}
 
//---------------------------------------------------------------------------------------- Descriptions + Navigation Panels
 
//Variables
var menuRaised:Boolean = true;
var navigationOn:Boolean = false;
var newPosNav:Number;
 
function onMouseMove() {
	if(_xmouse>=0 && _xmouse<= slideshowWidth){
		if(enableDescriptions){
			if(_ymouse > (slideshowHeight - accessibilityOfPanels*descriptions._height)){
				if(!menuRaised){
					raiseMenu(true);
				}
			}else{
				if(menuRaised && !lockDescriptionOpen){
					raiseMenu(false);
				}
			}
		}
		if(enableNavigation){
			if(_ymouse < (accessibilityOfPanels*navigation._height)){
				if(!navigationOn){
					turnNavigationOn(true);
				}
			}else{
				if(navigationOn){
					turnNavigationOn(false);
				}
			}
		}
		if(enableNavigation && slideshowWidth < navigation._width){
			var tmpPos =_xmouse / slideshowWidth;
			newPosNav = (slideshowWidth - navigation._width) * tmpPos;
		}
	}
}
onEnterFrame = function(){
	if(enableNavigation && slideshowWidth < navigation._width){
		var tmpAcceleration = newPosNav - navigation._x;
		navigation._x += tmpAcceleration*0.4;
	}
}
 
function raiseMenu(toRaise){
	menuRaised = toRaise;
	var f:Fuse = new Fuse();
	if(toRaise){
		f.push({target:descriptions, y:slideshowHeight - descriptions._height, seconds:elementsTransitionTime, ease:elementsEaseType});
	}else{
		f.push({target:descriptions, y:slideshowHeight, seconds:elementsTransitionTime, ease:elementsEaseType});
	}
	f.start();
}
 
function turnNavigationOn(turnOn){
	navigationOn = turnOn;
	var f:Fuse = new Fuse();
	if(turnOn){
		f.push([{target:navigation, y:0, seconds:elementsTransitionTime, ease:elementsEaseType},
				{target:preloader, y:navigation._height, seconds:elementsTransitionTime, ease:elementsEaseType}
				]);
	}else{
		f.push([{target:navigation, y:-navigation._height, seconds:elementsTransitionTime, ease:elementsEaseType},
				{target:preloader, y:0, seconds:elementsTransitionTime, ease:elementsEaseType}
				]);
	}
	f.start();
}
 
linkButton.onRelease = function(){
	if(enableImageLink){
		getURL(images[currentIndice]['Link'],'_blank');
	}
}
 
//---------------------------------------------------------------------------------------- Navigation System
 
function creationThumbnails(){
	for(v=0;v<images.length;v++){
		navigation.attachMovie("NavigationButton", "button"+v, getDepth()+v+2);
	}
}
function updateThumbnails(){
	for(v=0;v<images.length;v++){
		var tmpThumb:Object = eval ("navigation.button"+v);
		tmpThumb._x = 60*v;
		tmpThumb.mainButton.indice = v;
	}
}
 
// Preloading Variables
var mcl3:MovieClipLoader = new MovieClipLoader();
var mclL3:Object = new Object();
var finished = true;
var seq = 0;
 
// Load a Thumbnail
function loadContent(tmpThumb){
	mclL3.onLoadProgress = function(target,loaded,total) {
		//part = Math.round((loaded/total) * 100);
	}
	mclL3.onLoadInit = function (target){
		//End of this loading
		finished=true
		images[seq]['IsThumbLoaded']= true;
		seq++;
	}
	mcl3.addListener(mclL3);
	var thumbToLoad = images[seq]['ThumbnailPath'];
	mcl3.loadClip(thumbToLoad,tmpThumb.loader);
}
 
// Load all thumbnails
function loadAllThumbnails() {
	if(finished){
		if(seq==(images.length)-1){
			clearInterval(loadSequence);
		}
		if(!images[seq]['IsThumbLoaded']){
			var tmpThumb:Object = eval ("navigation.button"+seq);
			loadContent(tmpThumb);
			finished = false;
		}
	}
}
 
if(enableNavigation){
	creationThumbnails();
	updateThumbnails();
	loadAllThumbnails();
	var loadSequence = setInterval(loadAllThumbnails, 100 );
}
 
function pauseSlideShow(){
	plim.pause();
}
 
 
 
function playSlideShow(timeToWait,indice){
	pauseSlideShow();
	
	if(indice > images.length-1){
		indice = 0;
	}
	
	previousContainer = containerToLoad;
	containerToLoad = eval ("theContainers.container"+indice);
	plim.dispose();
	plim = new Fuse();
	plim.push({delay:timeToWait});
	plim.push({func:loadImage, args:indice});
	plim.start();
	
	descriptions.thePlayPauseButton.makePlayPosition(false);
	
}
 
function freezeAllNavigationButtons(toFreeze){
	for(v=0;v<images.length;v++){
		var tmpThumb:Object = eval ("navigation.button"+v);
		tmpThumb.mainButton.isFreezed = toFreeze;
	}
	descriptions.thePlayPauseButton.isFreezed = toFreeze;
}
 
 
//----------------------------------------------------------------------------------------Color Settings
 
function updateDescriptions(indice){
	
	var cl:Fuse = new Fuse();
	//Initialisation
	cl.push({target:descriptions,  seconds:transitionTime/1.5, alpha: 0, ease:easeType});
	cl.push([
		//Theme
		{target:descriptions.Tittle, tint:images[indice]['ColorTheme'], seconds:0, ease:easeType},
		{target:descriptions.thePlayPauseButton.playPauseShape, tint:images[indice]['ColorTheme'], seconds:0, ease:easeType},
		//Backgrounds
		{target:descriptions.shape.descriptionPanelShape, tint:images[indice]['ColorBackground'], seconds:0, ease:easeType},
		{target:descriptions.thePlayPauseButton.buttonBackgroundShape.buttonBackgroundShapeColor, tint:images[indice]['ColorBackground'], seconds:0, ease:easeType},
		{target:navigation.shape.descriptionPanelShape, tint:images[indice]['ColorBackground'], seconds:0, ease:easeType},
		//Preloader
		{target:preloader.preloaderColor, tint:images[indice]['ColorBackground'], seconds:0, ease:easeType},
		//Descriptions
		{target:descriptions.Description, tint:images[indice]['ColorDescription'], seconds:0, ease:easeType},
		//Texts
		{func:updateDescriptionTexts, args:indice}
	]);
	cl.push({target:descriptions,  seconds:transitionTime/1.5, alpha: 100, ease:easeType});
	cl.start();	
}
 
function updateDescriptionTexts(indice){
	//Update decription & tittle
	descriptions.Tittle.htmlText = images[indice]['Name'];
	descriptions.Description.htmlText = images[indice]['Description'];
	if(lockDescriptionOpen){
		raiseMenu(true);
	}
}
 
//----------------------------------------------------------------------------------------Execution
stop();
initElements();
creationContainers();
playSlideShow(0,0);
raiseMenu(true);
[+][-]05.21.2008 at 06:48AM PDT, ID: 21614976

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 08:44AM PDT, ID: 21616217

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Macromedia Flash
Tags: flash cs3 actionscript, cross, http://tahoehometours.com/ideas/v_tour.html
Sign Up Now!
Solution Provided By: yarunii
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628