Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Convert actionscript 2 to actionscript 3

Participant ,
Feb 14, 2019 Feb 14, 2019

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.

TOPICS
ActionScript
4.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 16, 2019 Feb 16, 2019

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.

Translate
Community Expert ,
Feb 14, 2019 Feb 14, 2019

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();

          }

      }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 14, 2019 Feb 14, 2019

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2019 Feb 14, 2019

you can add custom methods to movieclips with as3 just like as2.  (Void in as2 is void in as3). 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 14, 2019 Feb 14, 2019

I'm not very good at programming. Can you give me a example how I do that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 15, 2019 Feb 15, 2019

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

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 15, 2019 Feb 15, 2019

What you mean with this dynamically then I mean methods and can you show me that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 15, 2019 Feb 15, 2019

i showed how to create a remove() method dynamically.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 16, 2019 Feb 16, 2019

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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2019 Feb 16, 2019

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 16, 2019 Feb 16, 2019

Thank you for helping me with to answer my questions. Now I can perhaps continue my own project.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2019 Feb 16, 2019
LATEST

you're welcome.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 14, 2019 Feb 14, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines