编辑:我更改了代码。我在最后一个代码块(第三个)中实现了它,即前两个原件。
我有一个 gaia 网站,其中一个页面应该有背景粒子效果。取自http://blog.soulwire.co.uk/flash/actionscript-3/as3-alphabet-particles
但是当导入并尝试使用它时,我只会得到错误,我不知道我应该去哪个方向来创建它:
PAGE01:打算使用效果的页面:
import com.gaiaframework.templates.AbstractPage;
import com.gaiaframework.events;
import com.gaiaframework.debug;
import com.gaiaframework.api;
import flash.display.*;
import flash.events.*;
import com.greensock.TweenMax;
public class ClubPage extends AbstractPage
{
public var ButtonInicio:MovieClip;
public var NavArray:Array;
public function ClubPage()
{
super();
alpha = 0;
ButtonInicio.branch = Pages.HOME;
NavArray = [ButtonInicio];
for each (var button:MovieClip in NavArray)
{
button.buttonMode = true;
button.mouseChildren = false;
button.addEventListener(MouseEvent.CLICK, onClick, false,0,true);
}
}
override public function transitionIn():void
{
super.transitionIn();
TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
}
override public function transitionOut():void
{
super.transitionOut();
TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
for each (var button:MovieClip in NavArray)
{
button.removeEventListener(MouseEvent.CLICK, onClick);
}
}
private function onClick(e:MouseEvent):void
{
Gaia.api.goto(e.target.branch);
}
}
PAGE 02:正如您在上面链接的粒子效果源代码中看到的那样,我正在尝试在 PAGE01 上实现此代码:
import com.soulwire.physics.ParticleEmitter;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;
public class Club extends Sprite
{
/*
========================================================
| Private Variables | Data Type
========================================================
*/
private var emitter:ParticleEmitter;
/*
========================================================
| Constructor
========================================================
*/
public function Club()
{
stage.align = 'TL';
stage.scaleMode = 'noScale';
emitter = new ParticleEmitter(stage,false,'TestParticle',20,8,[2,4],[10,100],5,0,0,'wander');
emitter.x = stage.stageWidth / 2;
emitter.y = stage.stageHeight / 2;
addChild( emitter );
emitter.init();
}
}
我尝试过复制粘贴并尝试适应,但没有任何效果,我花了 2 天时间,但没有想到可能存在的错误。如果有人知道 gaia,as3,并且知道他将如何实现这一点,请指导我完成。谢谢
编辑:这是我的实现,我不断收到空引用错误:TypeError:错误#1009:无法访问空对象引用的属性或方法。at com.soulwire.physics::ParticleEmitter() at com.pages::ClubPage() 无法在此位置显示源代码。
import com.soulwire.physics.ParticleEmitter;
public class ClubPage extends AbstractPage
{
var emitter:ParticleEmitter;
public function ClubPage()
{
super();
alpha = 0;
emitter = new ParticleEmitter(stage,false,'TestParticle',20,8,[2,4],[10,100],5,0,0,'wander');
this.addChild( emitter );
emitter.x = stage.stageWidth / 2;
emitter.y = stage.stageHeight / 2;
emitter.init();
}