Tweening with Event in seperate .as

By Vergeet | Jun 25, 2009

actionscript3

i am a little bit lost. i tried to mage a button in my header witch will move the body if clicked, but i am totaly stuck because i dont know how to handle this.

here is the code. maybe someone knows an answer. I left the irrelevant code aside, so that the post is not too long. Thanks a lot!!!

I habve got a main as file with this:

Code:

private function _configUI():void{
                        _header =HeaderUI.getInstance(this);
                        addChild(_header);
                        _side= SideUI.getInstance(this);
                        addChild(_side);
                        _body= BodyUI.getInstance(this);
                        addChild(_body);
                        _footer=FooterUI.getInstance(this)
                        addChild(_footer);
                       
                       
                        _body.addEventListener (BodyOpenEvent.OPEN, _body.bodyOpen, false, 0.0, true);
                        _
                }


a header as with this:

Code:

private function _configUI():void {

                       
                        bg = new HeaderBG();
                        addChild(bg);

                        title = new HeaderTitle();
                        addChild(title);
                        title.x=17;
                        title.y=12;
                        title.buttonMode=true;
                        title.addEventListener(MouseEvent.CLICK, _bodyOpen, false, 0.0, true);
}

public function _bodyOpen(event:MouseEvent):void{
                        dispatchEvent (new BodyOpenEvent(BodyOpenEvent.OPEN, false, true));
                }


an BodOpenEvent with this code:

Code:

package com.gui.events{

        import flash.events.*;

        public class BodyOpenEvent extends Event {

                public static const OPEN:String="open";

                public function BodyOpenEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) {
                        super (type, bubbles, cancelable);

                }
        }
}


and the bodyUi witch contains this:

Code:

import com.gui.events.BodyOpenEvent;

public function bodyOpen(event:BodyOpenEvent):void{
                        /*_bodyOpen =new Tween(bg,"x",Elastic.easeIn,0,100,2,true);*/
                        bg.x=100;
                }


actionscript3

Please reply at our Forum

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

© 2007 ActionScript 3.0