0

Trying to get this working in Flash AS3, AIR 3.2 for iOS, using GreenSock. I've tried defining it as a variable, function, etc, to no avail. A search online comes up with nothing.

The following errors come up for the line of code TweenMax tween = TweenMax.to(textOne, 14, {x:xScreenPosEnd, ease:SlowMo.ease.config(1, 0), repeat:-1});:

1071: Syntax error: expected a definition keyword (such as function) after attribute TweenMax, not tween.
1084: Syntax error: expecting rightbrace before leftbrace.
1084: Syntax error: expecting identifier before rightparen.

var middle:Boolean = false;

public function run():void {
    TweenMax tween = TweenMax.to(textOne, 14, {x:xScreenPosEnd, ease:SlowMo.ease.config(1, 0), repeat:-1});
    tween.addEventListener(TweenEvent.UPDATE, updateListener);
    tween.addEventListener(TweenEvent.REPEAT, repeatListener);
}

function updateListener(e:TweenEvent):void {
    if(tween.currentProgress > 0.5 && middle == false)
    {
        TweenMax.to(textOne, 7, {ease:SlowMo.ease.config(1, 0), repeat:-1, autoAlpha:0});
        middle = true;
    }
}

function repeatListener(e:TweenEvent):void {
    textOne.alpha = 1.0;
    middle = false;
}

EDIT: The line in error has been replaced with var tween:TweenMax = TweenMax.to(textOne, 14, {x:xScreenPosEnd, ease:SlowMo.ease.config(1, 0), repeat:-1});
Further errors that come up are:
1120: Access of undefined property TweenMax.
1046: Type was not found or was not a compile-time constant: TweenMax.
1120: Access of undefined property tween.
1120: Access of undefined property middle.

My imports of GreenSock are as follows:

import com.greensock.easing.*;
import com.greensock.plugins.*;
import com.greensock.events.TweenEvent;

Even tried import com.greensock.*;

EDIT: Adding the line import com.greensock.TweenMax; has removed the errors:
1120: Access of undefined property TweenMax.
1046: Type was not found or was not a compile-time constant: TweenMax.

The other two errors still stands.

ArrayOutOfBounds
  • 133
  • 4
  • 19
  • 3
    `var tween=TweenMax.to(...)` You seemingly mixed up syntaxes for AS3 and Java or alike language. – Vesper Feb 11 '13 at 13:04
  • I had tried that before already. It gives lots of further errors of: Access of undefined property TweenMax, tween and middle. – ArrayOutOfBounds Feb 11 '13 at 13:14

1 Answers1

1

@Vesper is absolutely right.

var tween:TweenMax = TweenMax.to(...)

As3 uses the name:Type notation. As for your further errors, they may come from incorrectly referrencing greensock code, but they are a step in the correct direction. Please post them in an edit.

ok let's see :

private var _middle:Boolean = false;
private var _tween:TweenMax;

public function run():void {
    _tween = TweenMax.to(textOne, 14, {x:xScreenPosEnd, ease:SlowMo.ease.config(1, 0), repeat:-1});
    _tween.addEventListener(TweenEvent.UPDATE, updateListener);
    _tween.addEventListener(TweenEvent.REPEAT, repeatListener);
}

private function updateListener(e:TweenEvent):void {
    if(_tween.totalProgress() > 0.5 && _middle == false) {
        TweenMax.to(textOne, 7, {ease:SlowMo.ease.config(1, 0), repeat:-1, autoAlpha:0});
        _middle = true;
    }
}

private function repeatListener(e:TweenEvent):void {
    textOne.alpha = 1.0;
    _middle = false;
}

I'm not sure about functionnality, but this code shouldn't throw errors, provided that textOne actually exists.

ArrayOutOfBounds
  • 133
  • 4
  • 19
Boris
  • 1,161
  • 9
  • 20
  • I have edited my post with the two persisting errors. Could you explain why `import com.greensock.TweenMax;` works and `import com.greensock.*;` doesn't? Does it not import everything within the greensock directory? – ArrayOutOfBounds Feb 11 '13 at 13:40
  • beats me, i must say, .* works in my projects. what IDE are you using? Flash Pro, Flash Builder? FDT? Flash Develop? – Boris Feb 11 '13 at 13:55
  • for your two other errors, I would need to know what scope your code is in. are we in a class? on an animation frame? the variable tween is only available in your function run(), so it fails in updateListener(). for middle I don't know the scope. – Boris Feb 11 '13 at 13:57
  • We are in a class. Everything is done and coded in AS3 – there are no animation frames and the Flash GUI is not used. tween and middle only appear in the provided code above. – ArrayOutOfBounds Feb 11 '13 at 14:05
  • Ok I have edited the response with some additions about scope. It should compile ok. – Boris Feb 11 '13 at 14:14
  • I didn't make the variables global... *facepalm* Should've noticed that. I also tried to edit your answer because there was still a `middle` rather than `_middle` in it. The only error now is the error 119: Access of possibly undefined property currentProgress through a reference with static type com.greensock:TweenMax. coming up. – ArrayOutOfBounds Feb 11 '13 at 14:28
  • that's because TweenMax doesn't have a currentProgress, it has a progress(), though : http://api.greensock.com/as/index.html?com/greensock/TweenMax.html&com/greensock/class-list.html – Boris Feb 11 '13 at 14:39
  • I've updated the answer with the correct functions and syntax. :) Thanks. – ArrayOutOfBounds Feb 11 '13 at 14:54