AS3 gaia和粒子效应问题
编辑:我更改了代码。我在最后一个代码块(第三个)中实现了它,这是前两个原始代码块。
我有一个盖亚网站,在其页面之一应该有背景粒子效果。 摘自http://blog.soulwire.co.uk/flash /actionscript-3/as3-alphabet-articles
但是,当导入并尝试使用它时,我只收到错误,并且我不知道应该去哪个方向来创建它:
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);
}
}
第 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:无法访问空对象引用的属性或方法。 在 com.soulwire.physicals::ParticleEmitter() 在 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();
}
EDIT: I changed the code. I implemented it in the last code block (third), being the first two originals.
I have a gaia website, in one of its pages there should be a background particle effect.
taken from http://blog.soulwire.co.uk/flash/actionscript-3/as3-alphabet-particles
But when importing and trying to use it I only get errors and I do not know what direction should I go to to create it:
PAGE01: Page which intends to use the effect:
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: And as you can see in the particle effect source code of the above link, I'm trying to implement this code on 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();
}
}
I've tried copypaste and trying to adapt but nothing works, I have spent 2 days but nothing comes to my mind on what possible errors there are.
If anybody knows gaia, as3, and knows how he would implement this please guide me through.
Thanks
EDIT: This is my implementation, I keep getting null references errors: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.soulwire.physics::ParticleEmitter()
at com.pages::ClubPage()
Cannot display source code at this location.
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();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论