I define a function and try and run it but it won’t run, if i take the code out of the function it runs fine and I can’t work out why, here is the function and the call…
function Boomclat() {
var TweenX:Tween = new Tween(this, "_x", mx.transitions.easing.Strong.easeOut, this._x, 16.9, 1, true);
var TweenY:Tween = new Tween(this, "_y", mx.transitions.easing.Strong.easeOut, this._y, listY, 1, true);
}
Boomclat();
Here is my whole code (on this MC, there is more outside):
onClipEvent (load) {
import mx.transitions.Tween;
import mx.transitions.easing.*;
startX = this._x;
startY = this._y;
mn = 0;
}
onClipEvent (enterFrame) {
this.onRollOver = function() {
this.gotoAndStop("over");
};
this.onRollOut = function() {
this.gotoAndStop("up");
};
this.onPress = function() {
this.gotoAndStop("down");
};
this.onReleaseOutside = function() {
this.gotoAndStop("up");
};
this.onRelease = function() {
this.gotoAndStop("up");
this.enabled = false;
this.arrow.gotoAndStop("ordered");
if (_global.hasAnswered != 1) {
this.arrow.listNumber = this._parent.Order.length+1;
listY = 35+(74.9*this._parent.Order.length);
this._parent.Order.push(this);
function Boomclat() {
var TweenX:Tween = new Tween(this, "_x", mx.transitions.easing.Strong.easeOut, this._x, 16.9, 1, true);
var TweenY:Tween = new Tween(this, "_y", mx.transitions.easing.Strong.easeOut, this._y, listY, 1, true);
};
Boomclat();
this._parent.buttonHolder.previousOrder.push(this);
} else {
for (i=0; i<this._parent.trueOrder.length; i++) {
if (this == this._parent.trueOrder[i]) {
_global.previousButton.enabled = true;
_global.previousButton.gotoAndStop("up");
myColor = new Color(_global.previousButton);
myColor.setTint(255,255,255,0);
myColor = new Color(this);
myColor.setTint(113,205,0,23);
this.gotoAndStop("down");
var TweenX:Tween = new Tween(_global.lastText, "_x", mx.transitions.easing.Back.easeOut, 276.4, -210, 0.7, true);
_global.whichText = this._parent.textFile[i];
var TweenX:Tween = new Tween(_global.whichText, "_x", mx.transitions.easing.Back.easeOut, 760, 276.4, 0.7, true);
_global.lastText = whichText;
_global.previousButton = this;
}
}
}
};
}
Anyone can see what’s wrong? Cheers.
Strangely enough if I define the function before the onRelease it works… here is final code: