Solved

AS2 preloading external SWF

Posted on 2009-07-01
1
305 Views
Last Modified: 2013-11-11
When preloading an external SWF file, I didn't see the preloader until it was about 90% done. I updated the MCs that are dynamically loaded, turning off "Export in first frame". I then added all the movieClips to a frame at the end that will never be seen by the user. When I do that, the preloader works like a charm by itself, but the code that dynamically displayed an image no longer works.

However,  when I take that file (without removing the "Export in first frame" capability and try to load into a stub .fla file, my works great and the image appears. However, the preloaded doesn't display the correct percentage until about 90%.
//Constants
scrollerMovement = 40;// how far in pixels the scrollbar moves when the +/- button is pressed
maximumScale = 150;// the largest scale of the middle image
leftStart = 316;// left most scrollbar point
rightEnd = 516;// righ most scrollbar point
percentChange = 10;// Determine how much the +/- buttons adjust the size of the image
//trace("_global.button: " + _global.button);
 
// Master functionality
switch (_global.button) {
	case "bc10" :
		placeMiddleImage("a10","mask",551,300.9,143,143.8,"b10","",2);
		break;
	case "bc11" :
		placeMiddleImage("a11","mask",551,300.9,143,143.8,"b11","",2);
		break;
	case "bc12" :
		placeMiddleImage("a12","mask",551,300.9,143,143.8,"b12","",2);
		break;
	case "bc13" :
		placeMiddleImage("a13","mask",551,300.9,143,143.8,"b13","",2);
		break;
	case "bc14" :
		placeMiddleImage("a14","mask",253.9,300.9,289.05,143.8,"b14","",2);
		break;
	case "bc15" :
		placeMiddleImage("a15","mask",551,300.9,143,143.8,"b15","",2);
		break;
	case "bc16" :
		placeMiddleImage("a16","mask",364,300.9,236.5,143.8,"b16","",2);
		break;
	case "bc17" :
		placeMiddleImage("a17","mask",551,204.7,143,189.8,"","",1);
		break;
	case "bc18" :
		placeMiddleImage("a18","mask",551,300.9,143,143.8,"b18","",2);
		break;
	case "bc19" :
		placeMiddleImage("a19","mask",253.3,300.9,289.4,143.8,"b19","",2);
		break;
	case "bc20" :
		placeMiddleImage("a20","mask",551,300.9,143,143.8,"","",1);
		break;
 
	case "bc21" :
		placeMiddleImage("a21","mask",370.9,300.9,230.55,143.8,"b21","",2);
		break;
	case "bc22" :
		placeMiddleImage("a22","mask",551,300.9,143,143.8,"","",1);
		break;
	case "bc23" :
		placeMiddleImage("a23","mask",551,300.9,143,143.8,"b23","",2);
		break;
	case "bc24" :
		placeMiddleImage("a24","mask",551,300.9,143,143.8,"b24","",2);
		break;
	case "bc25" :
		placeMiddleImage("a25","mask",551,300.9,143,143.8,"b25","",2);
		break;
	case "bc26" :
		placeMiddleImage("a26","mask",551,204.6,143,189.3,"","",1);
		break;
	case "bc27" :
		placeMiddleImage("a27","mask",360.7,300.9,235.2,143.8,"b27","",1);
		break;
	case "bc28" :
		placeMiddleImage("a28","mask",463.3,300.9,184.35,143.8,"b28","",2);
		break;
	case "bc29" :
		placeMiddleImage("a29","mask",551,300.9,143,143.8,"","",1);
		break;
	case "bc30" :
		placeMiddleImage("a30","mask",551,300.9,143,143.8,"b30","",2);
		break;
 
	case "bc31" :
		placeMiddleImage("a31","mask",551,300.9,143,143.8,"","",1);
		break;
	case "bc32" :
		placeMiddleImage("a32","mask",373.3,300.9,229.3,143.8,"b32","c32",3);
		break;
	case "bc33" :
		placeMiddleImage("a33","mask",551,300.9,143,143.8,"b33","",2);
		break;
	case "bc34" :
		placeMiddleImage("a34","mask",551,266.3,143,155.8,"b34","",2);
		break;
	case "bc35" :
		placeMiddleImage("a35","mask",551,300.9,143,143.8,"b35","",2);
		break;
	case "bc36" :
		placeMiddleImage("a36","mask",551,300.9,143,143.8,"b36","",2);
		break;
	case "bc37" :
		placeMiddleImage("a37","mask",551,300.9,143,143.8,"b37","",2);
		break;
	case "bc38" :
		placeMiddleImage("a38","mask",551,300.9,143,143.8,"b38","",2);
		break;
	case "bc39" :
		placeMiddleImage("a39","mask",551,300.9,143,143.8,"","",1);
		break;
	case "bc40" :
		placeMiddleImage("a40","mask",551,300.9,143,143.8,"b40","",1);
		break;
 
	case "bc41" :
		placeMiddleImage("a41","mask",551,300.9,143,143.8,"b41","",2);
		break;
	case "bc42" :
		placeMiddleImage("a42","mask",551,300.9,143,143.8,"b42","",2);
		break;
	case "bc43" :
		placeMiddleImage("a43","mask",551,300.9,143,143.8,"b43","",2);
		break;
	case "bc44" :
		placeMiddleImage("a44","mask",551,300.9,143,143.8,"","",1);
		break;
	case "bc45" :
		placeMiddleImage("a45","mask",551,300.9,143,143.8,"","",1);
		break;
	case "bc46" :
		placeMiddleImage("a46","mask",556.5,300.9,137.8,143.8,"b46","",2);
		break;
	case "bc47" :
		placeMiddleImage("a47","mask",517.3,300.9,157.35,143.8,"b47","",2);
		break;
	case "bc48" :
		placeMiddleImage("a48","mask",551,300.9,143.0,143.8,"b48","",2);
		break;
	case "bc49" :
		placeMiddleImage("a49","mask",551,204.7,143,189.8,"","",1);
		break;
	case "bc50" :
		placeMiddleImage("a50","mask",551,300.9,143.0,143.8,"b50","",2);
		break;
 
	case "bc51" :
		placeMiddleImage("a51","mask",551,300.9,143.0,143.8,"b51","",2);
		break;
	case "bc52" :
		placeMiddleImage("a52","mask",230.8,290.9,300.6,143.8,"","",1);
		break;
	case "bc53" :
		placeMiddleImage("a53","mask",551,300.9,143.0,143.8,"","",1);
		break;
	case "bc54" :
		placeMiddleImage("a54","mask",247,314.8,292.5,129.8,"","",1);
		break;
	case "bc55" :
		placeMiddleImage("a55","mask",551,300.9,143.0,143.8,"","",1);
		break;
	case "bc56" :
		placeMiddleImage("a56","mask",551,300.9,143.0,143.8,"","",1);
		break;
	case "bc57" :
		placeMiddleImage("a57","mask",551,300.9,143.0,143.8,"b57","",2);
		break;
	case "bc58" :
		placeMiddleImage("a58","mask",551,300.9,143.0,143.8,"","",1);
		break;
	case "bc59" :
		placeMiddleImage("a59","mask",551,300.9,143.0,143.8,"","",1);
		break;
	case "bc60" :
		placeMiddleImage("a60","mask",551,300.9,143.0,143.8,"","",1);
		break;
 
}
 
// ----------- Drag functions
_root.middleImage.onPress = function() {
	trace("press");
	this.startDrag();
};
_root.middleImage.onRelease = function() {
	trace("onRelease");
	this.stopDrag();
};
_root.middleImage.onReleaseOutside = function() {
	trace("onReleaseOutside");
	this.stopDrag();
};
 
// ----------- Thumbnail scroller functions
scroller.onPress = function() {
	startDrag(this, false, 316, 448, 516, 448);
};
scroller.onRelease = scroller.onReleaseOutside = function () {
	this.stopDrag();
	//
	switch (true) {
		case (this._x <= leftStart) :
			_root.middleImage._xscale = 100;
			_root.middleImage._yscale = 100;
			break;
		case (this._x >= leftStart && this._x <= rightEnd) :
			_root.middleImage._xscale = int(100 + ((this._x - leftStart) / 4));
			_root.middleImage._yscale = _root.middleImage._xscale;
			break;
		case (_root.middleImage._xscale >= rightEnd) :
			_root.middleImage._xscale = maximumScale;
			_root.middleImage._yscale = maximumScale;
			break;
	}
};
 
// ----------- +/- button functions
enlargeButton.onRelease = enlargeButton.onReleaseOutside = function () {
	switch (true) {
		case (_root.middleImage._xscale < 100) :
			_root.middleImage._xscale = 100;
			_root.middleImage._yscale = 100;
			scroller._x = leftStart;
			break;
		case (_root.middleImage._xscale >= 100 && _root.middleImage._xscale < maximumScale) :
			if (scroller._x > rightEnd - scrollerMovement) {
				_root.middleImage._xscale = maximumScale;
				_root.middleImage._yscale = maximumScale;
				scroller._x = rightEnd;
				break;
			} else {
				_root.middleImage._xscale += percentChange;
				_root.middleImage._yscale += percentChange;
				scroller._x = scroller._x + scrollerMovement;
				break;
			}
		case (_root.middleImage._xscale >= maximumScale) :
			_root.middleImage._xscale = maximumScale;
			_root.middleImage._yscale = maximumScale;
			scroller._x = rightEnd;
			break;
	}
};
shrinkButton.onRelease = shrinkButton.onReleaseOutside = function () {
	switch (true) {
		case (_root.middleImage._xscale <= 100) :
			_root.middleImage._xscale = 100;
			_root.middleImage._yscale = 100;
			scroller._x = leftStart;
			break;
		case (middleImage._xscale > 100 && _root.middleImage._xscale <= maximumScale) :
			if (scroller._x < leftStart + scrollerMovement) {
				_root.middleImage._xscale = 100;
				_root.middleImage._yscale = 100;
				scrol_root.ler._x = leftStart;
				break;
			} else {
				_root.middleImage._xscale -= percentChange;
				_root.middleImage._yscale -= percentChange;
				scroller._x = scroller._x - scrollerMovement;
				break;
			}
		case (_root.middleImage._xscale > maximumScale) :
			_root.middleImage._xscale = maximumScale;
			_root.middleImage._yscale = maximumScale;
			scroller._x = rightEnd;
			break;
	}
};
 
// ----------- master function
// placeMiddleImage("a60","mask",551,300.9,289.4,143.8,"","",1);
function placeMiddleImage(mc1, mcMask, mcW, mcH, mcX, mcY, mc2, mc3, noArrows) {
	//Create and attach image
	trace("mc1: " + mc1);
	trace("mcMask: " + mcMask);
	trace("mcW: " + mcW);
	trace("mcH: " + mcH);
	trace("mcX: " + mcX);
	trace("mcY: " + mcY);
	trace("mc2: " + mc2);
	trace("mc3: " + mc3);
	trace("noArrows: " + noArrows);
 
	if (noArrows < 2) {
		leftArrow._visible = false;
		rightArrow._visible = false;
	}
	//                      
	_root.createEmptyMovieClip("masterImage",1);
	_root.masterImage.attachMovie(mc1,mc1,1);
	_root.masterImage._x = mcX;
	_root.masterImage._y = mcY;
	_root.masterImage._height = mcH;
	_root.masterImage._width = mcW;
	initialX = _root.masterImage._x;
	initialY = _root.masterImage._y;
	initialHeight = _root.masterImage._height;
	initialWidth = _root.masterImage._width;
	//
	trace("mc1 placed: " + mc1);
	trace("masterImage height: " + _root.masterImage._height);
	trace("masterImage width: " + _root.masterImage._width);
	trace("masterImage x: " + _root.masterImage._x);
	trace("masterImage y: " + _root.masterImage._y);
 
	//Create mask
	_root.createEmptyMovieClip("masterMask",2);
	_root.masterMask.attachMovie(mcMask,mcMask,2);
	_root.masterMask._x = _root.masterImage._x;
	_root.masterMask._y = _root.masterImage._y;
	_root.masterMask._height = initialHeight;
	_root.masterMask._width = initialWidth;
	_root.masterImage.setMask(_root.masterMask);
	trace("masterMask location: " + _root.masterMask._x + ", " + _root.masterMask._y);
 
	if (noArrows > 1) {
		rightArrow._visible = true;
		leftArrow._visible = false;
	}
	//To back                         
	rightArrow.onPress = function() {
		_root.masterImage.masterImage.removeMovieClip();
		_root.masterMask.masterMask.removeMovieClip();
 
		_root.masterImage.attachMovie(mc2,mc2,1);
		_root.masterImage._x = mcX;
		_root.masterImage._y = mcY;
		_root.masterImage._height = initialHeight;
		_root.masterImage._width = initialWidth;
 
		_root.masterMask.attachMovie(mcMask,"masterMask",2);
		_root.masterMask._x = _root.masterImage._x;
		_root.masterMask._y = _root.masterImage._y;
		_root.masterMask._height = initialHeight;
 
		_root.masterMask._width = initialWidth;
		_root.masterImage.setMask(_root.masterMask);
 
		//middleImage = masterImage;
		if (noArrows > 1) {
			rightArrow._visible = false;
			leftArrow._visible = true;
		}
 
		scroller._x = leftStart;
	};
 
	//To front
	leftArrow.onPress = function() {
		_root.masterImage.masterImage.removeMovieClip();
		_root.masterMask.masterMask.removeMovieClip();
 
		_root.masterImage.attachMovie(mc1,mc1,1);
		_root.masterImage._x = mcX;
		_root.masterImage._y = mcY;
		_root.masterImage._height = initialHeight;
		_root.masterImage._width = initialWidth;
 
		_root.masterMask.attachMovie(mc1,mc1,2);
		_root.masterMask._x = _root.masterImage._x;
		_root.masterMask._y = _root.masterImage._y;
		_root.masterMask._height = initialHeight;
		_root.masterMask._width = initialWidth;
		_root.masterImage.setMask(_root.masterMask);
 
 
 
		//middleImage = masterImage;
		if (noArrows > 1) {
			rightArrow._visible = true;
			leftArrow._visible = false;
		}
 
		scroller._x = leftStart;
	};
	_root.middleImage = _root.masterImage;
	break;
}

Open in new window

0
Comment
Question by:msukow
1 Comment
 

Accepted Solution

by:
msukow earned 0 total points
ID: 24756196
Figured it out - didn't use a separate stub file. Instead, turned off the "Export in first frame" setting for all MCs, places all the clips in the 2nd frame (size 1x1 in upper left of stage), moved all the rest of the frames back a frame.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question