Jump to content
Search Community

AS2 to AS3

volkangundogdu test
Moderator Tag

Recommended Posts

Hi, I'm new to GSAP and have got an issue with an animation that worked in AS2 but isn't in AS3. I've changed the values so they are AS3 but if someone could tell me what i'm doing wrong, that would be a great help.

 

I see this error message 4 times when i compile is "1046: Type was not found or was not a compile-time constant: Void."

 

I've copied my code below.

 

Thanks for your help.


import com.greensock.TweenNano;
import com.greensock.easing.Quad;

var textWidth:Number = 500; // width that the mask needs to extend to to reveal longest copy
var revealSpeed:Number = 2; // Speed at which the mask reveals the copy
var fadeSpeed:Number = 0.5; // speed that MovieClips fade out 

var startTime:Date; // Used for timing the banner animation duration
var endTime:Date; // Used for timing the banner animation duration

{
// Entry point
function init():Void{
	//image2_mc._x = -546.15;
	//image2_mc._y = -795.15;
	
	
	showFrame1();
}
}

function revealCopy(mc:MovieClip):Void{
	TweenNano.to(mc.mask_mc, revealSpeed,{_width:textWidth, ease:Linear.easeNone});
}


function showFrame1():Void{
	startTime = new Date();
	//TweenNano.to(image1_mc,2, {_alpha:100, ease:Quad.easeInOut, delay:2}); // Fade in first image
	TweenNano.to(ifWeLogo_mc, 1, {_alpha:100, delay:1});
	TweenNano.delayedCall(1.5, revealCopy, [copy1_mc ]);
	TweenNano.delayedCall(2.5, revealCopy, [copy2_mc ]);
	TweenNano.delayedCall(4.5, revealCopy, [copy3_mc ]);
	TweenNano.delayedCall(5.8, revealCopy, [copy4_mc ]);
	TweenNano.to(compass_mc, 1.5, {_alpha:100, delay:7.5});
	TweenNano.to(copy5_mc, 1.5, {_alpha:100, delay:8});
	TweenNano.to(image1_mc, 16, {x:-100, y:-8, xscale:85, yscale:85, delay:9, ease:Quad.easeInOut, onComplete:testLooping});

}


function testLooping():Void{
	loopNum++;
	if(loopNum < maxLoops){
		trace('replay');
	}else{
		endTime = new Date();
		trace(startTime-endTime);
	}
}


init();
Link to comment
Share on other sites

You've mixed up a lot of the property names and values from AS3 and AS2...

 

AS2  --> AS3

_width --> width
_height --> height
_xscale --> scaleX
_yscale --> scaleY
_alpha --> alpha (in AS2, the values went from 0-100, but AS3 goes from 0-1)
  • Like 1
Link to comment
Share on other sites

Thanks gents, thats been very useful.

 

I've done those but i'm still getting a issues.

 

Scene 1, Layer 'Layer 1', Frame 1, Line 24, Column 62 1120: Access of undefined property Linear.
Scene 1, Layer 'Layer 1', Frame 1, Line 44, Column 2 1120: Access of undefined property loopNum.
Scene 1, Layer 'Layer 1', Frame 1, Line 45, Column 5 1120: Access of undefined property loopNum.
Scene 1, Layer 'Layer 1', Frame 1, Line 45, Column 15 1120: Access of undefined property maxLoops.
Scene 1, Layer 'Layer 1', Frame 1, Line 49, Column 9 1067: Implicit coercion of a value of type Date to an unrelated type Number.
Scene 1, Layer 'Layer 1', Frame 1, Line 49, Column 19 1067: Implicit coercion of a value of type Date to an unrelated type Number.
Link to comment
Share on other sites

Scene 1, Layer 'Layer 1', Frame 1, Line 24, Column 62 1120: Access of undefined property Linear.

you are not importing the Linear ease. You are only importing the Quad ease with

import com.greensock.easing.Quad;

use

import com.greensock.easing.*;

to import all the eases (only the eases you use will get compiled into your swf)

 

The other errors are fairly straightforward

 

Scene 1, Layer 'Layer 1', Frame 1, Line 44, Column 2 1120: Access of undefined property loopNum.
Scene 1, Layer 'Layer 1', Frame 1, Line 45, Column 5 1120: Access of undefined property loopNum.
Scene 1, Layer 'Layer 1', Frame 1, Line 45, Column 15 1120: Access of undefined property maxLoops.

you are not defining or assigning a value to loopNum or maxNum anywhere.

 
you should have something like
var loopNum:Number = 0;
var maxLoops:Number = 3;

and lastly a new Date() is not an integer, check out the AS3 docs for more help 

 

Hopefully this gets you on the right track. Unfortunately, there isn't a lot more we can do to help with these generic conversion errors. 

If you have any more questions about GreenSock tools, please let us know.

Good luck with your project.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...