2010-05-03 46 views
1

我有一个项目,我需要更新表格AS2到AS3,因为我需要一些新的功能可用于垂直居中文本。帮助需要与Flash AS2到AS3转换,有重大问题

我在时间线上的当前AS2代码如下。

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

而我的外部AS文件如下。

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

} 

这是我在移动的时间表和外部AS2到AS3

时间轴的尝试,我现在:

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

外部AS3我有

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

} 
} 

我是错误的目前得到的是:

场景1,图层'标签',第1帧,第6行1120:访问未定义属性_root。 场景1,图层“标签”,第1帧,第7行1137:参数的数量不正确。预计不会超过1.

如果有人能帮助我解决这个问题,我将非常感激。

亲切的问候 垫。

+0

我真的不知道你在问什么 - 如果你发布你得到的错误,或者在AS3已经尝试了代码可能有帮助,所以我们可以帮助找出你要出错的地方。 – quoo 2010-05-03 15:12:54

+0

嗨quoo我已经添加了我目前已有的原始帖子的结尾,希望这是更多的信息。谢谢:) – Mat 2010-05-03 16:02:33

回答

1

不要使用_root,如果您绝对需要向上引用,则最接近的AS3等效阶段。

DisplayObject属性不再以下划线开始(_alphaalpha在你的情况下)。

不能使用onRelease,你需要使用的addEventListener()

你的时间轴代码没有什么,某种意义上说,你为什么做本地变量?

总而言之,我建议你阅读Adobe's migration guide

+0

对不起,如果这有点苛刻,但你的代码基本上需要一个完整的重写。 – grapefrukt 2010-05-03 16:15:42

+0

哦亲爱的:(我认为这可能是这种情况,我试图改变位在这里和那里让它在AS3中工作 局部变量从动态PHP页面传递到按钮作为其导航按钮。 – Mat 2010-05-03 16:22:01

0

变化

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

mc.addEventListener(MouseEvent.CLICK, mcClicked) 
function mcClicked(e:Event) { 
    navigateToURL(new URLRequest("index.php?page="+dataPage+"&num="+dataNum+"&"+dataType+"="+dataVar, "_self")); 
} 

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/MouseEvent.html#MouseEvent%28%29

highlight._alpha = 0;highlight.alpha = 0;

highlightTween = new Tween(highlight, "_alpha", fl.transitions.easing.Regular.easeInOut, 100, 0, 10, false); 

highlightTween = new Tween(highlight, "alpha", Regular.easeInOut, 100, 0, 10, false); 

http://www.republicofcode.com/tutorials/flash/as3tweenclass/