Advertisement

06.10.2008 at 03:18PM PDT, ID: 23474084
[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!

9.3

Thumbnail creation

Asked by pertrai1 in ActionScript, Macromedia Flash

Tags:

Hi, I use this gallery that I like and I do not know much about Flash. In the XML file you add the image and the thumbnail but I would like to not have to add the thumbnail, which you do not have to. My only problem is that my taller images are not making it into the thumbnail holder.
 
Take a look: http://jansonphoto.powweb.com/proofs/2008

I have included the AS for the thumbnail creation. I can offer more if this is not what needs to be changed.

Is this possible to do?

RobStart 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:
class Thumbnail extends GenericImage {
	// ===== SETTINGS =====
	// border width
	private var bw:Number = 3;
	// distance between border and image
	private var is:Number = 0;
	// thumb height
	private var h:Number = 275;
	// label rectangle height
	private var lrh:Number = 28;
	// distance between thumb and label
	private var ls:Number = 0;
	// initial scale
	private var iScale:Number = 60;
	// initial rotation
	private var iRot:Number = -9;
	// animation time
	private var anit:Number = .3;
	// easing tipe
	private var inEase:String = "easeOutQuad";
	private var outEase:String = "easeOutQuad";
	// image to black alpha
	private var efa:Number = 0;
	// slide into stage time
	private var slint:Number = 1.5;
	// ===== end of SETTINGS =====
	private var yp:Number;
	private var oy:Number;
	private var xp:Number;
	private var ox:Number;
	private var osc:Number;
	private var out:Boolean = true;
	// movie clips
	private var MCBorder:MovieClip;
	private var MCBground:MovieClip;
	private var MCMask:MovieClip;
	private var MCLabel:MovieClip;
	private var MCEffect:MovieClip;
	private var TFLabel:TextField;
	private var TN:MovieClip;
	// other variables
	private var pid:String = undefined;
	private var AniMC:Array;
	private var clickHandler:Function;
	private var DataNode:XMLNode;
	private var TIndex:Number = -1;
	private var w:Number = 130;
	private var lbl:String;
	//
	private var locked:Boolean = false;
	// constructor
	public function Thumbnail() {
		this._focusrect = false;
		// set movie clips
		MCBorder = eval(this._target+"/a");
		MCBground = eval(this._target+"/b");
		MCLabel = eval(this._target+"/c");
		MCEffect = eval(this._target+"/ef");
		TFLabel = eval(this._target+"/c/a");
		MCMask = MCBground.duplicateMovieClip("d", this.getNextHighestDepth());
		TN = MCBorder._parent;
		// array with animated movie clips
		AniMC = new Array(MCBorder, MCEffect);
		// stop all animations
		for (var i in AniMC) {
			AniMC[i].stop();
		}
		//
		this.hitArea = MCBorder;
		MCMask._alpha = 0;
		MCLabel._alpha = 0;
		//
		MCEffect._alpha = efa;
		MCEffect._visible = false;
		//
		TFLabel.autoSize = false;
		TFLabel.multiline = true;
		TFLabel.wordWrap = true;
		TFLabel.selectable = false;
		TFLabel.text = "";
		//
		this.resize();
	}
	// SET SIZE
	public function resize() {
		MCBorder._width = w;
		MCBorder._height = h-lrh-ls;
		MCBorder._x = MCBorder._y=0;
		//
		MCBground._width = w-2*bw;
		MCBground._height = h-2*bw-lrh-ls;
		MCBground._x = MCBground._y=bw;
		//
		MCMask._width = w-2*(bw+is);
		MCMask._height = h-2*(bw+is)-lrh-ls;
		MCMask._x = MCMask._y=bw+is;
		//
		MCEffect._width = w-2*(bw+is);
		MCEffect._height = h-2*(bw+is)-lrh-ls;
		MCEffect._x = MCEffect._y=bw+is;
		//
		TFLabel._width = w;
		TFLabel._height = lrh;
		MCLabel._x = 0;
		MCLabel._y = h-lrh;
		//
		resizeIMG();
	}
	// PLAY ANIMATIONS
	private function playTo(mc:MovieClip, fr:Number):Void {
		if (fr<=0) {
			fr = mc._totalframes;
		}
		mc.onEnterFrame = function() {
			if (this._currentframe == fr) {
				delete this.onEnterFrame;
				return;
			}
			if (this._currentframe>fr) {
				this.prevFrame();
			} else {
				this.nextFrame();
			}
		};
	}
	private function clearTweens() {
		TN.stopTween();
		MCLabel.stopTween();
	}
	// PLAY OVER STATE
	private function overState() {
		out = false;
		for (var i in AniMC) {
			playTo(AniMC[i], 0);
		}
		clearTweens();
		TN.tween(["_rotation", "_xscale", "_yscale", "_y", "_x"], [0, 100, 100, oy, ox], anit, inEase, 0);
		MCLabel.alphaTo(100, anit, "linear", anit);
	}
	// PLAY OUT STATE
	private function outState() {
		out = true;
		for (var i in AniMC) {
			playTo(AniMC[i], 1);
		}
		clearTweens();
		TN.tween(["_rotation", "_xscale", "_yscale", "_y", "_x"], [iRot, iScale, iScale, yp, xp], anit, outEase, anit);
		MCLabel.alphaTo(0, anit, "linear");
	}
	// ON CLICK EVENT
	public function set onClick(f:Function) {
		clickHandler = f;
	}
	public function get onClick():Function {
		return clickHandler;
	}
	// MOVIE CLIP EVENTS
	private function onRollOver() {
		if (locked) {
			return;
		}
		overState();
	}
	private function onRollOut() {
		if (locked) {
			return;
		}
		outState();
	}
	private function onReleaseOutside() {
		if (locked) {
			return;
		}
		outState();
	}
	private function onRelease() {
		if (locked) {
			return;
		}
		trace(DataNode);
		clickHandler.call(this, DataNode, TIndex);
	}
	//
	private function onLoadStart() {
		preloader.alphaTo(100, 1.5, "linear", 0, undefined, undefined, undefined);
		preloader._x = Math.round(w/2);
		preloader._y = Math.round((h-lrh-ls)/2);
	}
	private function resizeIMG() {
		if (image == undefined) {
			return;
		}
		var tw:Number = w-2*(bw+is);
		var th:Number = (h-lrh-ls)-2*(bw+is);
		image._width = tw;
		image._height = tw/ratio;
		if (image._height<th) {
			image._height = th;
			image._width = th*ratio;
		}
		image._x = bw+is+Math.floor(tw/2-image._width/2);
		image._y = bw+is+Math.floor(th/2-image._height/2);
	}
	private function customize() {
		resizeIMG();
		image.setMask(MCMask);
		image._alpha = 100;
		MCEffect.swapDepths(this.getNextHighestDepth());
		MCEffect._visible = true;
		function hnd() {
			this.enabled = true;
		}
		TN.xSlideTo(xp, slint, "easeOutBack", undefined, hnd);
	}
	//
	public function setData(n:XMLNode, i:Number) {
		TIndex = i;
		MCEffect._visible = false;
		DataNode = n;
		lbl = String(n.attributes.name).toUpperCase();
		TFLabel.text = lbl;
		if (n.attributes.thumb != undefined) {
			super.setData(n.attributes.thumb);
		} else {
			super.setData(n.attributes.src);
		}
		doMath();
		this.enabled = false;
	}
	//
	private function onTweenUpdate() {
		updateDepth();
	}
	private function onTweenComplete() {
		updateDepth();
	}
	private function updateDepth() {
		var mids:Number = iScale+(100-iScale)/2;
		if (this._xscale<mids) {
			if (out) {
				if (this.getDepth() != osc) {
					this.swapDepths(osc);
				}
			}
		} else {
			if (!out) {
				this.swapDepths(this._parent.getNextHighestDepth());
			}
		}
	}
	private function doMath() {
		osc = this.getDepth();
		this._xscale = this._yscale=iScale;
		this._rotation = iRot;
		yp = oy+Math.round(w/2-w*iScale/200);
		xp = ox+Math.round(h/2-h*iScale/200);
		this._y = yp;
	}
	public function set origX(orx:Number) {
		ox = orx;
	}
	public function set origY(ory:Number) {
		oy = ory;
	}
	//
	public function set width(nw:Number) {
		w = nw;
		this.resize();
	}
	public function set height(nh:Number) {
		h = nh;
		this.resize();
	}
	public function get width():Number {
		return w;
	}
	public function get height():Number {
		return h;
	}
	public function set depth(dpth:Number) {
		osc = dpth;
		this.swapDepths(osc);
	}
	public function get depth():Number {
		return osc;
	}
}
[+][-]06.10.2008 at 10:53PM PDT, ID: 21757154

View this solution now by starting your 30-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

Zones: ActionScript, Macromedia Flash
Tags: flash, actionscript
Sign Up Now!
Solution Provided By: SamuelRostol
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628