您好我尝试将我的Arry传递给Class。我尝试传递它,它看起来像这样:
早期的第32帧是一些动画。
import flash.events.MouseEvent;
import fl.transitions.Tween;
import flash.display.MovieClip;
import Wyjazd;
stop();
ofertaBTN.addEventListener(MouseEvent.CLICK, wyskok);
function wyskok(e:MouseEvent)
{
var vektor:Array = new Array(I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII);
var menu:Wyjazd = new Wyjazd(vektor);
}
类
package
{
import fl.transitions.Tween;
import fl.motion.easing.*;
import flash.filters.*;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.display.MovieClip;
public class Wyjazd extends MovieClip
{
public function Wyjazd(ar:Array)
{
var xX = ar.x;
var time:Number = 2;
var offset:Number = 0;
for (var i:Number = 0; i < 12; i++)
{
var tween:Tween = new Tween(ar[i],"x",Sine.easeOut,ar[i].x,266.65 + offset,time,true);
ar[i].addEventListener(MouseEvent.MOUSE_OVER,podswietlenie);
ar[i].addEventListener(MouseEvent.MOUSE_OUT,zgaszenie);
time += 0.2;
offset += 15.25;
}
function zgaszenie(e:MouseEvent)
{
ar[i].filters = [];
}
function podswietlenie(e:MouseEvent)
{
var pods:GlowFilter = new GlowFilter ;
pods.inner = false;
pods.color = 0x000000;
pods.knockout = false;
ar[i].filters = [pods];
}
/*var targetLabel:String;
ar.addEventListener(MouseEvent.MOUSE_OVER, podswietlenie);
ar.addEventListener(MouseEvent.MOUSE_OUT, zgaszenie);
ar.addEventListener(MouseEvent.CLICK,przejscie);
function przejscie(e:MouseEvent)
{
targetLabel= e.currentTarget.name;
tween = new Tween(ar,"x",Sine.easeOut,ar.x,xX,time,true);
trace(targetLabel);
}*/
}
}
}
但我仍然得到错误#1063。它说我没有通过论证。怎么通过它?你能帮助我吗?
更新#1: 我用try try trace。帧代码不是机会,但Class看起来像这样。
package
{
import fl.transitions.Tween;
import fl.motion.easing.*;
import flash.filters.*;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.display.MovieClip;
public class Wyjazd extends MovieClip
{
public function Wyjazd(ar:Array)
{
trace(ar.length);
//reast is commented
}
}
}
但是,我还有错误#1063,我们必须更深入。然后我改变了帧代码:
import flash.events.MouseEvent;
import fl.transitions.Tween;
import flash.display.MovieClip;
stop();
ofertaBTN.addEventListener(MouseEvent.CLICK, wyskok);
function wyskok(e:MouseEvent)
{
var vektor:Array = [I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII];
trace(vektor.lenght);
//var menu:Wyjazd = new Wyjazd(vektor);
}
现在我在非构造函数上尝试了错误#1007实例化。 at site_fla :: MainTimeline / wyskok()
答案 0 :(得分:1)
看起来你打算引用数组中的每个值:
new Array('I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII');
答案 1 :(得分:0)
为了缩小范围,我建议将你的Wyjazd函数代码注释掉并用跟踪语句替换它,例如trace(ar.length);
看看你是否可以运行它,以及它是否跟踪数组长度。如果可以,那么问题不在于将数组传递给函数。
我能够测试这个,当我创建它时它对我有用,这就是为什么我建议上面这个。
如果它仍然抛出相同的错误,那么你可以向我提供更多信息吗?
答案 2 :(得分:0)
试试这个:
var vektor:Array = [I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII];
另外,我认为这一行不正确:
var xX = ar.x;
..顺便说一下,你也可以改变这个
// for (var i:Number = 0; i < 12; i++)
for (var i:int = 0; i < ar.length; i++)
答案 3 :(得分:0)
您不能拥有IDE中实例的符号参数,请查看类似的问题并回答:AS3 not accepting constructor
你必须尝试不同地初始化你的课程,但这实际上取决于你的用法
例如:
public class Wyjazd extends MovieClip
{
public function Wyjazd(ar:Array=null) // use a default parameter
{
if (ar!=null) init(ar) // call your init function
}
public function init(ar:Array):void {
var xX = ar.x;
var time:Number = 2;
var offset:Number = 0;
for (var i:Number = 0; i < 12; i++)
{
var tween:Tween = new Tween(ar[i],"x",Sine.easeOut,ar[i].x,266.65 + offset,time,true);
ar[i].addEventListener(MouseEvent.MOUSE_OVER,podswietlenie);
ar[i].addEventListener(MouseEvent.MOUSE_OUT,zgaszenie);
time += 0.2;
offset += 15.25;
}
function zgaszenie(e:MouseEvent)
{
ar[i].filters = [];
}
function podswietlenie(e:MouseEvent)
{
var pods:GlowFilter = new GlowFilter ;
pods.inner = false;
pods.color = 0x000000;
pods.knockout = false;
ar[i].filters = [pods];
}
/*var targetLabel:String;
ar.addEventListener(MouseEvent.MOUSE_OVER, podswietlenie);
ar.addEventListener(MouseEvent.MOUSE_OUT, zgaszenie);
ar.addEventListener(MouseEvent.CLICK,przejscie);
function przejscie(e:MouseEvent)
{
targetLabel= e.currentTarget.name;
tween = new Tween(ar,"x",Sine.easeOut,ar.x,xX,time,true);
trace(targetLabel);
}*/
}
}
}