Help needed with Flash AS2 to AS3 conversion, having major problems...

Posted by Mat on Stack Overflow See other posts from Stack Overflow or by Mat
Published on 2010-05-03T11:37:14Z Indexed on 2010/05/03 16:18 UTC
Read the original article Hit count: 304

Filed under:
|
|
|
|

Hi all,

I have a project i need to update form AS2 to AS3 as i need some of the new functions available for vertical centering of text.

My current AS2 code on the time line is as follows.

var dataField =  _root.dataField;
var dataType =  _root.dataType;
var dataPage =  _root.dataPage;
var dataVar =  _root.dataVar;
_root.mc.onRelease = function() {
    getURL("index.php?page="+dataPage+"&num="+dataNum+"&"+dataType+"="+dataVar, "_self");
};

And my external AS file is as follows.

import mx.transitions.Tween;

/**
 *
 *  StandardKey is attached to a movieclip in the library.
 *  It handles the basic button behavior of the keyboard keys.
 *  When each button is placed on the stage, it's instance name
 *  will be the unique ID of the key.
 *
 */
class StandardKey extends MovieClip {


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

    //Stage Elements    
    var highlight:MovieClip;
    //End Stage Elements
    var highlightTween:Tween;

    function StandardKey(Void) {
                //Repaint the key with 0 alpha
        highlight._alpha = 0;
    }


    function onPress(Void):Void {

        //Do the highlight animation
        highlightTween.stop();
        highlightTween = new Tween(highlight, "_alpha", mx.transitions.easing.Regular.easeInOut, 100, 0, 10, false);
    }

}

Here is my attempt at moving timeline and external AS2 to AS3

Timeline i now have :

var dataField =  this.dataField;
var dataType =  this.dataType;
var dataPage =  this.dataPage;
var dataVar =  this.dataVar;
var dataNum =  this.dataNum;
_root.mc.onRelease = function() {
navigateToURL(new URLRequest("index.php?page="+dataPage+"&num="+dataNum+"&"+dataType+"="+dataVar, "_self"));
};

External AS3 i have

package {
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.MovieClip;

/**
 *
 *  StandardKey is attached to a movieclip in the library.
 *  It handles the basic button behavior of the keyboard keys.
 *  When each button is placed on the stage, it's instance name
 *  will be the unique ID of the key.
 *
 */
public class StandardKey extends MovieClip {


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

    //Stage Elements    
    var highlight:MovieClip;
    //End Stage Elements
    var highlightTween:Tween;

    public function StandardKey(Void) {
                //Repaint the key with 0 alpha
        highlight._alpha = 0;
    }


    public function onPress(Void):void {

        //Do the highlight animation
        highlightTween.stop();
        highlightTween = new Tween(highlight, "_alpha", fl.transitions.easing.Regular.easeInOut, 100, 0, 10, false);
    }

}
}

The errors i am currently getting are :

Scene 1, Layer 'Label', Frame 1, Line 6 1120: Access of undefined property _root. Scene 1, Layer 'Label', Frame 1, Line 7 1137: Incorrect number of arguments. Expected no more than 1.

If any one could help me work this out i would appreciate it very much.

Kind regards Mat.

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about as2