Skip to main content
Willy_2011
Participant
May 26, 2011
Answered

Converting AS2 to AS3

  • May 26, 2011
  • 1 reply
  • 320 views

Hi All, I have a project which requires me to convert all the AS2 code to AS3. I have finished most of it except the function below.

Could anyone help me out expecially on converting the createTextField("marker_"+id+"_txt",this.getNextHighestDepth(),obj._x,obj._y,0,4); ?

Thanks!

function createMarker(obj:MovieClip,lbl:String):Void
{
this.createTextField("marker_"+id+"_txt",this.getNextHighestDepth(),obj._x,obj._y,0,4);
this["marker_"+id+"_txt"].type = "dynamic";
this["marker_"+id+"_txt"].html = true;
this["marker_"+id+"_txt"].autoSize = "center";
this["marker_"+id+"_txt"].multiline = false;
this["marker_"+id+"_txt"].wordWrap = false;
this["marker_"+id+"_txt"].embedFonts = true;
this["marker_"+id+"_txt"].selectable = false;
this["marker_"+id+"_txt"].antiAliasType = "advanced";
this["marker_"+id+"_txt"].gridFitType = "subpixel";
this["marker_"+id+"_txt"].sharpness = 200;
this["marker_"+id+"_txt"].styleSheet = markerStyle;
this["marker_"+id+"_txt"].htmlText = "<p>"+lbl+".</p>";

obj.swapDepths(this["marker_"+id+"_txt"]);
this["marker_"+id+"_txt"]._x = (obj._x + obj._width/2) - (this["marker_"+id+"_txt"]._width/4);
this["marker_"+id+"_txt"]._y = (obj._y + obj._height/2) - (this["marker_"+id+"_txt"]._height/4);
++id;
}

This topic has been closed for replies.
Correct answer kglad
:

function createMarker(obj:MovieClip,lbl:String):void
{
//this.createTextField("marker_"+id+"_txt",this.getNextHighestDepth(),o bj._x,obj._y,0,4);

this["marker_"+id+"_txt"]=new TextField();


this["marker_"+id+"_txt"].type = "dynamic";
//this["marker_"+id+"_txt"].html = true;
this["marker_"+id+"_txt"].autoSize = "center";
this["marker_"+id+"_txt"].multiline = false;
this["marker_"+id+"_txt"].wordWrap = false;
this["marker_"+id+"_txt"].embedFonts = true;
this["marker_"+id+"_txt"].selectable = false;
this["marker_"+id+"_txt"].antiAliasType = "advanced";
this["marker_"+id+"_txt"].gridFitType = "subpixel";
this["marker_"+id+"_txt"].sharpness = 200;
this["marker_"+id+"_txt"].styleSheet = markerStyle;
this["marker_"+id+"_txt"].htmlText = "<p>"+lbl+".</p>";

var i:int = obj.parent.getChildIndex(obj);


//obj.swapDepths(this["marker_"+id+"_txt"]);

obj.parent.addChildAt(this["marker_"+id+"_txt"],i);

obj.parent.addChild(obj);

this["marker_"+id+"_txt"].x = (obj.x + obj.width/2) - (this["marker_"+id+"_txt"].width/4);
this["marker_"+id+"_txt"].y = (obj.y + obj.height/2) - (this["marker_"+id+"_txt"].height/4);
++id;
}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 26, 2011
:

function createMarker(obj:MovieClip,lbl:String):void
{
//this.createTextField("marker_"+id+"_txt",this.getNextHighestDepth(),o bj._x,obj._y,0,4);

this["marker_"+id+"_txt"]=new TextField();


this["marker_"+id+"_txt"].type = "dynamic";
//this["marker_"+id+"_txt"].html = true;
this["marker_"+id+"_txt"].autoSize = "center";
this["marker_"+id+"_txt"].multiline = false;
this["marker_"+id+"_txt"].wordWrap = false;
this["marker_"+id+"_txt"].embedFonts = true;
this["marker_"+id+"_txt"].selectable = false;
this["marker_"+id+"_txt"].antiAliasType = "advanced";
this["marker_"+id+"_txt"].gridFitType = "subpixel";
this["marker_"+id+"_txt"].sharpness = 200;
this["marker_"+id+"_txt"].styleSheet = markerStyle;
this["marker_"+id+"_txt"].htmlText = "<p>"+lbl+".</p>";

var i:int = obj.parent.getChildIndex(obj);


//obj.swapDepths(this["marker_"+id+"_txt"]);

obj.parent.addChildAt(this["marker_"+id+"_txt"],i);

obj.parent.addChild(obj);

this["marker_"+id+"_txt"].x = (obj.x + obj.width/2) - (this["marker_"+id+"_txt"].width/4);
this["marker_"+id+"_txt"].y = (obj.y + obj.height/2) - (this["marker_"+id+"_txt"].height/4);
++id;
}