Copy link to clipboard
Copied
I want help with converting codes from actionscript 2 to actionscript 3. I use bold style codes to change.
How I do this if this it is coded from actionscript 2 to actionscript 3 below here.
private static function createText(scope:MovieClip, phrase:String, x:Number, y:Number, format:TextFormat):MovieClip {
var teText:MovieClip = scope.createEmptyMovieClip("ascTextPhrase" + scope.getNextHighestDepth(), scope.getNextHighestDepth());
teText.characterArray = new SatoriArray();
teText.remove = function(m:MovieClip):Void {
this.characterArray.removeItem(m);
m.removeMovieClip();
if(this.characterArray.length == 0) {
this.removeMovieClip();
}
}
Similarly, this code also converts to actionscript 3.
Have declared these
private var removeSelf:Function;
var l:Number = phrase.length;
for(var i:Number = 0; i < l; i++) {
var m:MovieClip = TextScript.createCharacter(teText, phrase.substr(i, 1), format);
m.removeSelf = function() {
this._parent.remove(this);
}
m._x = x;
m._y = y;
m.characterLength = l;
teText.characterArray.push(m);
x += format.getTextExtent(m.field.text).width;
}
Similarly, this code also converts to actionscript 3.
Have declared these
private var onEnterFrame:Function;
private static function configureEffect(m:MovieClip, effect:Function, delay:Number) {
var l:Number = m.characterArray.length;
while(l--) {
var char:MovieClip = m.characterArray
char.delay = delay * l;
char.frameCount = 0;
char.onEnterFrame = Delegate.create(char, effect);
}
}
Delegate is not included in actionscript 3 but in which other way can replace it.
no, you need to create a removeItem method yourself:
teText.removeItem = function(e:*):void{
a.removeAt(a.indexOf(e));
}
and i don't know about using a delegate function in as3 because there's no need.
Copy link to clipboard
Copied
you have more to replace than just the bolded code. for example, your first snippet:
private static function createText(scope:MovieClip, phrase:String, x:Number, y:Number, format:TextFormat):MovieClip {
var teText:MovieClip = new MovieClip();
teText.name ="ascTextPhrase";
scope.addChild(teText);
// don't know what this is supposed to do
teText.characterArray = new SatoriArray();
teText.remove = function(m:MovieClip):Void {
this.characterArray.removeItem(m);
m.removeMovieClip();
if(this.characterArray.length == 0) {
this.removeMovieClip();
}
}
}
Copy link to clipboard
Copied
Thanks for your answer and you wanted to help me.
So you don't know how to do this teText.remove = function(m:MovieClip):Void { in actionscript 3.
Of course, I can replace removeMovieClip () with removeaddChild in actionscript 3.
These codes come from Satori Canton and he has made a text animation where he created a class file in .as and .fla
You have no response from the other snippet in the bold text.
Copy link to clipboard
Copied
you can add custom methods to movieclips with as3 just like as2. (Void in as2 is void in as3).
Copy link to clipboard
Copied
I'm not very good at programming. Can you give me a example how I do that.
Copy link to clipboard
Copied
it would be better to create those methods in a class, but you can do it dynamically:
private static function createText(scope:MovieClip, phrase:String, x:Number, y:Number, format:TextFormat):MovieClip {
var teText:MovieClip = new MovieClip();
teText.name ="ascTextPhrase";
scope.addChild(teText);
teText.remove=function(m:MovieClip):void{
// do whatever
}
}
Copy link to clipboard
Copied
What you mean with this dynamically then I mean methods and can you show me that.
Copy link to clipboard
Copied
i showed how to create a remove() method dynamically.
Copy link to clipboard
Copied
Thanks a lot for the tips.
Do you know if this code is blue removeItem() included in actionscript 2.0
Something completely different
Delegate is not included in Actionscript 3.0 and if I in this that you can create in a delegate in this class
Do you know where I can put this class in the Animate CC program.
In this place C:\Program Files\Adobe\Adobe Animate CC 2018\Common\First Run\Classes\FP8
package {
public class Delegate
{
public static function create(handler:Function, ... args):Function {
return function(... innerArgs):void {
handler.apply(this,innerArgs.concat(args));
}
}
}
}
Here I use it.
import flash.utils.setTimeout;
setTimeout(Delegate.create(func, "param1text", "param2text"), 1000);
function func(param1:String, param2:String):void {
trace("func param1=" + param1 + " param2=" + param2);
}
Copy link to clipboard
Copied
no, you need to create a removeItem method yourself:
teText.removeItem = function(e:*):void{
a.removeAt(a.indexOf(e));
}
and i don't know about using a delegate function in as3 because there's no need.
Copy link to clipboard
Copied
Thank you for helping me with to answer my questions. Now I can perhaps continue my own project.
Copy link to clipboard
Copied
you're welcome.
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Copy link to clipboard
Copied
Here you have the Text animation and the files that are in Actionscript 2.0 that I want in Actionscript 3.0 https://drive.google.com/open?id=1SF03HJMFiVoN6t_ZEiDY3cLBSSUoE2SX TextScript_Injection_sample2.fla https://drive.google.com/open?id=1ax7RLusWC5aqt9EyYdM4zcuqdmDNX0N8 TextScript_Injection_sample2.swf https://drive.google.com/open?id=1qJEOU6xdeN4RA4kucm5WOfUrmuVyLCB6 TextScript.as
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more