[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

07/04/2009 at 01:46PM PDT, ID: 24544198
[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.1

Flash AS2 paass variable

Asked by homemadebyx in Adobe Flash, Web Development Software, Scripting Languages

Tags: flash, as2, pass variable

i have a beginner/intermediate flash ability.   i recently picked up a component from flashden for use in one of my projects.  The component has a .AS file which it appears that it's exported to and imported from.   In the .AS file it specifies a string for an XML file its interacting with.   How can i make the chosen XML dynamic at runtime?   I'd like to designate the XML within the SWF, and be able to change it with a click or a frame action within the SWF at runtime.     I understand how to set up the click or frame, i just can't figure out how to make the XML a dynamic variable because it's within the .AS

Thanks for any assistance
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:
//my .AS file
 
// Flash libs
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.net.*;
import flash.text.*;
import mx.data.types._xm;
	
// Main class
class welcome.ScrollerAS2 extends MovieClip
{
	// Parameters
	private var base:Object = new Object();
	private var _mainXML:String = "flash/welcome.xml";   // XML Path
	private var _mainCSS:String = "flash/styles.css" // CSS path
	private var width:Number = 300;
	private var height:Number = 200;
	private var _padding:Number = 10;
	private var _scrollerDist:Number = 10;
	private var _autoCenter:Boolean = true;
	private var _scrollerHeight:Number;
	private var _paddingX:Number;
	private var _paddingY:Number;
	private var _backgroundAlpha:Number;
	private var _easing:Number;
	private var _mouseWheelSpeed:Number;
	
	// reference movie clip
	private var container:MovieClip;
	private var gradientMask:MovieClip;
	private var scroller:MovieClip;
	
	
	//------------------------ XML VARS --------------------------//
	
	private	var xmlData:XML;
	
	//--------------- end of -- XML VARS -----------------------//
	
	// MISC Vars
	private var range:Number;
	
	// Get / set XML and CSS path
	public function set mainXML(s:String):Void
	{
		_mainXML = s;
	}
	
	public function set mainCSS(s:String):Void
	{
		_mainCSS = s;
	}
				 
	// Constructor
	public function ScrollerAS2()
	{
		// Global reference
		_global.base = this;
		// Component reference
		container = this["container"];
		gradientMask = this["gradientMask"];
		scroller = this["scroller"];
		// Hide display
		this["display"]._visible = false;
		// Load CSS - XML  and create content
		initStyleSheet();
	}
	
	//__________________________________________________________ LOAD XML
	
	private function xmlLoad(xmlPath:String):Void
	{
		xmlData = new XML();
		xmlData.ignoreWhite = true;
		xmlData.onLoad = ParseData;
		xmlData.load(xmlPath);
	}
	
	private function ParseData(loaded:Boolean):Void
	{
		if (loaded)
		{
			var data:Array = this["firstChild"].childNodes;
			_global.base.initializeComponent(data);
		}
	}
	
	// Setup scroller based on passed parameter from XML
	private function initializeComponent(data:Array):Void
	{
		// apply configuration
		width = Number(data[0].attributes.width);
		height = Number(data[0].attributes.height);
		_paddingX = Number(data[0].attributes.paddingX);
		_paddingY = Number(data[0].attributes.paddingY);
		_scrollerDist = Number(data[0].attributes.scrollerDistance);
		_autoCenter = Boolean(data[0].attributes.autoCenter);
		_scrollerHeight = Number(data[0].attributes.scrollerHeight);
		_backgroundAlpha = Number(data[0].attributes.backgroundAlpha);
		_mouseWheelSpeed = Number(data[0].attributes.mouseWheelSpeed);
		_easing = Number(data[0].attributes.easing);
			
		// Mask area
		gradientMask._width = width;
		gradientMask._height = height;
		gradientMask._alpha = 100;
		
		//Main content and padding
		container.content._width = width - 2 * _paddingX;
		container.content._x = container.content._y = _paddingY;
		container._alpha = 100;
		
		// background
		container.background._width = width;
		container.content.htmlText = data[1].firstChild.nodeValue;
		container.background._height = container._height + 2 * _paddingY;
		container.background._alpha = _backgroundAlpha;
		
		// To check if scroller is necessary
		if (container._height <= height) scroller._visible = false;
		
		// scroller
		scroller._x = width + _scrollerDist;
		scroller._height = _scrollerHeight;
		scroller._y = (height - _scrollerHeight) * .5;
		scroller._alpha = 100;
		range = -container._height + height;
		
		// position
		if (_autoCenter)
		{
			this._x = (Stage.width - width) * .5;
			this._y = (Stage.height - height) * .5;
		}
		
		// interactive
		scroller.scrubber.onPress = scrubberPressed;
		scroller.scrubber.onRelease = scrubberReleased;
		scroller.scrubber.onRollOver = scrubberOver;
		scroller.scrubber.onRollOut = scrubberOut;
		scroller.track.onPress = scrollerPressed;
		// Mousewheel scrolling
		var mouseListener:Object = new Object();
		Mouse.addListener(mouseListener);
		mouseListener.onMouseWheel =  mouseWheelHandler;
		
		// adjust dimension and apply mask
		container.cacheAsBitmap = gradientMask.cacheAsBitmap = true;
		container.setMask(gradientMask);
		container.mask = gradientMask;
	}
	
	// Mouse Wheel Handler
	private function mouseWheelHandler(delta:Number):Void
	{
		var num:Number = Math.round(delta / 3);
		var target:MovieClip = _global.base.scroller.scrubber; 
		target._y -= num * _global.base._mouseWheelSpeed;
		target._y = (target._y <= 0) ? 0 : target._y;
		target._y = (target._y > 170) ? 170 : target._y;
		_global.base.scroller.scrubber.onEnterFrame = _global.base.scrubberEnterFrame;
	}
	
	// Scroller interactive
	private function scrubberPressed():Void
	{
		this.startDrag(false, 0, 0, 0, 170);
		this.onMouseMove = _global.base.scrubberMove;
		this.onEnterFrame = _global.base.scrubberEnterFrame;
		this.onRelease = this.onReleaseOutside = _global.base.scrubberReleased;
	}
	
	private function scrubberReleased():Void
	{
		this.stopDrag();
		this.gotoAndPlay(21);
		delete this.onMouseMove;
	}
	
	private function scrubberMove():Void
	{
		this.onEnterFrame = _global.base.scrubberEnterFrame;
	}
	
	private function scrubberEnterFrame():Void
	{
		with (_global.base)
		{
			var targetY:Number = (this._y / 170) * range;
			container._y += (targetY - container._y) * _easing ;
			if (Math.abs(targetY - container._y) < 0.5)
			{
				delete scroller.scrubber.onEnterFrame;
			}
		}
	}
	
	private function scrubberOver():Void
	{
		this.gotoAndPlay(2);
	}
	
	private function scrubberOut():Void
	{
		this.gotoAndPlay(21);
	}
	
	private function scrollerPressed():Void
	{
		(this._ymouse > 170) ? (this._parent["scrubber"]._y = 170) : (this._parent["scrubber"]._y = this._ymouse);
		this._parent["scrubber"].onEnterFrame = _global.base.scrubberEnterFrame; 
	}
	
	//__________________________________________ APPLY STYLE SHEET
	
	private function initStyleSheet():Void
	{
		var myStyle:TextField.StyleSheet = new TextField.StyleSheet;
		myStyle.load(_global.base._mainCSS);
		myStyle.onLoad = function(loaded:Boolean):Void
		{
			// apply stylesheet to description field
			if (loaded)
			{
				with (_global.base)
				{
					//css.parseCSS(e.target.data);
					container.content.styleSheet = this;
					xmlLoad(_mainXML);
				}
			}
		}
	}
	
		
}
[+][-]07/06/09 02:51 AM, ID: 24783698

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/06/09 07:52 AM, ID: 24785750

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07/06/09 06:01 PM, ID: 24790709

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07/07/09 12:02 AM, ID: 24791962

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: Adobe Flash, Web Development Software, Scripting Languages
Tags: flash, as2, pass variable
Sign Up Now!
Solution Provided By: blue-genie
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07/07/09 08:13 PM, ID: 24800271

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07/07/09 11:26 PM, ID: 24801070

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/13/09 12:19 PM, ID: 24842938

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
 
Loading Advertisement...
20090824-EE-VQP-74 - Hierarchy / EE_QW_3_20080625