Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Actionscript function help, needed badly 1

Status
Not open for further replies.

webmigit

Programmer
Aug 3, 2001
2,027
US
Code:
_root.Labeler.PickStatus = function() {
	_root.Labeler.rectype = _root.Labeler.rectype.toLowerCase()
	_root.Labeler.lblPrinted._visible = false;
	_root.Labeler.lblReceipt._visible = false;
	_root.Labeler.lblCleared._visible = false;
	_root.Labeler.lblVoid._visible = false;

	if (_root.Labeler.rectype == "receipt") {
		_root.Labeler.lblPrinted._visible = false;
		_root.Labeler.lblReceipt._visible = true;
		_root.Labeler.lblCleared._visible = false;
		_root.Labeler.lblVoid._visible = false;
	} 

	if (_root.Labeler.rectype == "already printed") {
		_root.Labeler.lblPrinted._visible = true;
		_root.Labeler.lblReceipt._visible = false;
		_root.Labeler.lblCleared._visible = false;
		_root.Labeler.lblVoid._visible = false;
	}

	if (_root.Labeler.rectype == "cleared") {
		_root.Labeler.lblPrinted._visible = false;
		_root.Labeler.lblReceipt._visible = false;
		_root.Labeler.lblCleared._visible = true;
		_root.Labeler.lblVoid._visible = false;
	} 

	if (_root.Labeler.rectype == "void") {
		_root.Labeler.lblPrinted._visible = false;
		_root.Labeler.lblReceipt._visible = false;
		_root.Labeler.lblCleared._visible = false;
		_root.Labeler.lblVoid._visible = true;
	}
}

I've also tried using this in place of _root.Labeler..

Here's what's going on... Labeler is a symbol in my movie, lblPrinted,lblReceipt etc are symbols within that symbol..

I'm trying to print something but first I need Labeler to show the right text... calls to it aren't working

Code:
	Labeler.rectype = arrStatus[_global.DMOData.SSTATUS - 3]; // Sets rectype to "void"
	_root.Labeler.PickStatus();

And then when the print job is setup, it asks if the user wans to print a reciept...

Code:
PrintButton.onRelease = function() { 
	var my_pj:PrintJob = new PrintJob();
	var myResult:Boolean = my_pj.start();
		if(myResult) {
			this.visible = false; // hide the print button, it covers up the hash
			// start mod
			import mx.controls.Alert;
			HandlePrintChoice = function(evt){
				if(evt.detail = 1) { // User Clicked Yes
					_global._receipt = 1
				} else {
					_global._receipt = 0
				}
			}
			Alert.show("Print a reciept also?", "Printing Options", Alert.YES | Alert.NO, this, HandlePrintChoice);
			_this._parent._xscale = 85;
			_this._parent._yscale = 85;
			my_pj.addPage(0);
			if(_global._receipt == 1) {
				_root.Labeler.rectype = "reciept"
				_root.Labeler._visible = true;
				_root.Labeler.PickStatus();
				my_pj.addPage(0);
			}
			_this._parent._xscale = 100;
			_this._parent._yscale = 100;
			_root.GoBackBox._visible = true
			// end mod
		}               
		delete my_pj;
     };

At this point, Labeler.PickStatus needs to run so that its set to "receipt" and that would change the label over the printout (a watermark, basically).

None of the calls to my custom function PickStatus are working, I've tried everything I can think of.

If anyone can help, I'd be really greateful... I'm so lost on actionscript... I've learned a lot of flash in the last few weeks and the last week especially. Kinda burnt out :).

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
The first thing I would do to debug is to add "trace()" to see if you get the expected result.

[tt]//
Labeler.rectype = arrStatus[_global.DMOData.SSTATUS - 3];
trace("Labeler.rectype: "+Labeler.rectype);
//[/tt]

If you're getting the right result, then move on to the next step:

[tt]//
_root.Labeler.PickStatus = function() {
trace("_root.Labeler.PickStatus");
...
}
//[/tt]

...to see if this function is actually being called. If so, move on to the next step. You'll eventually find where the problem is.

By the way "_this" should be "this".

Kenneth Kawamoto
 
Alright..

Tracing rectype gets me the proper value...

I traced the function call in quotes as you said and got the expected string back..

So I tried tracing the function call in both the following ways..

Code:
trace(_root.Labeler.PickStatus);
trace(_root.Labeler.PickStatus());

And I got "undefined"..

So I gave the function something to return and I still get undefined.

I'm really confused here. Thanks for the help so far...

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Thanks for the tip.

Got it working.

I had my function inside my movie, and I don't understand why that didn't work, but when I moved it to the main timeline, it worked. great.

Thanks again.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
If you do:

[tt]trace(_root.Labeler.PickStatus);[/tt]

you should get:

[tt][type Function][/tt]

because "_root.Labeler.PickStatus" is a Function.


If you do:

[tt]trace(_root.Labeler.PickStatus());[/tt]

you should get:

[tt]undefined[/tt]

because "_root.Labeler.PickStatus()" does not return anything.


If you rewrite your "_root.Labeler.PickStatus" function:

[tt]//
_root.Labeler.PickStatus = function():String {
...
return "Boo!";
};
//[/tt]

then do the trace:

[tt]trace(_root.Labeler.PickStatus());[/tt]

you will get:

[tt]Boo![/tt]

because now "_root.Labeler.PickStatus()" returns the string "Boo!".

Kenneth Kawamoto
 
If it would let me give you another star for that additional help, I would.

Thanks!

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top