Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

AS2 preloading external SWF

Posted on 2009-07-01
1
Medium Priority
?
311 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
Suggested Courses

618 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