AS3 gaia和粒子效应问题

时间:2011-08-15 18:09:53

标签: flash actionscript-3 particles gaia

编辑:我改变了代码。我在最后一个代码块(第三个)中实现了它,它是前两个原件。

我有一个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);
    }
}

第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.physics :: 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();
        }

0 个答案:

没有答案