1

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();
        }
Demonoid
  • 11
  • 2
  • The best recommendation I can give is to not use Gaia. – citizen conn Aug 15 '11 at 18:12
  • Thanks, I have already decided not to use it in my next project as it is just a handicap for me. But I'll have to finish this part of my project with it as I'm getting nearer the deadline – Demonoid Aug 15 '11 at 19:02
  • Confused by that newest code block. Class ClubPage, constructor HomePage? – Sam DeHaan Aug 17 '11 at 17:16
  • sorry, I changed it from home to club and it stayed there, but even when fixed the flash debugger keeps sendind the same error. 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. Reading the flash docs I found that I am supposed to addChild the emitter which is a sprite but as you can see this.addChild won't work. – Demonoid Aug 17 '11 at 17:30
  • For mouse interaction, look to my example --> [link](http://stackoverflow.com/questions/7508240/find-distance-between-2-points-in-fastest-way/7508280#7508280) – Katax Emperore Sep 22 '11 at 04:46

0 Answers0