2010-05-03 7 views
1

J'ai un projet dont j'ai besoin de mettre à jour le formulaire AS2 vers AS3 car j'ai besoin de certaines des nouvelles fonctions disponibles pour le centrage vertical du texte.Besoin d'aide avec la conversion Flash AS2 vers AS3, ayant des problèmes majeurs

Mon code AS2 actuel sur la ligne de temps est le suivant.

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

Et mon fichier AS externe est comme suit.

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

} 

Voici ma tentative de chronologie en mouvement et AS2 externe à AS3

Timeline i maintenant:

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 externe i ont

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

} 
} 

Les erreurs i am obtenir actuellement sont:

Scène 1, Couche 'Etiquette', Cadre 1, Ligne 6 1120: Accès à la propriété non définie _root. Scène 1, Calque 'Étiquette', Image 1, Ligne 7 1137: Nombre incorrect d'arguments. Attendu pas plus de 1.

Si quelqu'un pouvait m'aider à résoudre ce problème, je l'apprécierais beaucoup.

Sincères salutations Mat.

+0

Je ne suis pas vraiment sûr de ce que vous demandez - Il peut être utile si vous postez les erreurs que vous obtenez, ou le code que vous avez essayé en AS3, afin que nous puissions aider comprendre où vous allez mal. – quoo

+0

Salut Quoo j'ai ajouté ce que j'ai actuellement à la fin du message original, j'espère que c'est plus instructif.Merci :) – Mat

Répondre

1

N'utilisez pas _root, si vous avez absolument besoin de référencer vers le haut, l'équivalent AS3 le plus proche est le niveau.

Les propriétés DisplayObject ne commencent plus par un trait de soulignement (_alpha par rapport à alpha dans votre cas).

Vous ne pouvez pas utiliser onRelease, vous devez utiliser addEventListener()

Votre code de calendrier fait peu, le sens, pourquoi faites-vous vars locales?

Dans l'ensemble, je vous recommande de lire sur Adobe's migration guide.

+0

Je suis désolé si cela vient comme un peu dur, mais votre code a besoin essentiellement une réécriture complète. – grapefrukt

+0

Oh :(, je pensais que cela pourrait être le cas, j'ai essayé de changer les bits ici et là pour le faire fonctionner en AS3. Les variables locales sont transmises à partir d'une page php dynamique du bouton comme un bouton de navigation . – Mat

0

changement

_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/

Questions connexes