Skip to main content
Participant
November 19, 2013
Question

As2 code to As3 conversion please

  • November 19, 2013
  • 2 replies
  • 451 views

Hey, could someone help me converting the following code to AS3. Thanks for any help..

id=_root.id;

if(this._y<>_root.txk){

this._y=_root.txk;

_root.txk+=60;

}

this._x=_root.txx;

textyazı="";

onEnterFrame=function(){

this._name=namet.text;

if(_root.txk==360){

_root.txx+=60;

_root.txk=60;

}

this.onPress=function(){

if(_root["t"+namet.text].txtn.text<>namet.text){

_root.attachMovie("txt_dd","t"+namet.text,_root.derinlik);

_root["t"+namet.text]._x=100;

_root["t"+namet.text]._y=100;

_root["t"+namet.text].txtyname.text=namet.text;

_root["t"+namet.text].txtn.text=namet.text;

_root["t"+namet.text].txtyazılar.text=textyazı;

_root.derinlik++;

}

}

}

///////////////

txtac = SharedObject.getLocal(id);

setInterval(function(){

if(txtac.data.namet<>"" && txtac.data.id>0){

namet.text=txtac.data.namet;

textyazı=txtac.data.textyazı;

id=txtac.data.id;

}else{

namet.text=_name;

}

if(namet.text=="undefined"){

          namet.text=_name;

}

if(textyazı==undefined){

          textyazı="";

}

},50);

this.useHandCursor=false;

This topic has been closed for replies.

2 replies

Inspiring
November 20, 2013

1.download flashdevelop (Flash has bad code hinting and error descriptions)

2.start with deleting underscores in _root,_x,_y

3.work your way up from there

4.Lines like:

this.onPress=function

are probably attached directly to a button or MovieClip: This is not possible in as3 anymore. You have to take the code out of the button and put it on the timeline of the button, if it is a MovieClip.

5.The Event Model has changed considerably:

onEnterFrame=function(){

// do stuff here

}

is now

addEventListener(ENTER_FRAME, enterFrameHandler);

function enterFrameHandler(e:Event):void{

//do stuff here

}

kglad
Community Expert
Community Expert
November 19, 2013

that's terrible coding.  it looks like it's from a commercial template notorious for terrible coding.

if there's more coding than the snippet your showed, it's not worth converting.  you should start over and code it properly.