Link to home
Start Free TrialLog in
Avatar of webrhp
webrhpFlag for United States of America

asked on

Actionscript 2 Variable Listener

This is a rather simple concept, Im not sure how to generate the proper code.

I simply need a variable listener for my variable (_root.openimage)

and a switch/case statement for the conditions.

So incase the variable changes, the listener will know and prepare the appropriate function.

Help! This is rather urgent.
Avatar of webrhp
webrhp
Flag of United States of America image

ASKER

My rookie attempt code is below, help!
// Guide ///
// _root.galleryName = name of the gallery selected to determine pages
// _root.openimage = name of the image loaded when thumbnail clicked
 
// Hide Arrows Initially //
_root.scenage.work_content.work_panels.arrow_left._visible = false;
_root.scenage.work_content.work_panels.arrow_right._visible = false;
 
 
var imageCheck:Object = new Object();
 
imageCheck = function():Void {
 
if(_root.galleryName == "bedelicious") {
	
	switch (_root.openimage) {
		
		case "" :
			_root.scenage.work_content.work_panels.arrow_left._visible = false;
			_root.scenage.work_content.work_panels.arrow_right._visible = true;
			// Hide Page 01
			_root.scenage.work_content.work_panels.work_donnakaranfragrances_pg01._visible = true;
			// Show Page 02
			_root.scenage.work_content.work_panels.work_donnakaranfragrances_pg02._visible = false;
			// Fade in Page 02
			new mx.transitions.Tween(_root.scenage.work_content.work_panels.work_donnakaranfragrances_pg01, "_alpha", mx.transitions.easing.Strong.easeOut, 0, 100, 2, true);
		break;
		
		case "img/bedelicious_01.jpg" :
			// Left
			_root.scenage.work_content.work_panels.arrow_left.onPress = function() {
				_root.scenage.work_content.work_panels.arrow_left._visible = false;
				_root.scenage.work_content.work_panels.arrow_right._visible = true;
			}
			// Right
			_root.scenage.work_content.work_panels.arrow_right.onPress = function() {
				_root.scenage.work_content.work_panels.arrow_left._visible = true;
				_root.scenage.work_content.work_panels.arrow_right._visible = true;
				_root.openimage = "img/bedelicious_02.jpg";
				_root.scenage.work_content.view_image.gotoAndPlay(11);
			}
		break;
		case "img/bedelicious_02.jpg" :
			// Left
			_root.scenage.work_content.work_panels.arrow_left.onPress = function() {
				_root.scenage.work_content.work_panels.arrow_left._visible = true;
				_root.scenage.work_content.work_panels.arrow_right._visible = true;
				_root.openimage = "img/bedelicious_01.jpg";
				_root.scenage.work_content.view_image.gotoAndPlay(11);
			}
			// Right
			_root.scenage.work_content.work_panels.arrow_right.onPress = function() {
				_root.scenage.work_content.work_panels.arrow_left._visible = true;
				_root.scenage.work_content.work_panels.arrow_right._visible = true;
				_root.openimage = "img/bedelicious_03.jpg";
				_root.scenage.work_content.view_image.gotoAndPlay(11);
			}
		break;
		case "img/bedelicious_03.jpg" :
			// Left
			_root.scenage.work_content.work_panels.arrow_left.onPress = function() {
				_root.scenage.work_content.work_panels.arrow_left._visible = true;
				_root.scenage.work_content.work_panels.arrow_right._visible = true;
				_root.openimage = "img/bedelicious_02.jpg";
				_root.scenage.work_content.view_image.gotoAndPlay(11);
			}
			// Right
			_root.scenage.work_content.work_panels.arrow_right.onPress = function() {
				_root.scenage.work_content.work_panels.arrow_left._visible = true;
				_root.scenage.work_content.work_panels.arrow_right._visible = true;
				_root.openimage = "img/bedelicious_04.jpg";
				_root.scenage.work_content.view_image.gotoAndPlay(11);
			}
		break;
		case "img/bedelicious_04.jpg" :
			// Left
			_root.scenage.work_content.work_panels.arrow_left.onPress = function() {
				_root.scenage.work_content.work_panels.arrow_left._visible = true;
				_root.scenage.work_content.work_panels.arrow_right._visible = true;
				_root.openimage = "img/bedelicious_03.jpg";
				_root.scenage.work_content.view_image.gotoAndPlay(11);
			}
			// Right
			_root.scenage.work_content.work_panels.arrow_right.onPress = function() {
				_root.scenage.work_content.work_panels.arrow_left._visible = true;
				_root.scenage.work_content.work_panels.arrow_right._visible = true;
				_root.openimage = "img/bedelicious_05.jpg";
				_root.scenage.work_content.view_image.gotoAndPlay(11);
			}
		break;
		case "img/bedelicious_05.jpg" :
			// Left
			_root.scenage.work_content.work_panels.arrow_left.onPress = function() {
				_root.scenage.work_content.work_panels.arrow_left._visible = true;
				_root.scenage.work_content.work_panels.arrow_right._visible = true;
				_root.openimage = "img/bedelicious_04.jpg";
				_root.scenage.work_content.view_image.gotoAndPlay(11);
			}
			// Right
			_root.scenage.work_content.work_panels.arrow_right.onPress = function() {
				_root.scenage.work_content.work_panels.arrow_left._visible = true;
				_root.scenage.work_content.work_panels.arrow_right._visible = false;
			}
		break;
 
	} // switch _root.openimage 
	
} // if _root.galleryName
 
}
 
click.addListener(imageCheck);

Open in new window

Avatar of webrhp

ASKER

Anyone out there????
ASKER CERTIFIED SOLUTION
Avatar of Craybe
Craybe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial