0
votes

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.

1
var tween=TweenMax.to(...) You seemingly mixed up syntaxes for AS3 and Java or alike language.Vesper
I had tried that before already. It gives lots of further errors of: Access of undefined property TweenMax, tween and middle.ArrayOutOfBounds

1 Answers

1
votes

@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.