Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Button Class



Hi everybody. I'm working on making my buttons more... OOPie? It's killing me. I used a target to load the movie clip I'd like to dump images into so I can make buttons the way I know they're supposed to be made but as hard as I try I can't add things to that movie clip from within that same file.I need a life line.
PHP Code:


package components{    import flash.display.Sprite;    import flash.events.Event;    import flash.display.Loader;    import flash.net.URLRequest;    import flash.display.Bitmap;    import flash.display.MovieClip;    public class ImageLoader extends Loader    {        private var target:Object;        private var playup:String;        private var playover:String;        private var objx:int;        private var objy:int;        private var _playbtn=new MovieClip;        public function ImageLoader(target:*, playup:String, playover:String, objx:int, objy:int) {                        this.target = target;            this.playup = playup;            this.playover = playover;            this.x = objx;            this.y = objy;            this.target.addChild(_playbtn);            init(this.playup);        }        private function init(loadimg):void        {            this.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);            var request:URLRequest=new URLRequest(loadimg);            this.load(request);        }        private function completeHandler(event:Event):void{            var _image:Bitmap=Bitmap(this.content);            #### "this.target + _playbtn" .addChild(_image); ????        }    }} 



KirupaForum > Flash > ActionScript 3.0
Posted on: 12-27-2007, 12:36 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Button Created Within Class Cannot Access Class Properties
Hi,
I'm using the following code within a class:
code:
_head_mc.attachMovie("headButton", "head_btn", this.getNextHighestDepth());

_head_mc.head_btn.onRelease = function () {
containingClip_mc._parent._parent.clickedHead(_per sonName);
}


The button gets attached (line 1). This works because I can see the mouse changing to a finger.

The onRelease function is declared and works. I know because if I put a trace in there, it works.

The function it calls (containingClip_mc._parent._parent.clickedHead also works, becuase I can see traces from within it.

But the _personName variable is passed as undefined.

I know that this variable has a value, because I can trace it outside the function, but it seems that this onRelease function is not able to see the variable. It's declared as private, but setting it to public doesn't fix anything.

I imagine there's something I don't understand about the scoping of variables. I've tried _parent references, but that doesn't appear to help either. Is there a better way to do this or a workaround?

Barrette

Added by edit
Okay, I've pretty much determined this is a scoping issue. From the onRelease function, I'm unable to access ANY of the functions within my class. I still would like advice on how to do so..

Barrette

Button Class Affect The Document Class
I want it so when you click the button, it can make the movie go to the next scene or change a variable in the document class. I can do it on the timeline but I want it as a class instead

And it would be cool if I could figure out how to make seperate packages just for functions and variables so I didn't have to write it all in one document, I just don't want to code in a big pile after I heard you can do this


Cheers

Button Class Calling Class Method
I have this class to add code to some buttons on the stage, and the class also contains the code for the button actions.

How can I get the button code to call the search() method when the button is pressed?


Code:
class startup.Shell
{

function Shell ()
{

init ();
}
private function init () : Void
{
//buttons
_root.btn_search.onPress = function ()
{
search ();
}
//
public function search () : Void
{
trace("loadsearch");
}
}

Class Path, Button Class ?
Hello,

If possible I would like to have all objects (buttons in this case) automatically format without scripting each button to get values from the classes.

Like if I place a button on the stage and export the movie, it references the button class.

Will this work if I change the class path, if so how might I go about this?

Tween Class & Button Class
Sorry I accidently made two threads.. can this be deleted please??

Button Class Not Creating A Button
Hi,

I have some AS3 code which I was hoping would create a re-usable button class but it does not. I just get a blank canvas. I am not getting any errors. Code is attached. Anyone see what is wrong?







Attach Code

package{
import flash.display.MovieClip
import flash.display.Shape
import flash.display.SimpleButton
import flash.events.MouseEvent
public class ButtonTute extends MovieClip{
public function ButtonTute() {
var button:SimpleButton = new SimpleButton();

var up:Shape = new Shape()
up.graphics.lineStyle(0, 0xFFFFFF, 1);
up.graphics.beginFill (0x000000);
up.graphics.drawRect (0, 0, 100, 50);
up.graphics.endFill();
button.upState = up;
button.x = 200
button.y = 200
addChild(button);

var over:Shape = new Shape()
over.graphics.lineStyle(0, 0xCCCCCC, 1);
over.graphics.beginFill (0x000000);
over.graphics.drawRect (0, 0, 120, 60);
over.graphics.endFill();
button.overState = over;
var down:Shape = new Shape()
down.graphics.lineStyle(0, 0xCCCCCC, 1);
down.graphics.beginFill (0x000000);
down.graphics.drawRect (0, 0, 80, 40);
down.graphics.endFill();
button.downState = down;
button.hitTestState = up;

button.doubleClickEnabled = true;
button.addEventListener(MouseEvent.CLICK, onClick)
button.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
button.addEventListener(MouseEvent.MOUSE_UP, mouseUp);
button.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);
}
private function onClick (event:MouseEvent):void{
trace ("Click");
}
private function mouseDown(event:MouseEvent):void{
trace ("mouse down");
}
private function mouseUp (event:MouseEvent):void{
trace ("Mouse up");
}
private function onDoubleClick (event:MouseEvent):void{
trace ("Double clicked");
}


}
}

Button Class
Hi everyone,

I have a Button class I made, which is Buttons.as and I link that to each movie clip in my menu.fla file. It works how it is setup right now, but I need to make it so when I click one of the buttons it stays selected (downState) and then when I click another button it will stay selected and the other will reset to the normalState. I bet this is probably fairly simple with using an 'if' statement, I'm just not sure how to go about doing it.

Here's my script:

Code:
class Buttons extends MovieClip {
// connects handlers with the functions
function Buttons() {
onRollOver = overState;
onRollOut = normalState;
onPress = downState;
onRelease = releaseState;
onDragOut = dOutState;
onDragOver = dOverState;
}
// function for normalState
function normalState() {
// normal state (frame 1 of mc)
gotoAndStop(1);
}
// function for overState
function overState() {
// over state (frame 2 of mc)
gotoAndStop(2);
}
// function for downState
function downState() {
// over state (frame 3 of mc)
gotoAndStop(3);
}
// function for onRelease
function releaseState() {
// mouse up (frame 2 of mc)
gotoAndStop(2);
}
// function for Draging off the mc
function dOutState() {
// drag out of mc (frame 1 of mc)
gotoAndStop(1);
}
// function for Dragging over the mc
function dOverState() {
// drag over of mc (frame 2 of mc)
gotoAndStop(2);
}
}
I am greatful for any help.

Thank you,
PrimalSniper

New Button Class
I need some help in defining a new button class.
I have made a new button that I want to place into a movie clip with action script.
I have tried using
createClassObject(MyButton, buttonname, depth, {_x:a, _y:b});
But obviously I need to make the button intoa class of it's own.

Can someone give a hand at explaining the class procedure or give another sollution to the problem, thankyou.

Help With Button Class
Hi,

I hope someone can help me. I'm trying to create a button which is similar to the flash buttons seen on News Today (http://newstoday.com). eg. News Broadcast (NTB). I was wondering if there is a tutorial out there where I can learn how to create a similar effect.

Using Button In Class
Hi !


I get a !%"/%$!"/? error everytime I publish my application that saying:

1120: Access of undefined property btnLoad.
1120: Access of undefined property loadVideo.

The btnLoad is name on my stage and the option "Automatically declare stage instances" is check too. So what the problem and what I'm doing wrong ?



ActionScript Code:
package{
   
    import flash.display.*;
    import flash.events.*;
    import flash.media.Video;
    import flash.text.*;
   
   
    public class videoPlayer extends MovieClip{
       
        private var videoPath:String;
        private var click_handler:MouseEvent;
       
        btnLoad.addEventListener(MouseEvent.CLICK,loadVideo);
       
        public function loadVideo(e:MouseEvent):void
        {
            videoPath = videoPathBox.text;
            player.source = videoPath;
            trace(videoPath);
        }
       
       
    }
   
}

Button Class?
so I am making a menu and I stumble across the notion of making a class to define these buttons instead of the following:


Code:
b1.onRollOver = over;
b1.onRollOut = out;
b1.b1_button_text.b1_text.text = "HOME";

b2.onRollOver = over;
b2.onRollOut = out;
b2.b1_button_text.b1_text.text = "PORTFOLIO";

b3.onRollOver = over;
b3.onRollOut = out;
b3.b1_button_text.b1_text.text = "RESUME";

b4.onRollOver = over;
b4.onRollOut = out;
b4.b1_button_text.b1_text.text = "CONTACT";

function over() {
this.gotoAndPlay('b1_rollover');
}

function out() {
this.gotoAndPlay('b1_rollout');
}
any idea how I do that?

Button Class
i'm trying to make a button class. i have on the stage a movie clip with two frames, for the up and down states, with an instance name of button.
in my class, i have the code
Code:

private function mouseDown(e:MouseEvent):void
      {
         if (isOn == false)
         {
            isOn = true;
            button.gotoAndStop(2);
         }
         else
         {
            isOn = false;
            button.gotoAndStop(1);
         }
      }

but when i run it, i get the error
1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:Sprite.

Button Class
Hi im trying to make a button class - so that it has a eollover/out mouse up/down effects - the problem is that when you click the same effect happens to all the buttons not just the one you click - the rollover and out both work as they should - anyone got any ideas

thanks


Code:

class ButtonClass extends MovieClip {
public function ButtonClass () {
this.onRollOver = this.over;
this.onRollOut = this.out;
this.onMouseDown = this.down;
this.onMouseUp = this.up;
}
private function over() {
this.gotoAndPlay(2);
}
private function out() {
this.gotoAndPlay(12);
}
private function down() {
this.gotoAndPlay(11);
}
private function up() {
this.gotoAndPlay(12);
}
}

Modify Button Class
Does anyone know how to remove the background of the butto component?

I have changed these styles

_global.styles.Button.setStyle("backgroundColor", 0xffffff);
_global.styles.Button.setStyle("themeColor", 0xffffff);

and still get a light grey background.

Button In Extended Mc Class
Hi ya all

I have made an custom class that extents a custom mc in my lib. I have added an text field, empty clip (for loading external images) and a invisible button to the mc.

I have put 4 instances of the mc on the main timeline, then I read in some xml and populate the 4 mc instances with some variables. A picture is loaded and some text above it. When I click on the mc it hase to invoke a function in the root. Now I have put 4 lines off code on the root to define the onRelease for the 4 instances. BUT, I want to define the button function within the class. This is where things get difficult (for me at least ;-)

First I tried to do something like this: (invi is the invisible button)

this.invi.onRelease = function(){}

"This statement is not permitted in a class definition" hmmz okee

Then I tried this....

var btn:Button;
function Click(btn:MovieClip){
btn.onRelease = ChangMovie;
}

But the 4 inctances are not created dynamicly and therfor I think I can't assign it to a clip - I'm not sure about this, just started learning classes

Anybody an idea how to create the button in de class? Thanx in advance...

Button Class And Properties
Hi,

I recently run into a short FLash 8 professional tutorial where a Button was instantiated on the stage with say a name "btn1" and then in an Action layer , a script set a "value" property of this button "btn1" as follows:

btn1.value = "00";

I am new, and I have been tryin to find out what the "value" property means for a button. But I haven't found this property defined in the Button class description.

Can someone explain what this may mean?

thanks

-Malena

Button EventListener In A Class
So my problem is pretty simple, I've got two buttons on a stage. With the code in an external actionscript class. The "count" button which calls the "Go" buttons function.

My problem is, when I click the "count" button, the trace works fine but the function call never happens. Any ideas?




Code:
public var countBtnLstnr:Object;
public var goBtnLstnr:Object;

public function UserInterface( target:MovieClip )
{
goBtnLstnr = new Object();
_root.btn_GO.addEventListener( "click" , goBtnLstnr);
countBtnLstnr = new Object();
_root.btn_Count.addEventListener( "click" , countBtnLstnr);

Init("count");
}

public function Init ( initState:String ):Void
{
switch ( initState )
{
case "count":
countButtonHandler();
break;
case "go":
goButtonHandler();
break;
}
}


public function countButtonHandler ():Void
{
countBtnLstnr = countBtnLstnr.click = function()
{
trace("Geting into click handler");
Init("go");
}

}


public function goButtonHandler ():Void
{
trace("Am I getting into this function?");
}

Text Button Class
i have a class which is basically text button which is clickable, similar to a hyperlink and i want to be able pass each create object a different function to run when clicked. Ideally i need the class to be reusable so it can do different things when clicked, so i figured the best way was to pass it a function to call. Just not sure how to implement it.


ActionScript Code:
package {
    import flash.events.*;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.text.TextField;
    import flash.display.Sprite;
   
    public class linkLabel extends textLabel {
       
        private var overformat:TextFormat;
        private var downformat:TextFormat;
        private var myAction:String;
       
        public function linkLabel(myText, myFont, mySize, myColor, myJust, myOverColor, myDownColor) {
        super(myText, myFont, mySize, myColor, myJust);
       
        this.buttonMode = true;
        this.useHandCursor = true;
           
        overformat = new TextFormat();
        overformat.font = myFont;
        overformat.color = myOverColor;
        overformat.size = mySize;
        overformat.underline = true;
       
        downformat = new TextFormat();
        downformat.font = myFont;
        downformat.color = myDownColor;
        downformat.size = mySize;
        downformat.underline = true;
           
        this.addEventListener(MouseEvent.MOUSE_OVER, rollover);
        this.addEventListener(MouseEvent.MOUSE_OUT, rollout);
        this.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
        this.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);
        }// end constructor
       
        private function rollover(e:MouseEvent):void {
            super.myLabel.setTextFormat(overformat);
        }// end rollover
       
        private function rollout(e:MouseEvent):void {
            super.myLabel.setTextFormat(super.format);
        }// end rollout
       
        private function mousePress(e:MouseEvent):void {
            super.myLabel.setTextFormat(downformat);
        }// end mousePress
       
        private function mouseRelease(e:MouseEvent):void {
            super.myLabel.setTextFormat(overformat);
        }// end mouseRelease
       
       
    }// end class
}// end package

Custom Button Class
I am trying to define my own button class but I am having some trouble using it. Could someone take a look and tell me what I am missing or why it is not working.

Custom Button Class

ActionScript Code:
package
{
    import flash.display.MovieClip;

    public class BTButton extends MovieClip
    {
        public var _state:String;
        public var _mc:MovieClip;
       
        private var _x:Number;
        private var _y:Number;
        private var _width:Number;
        private var _height:Number;
        private var _color:uint;
        private var _alpha:int;
        private var _eclipseWidth:Number;
        private var _eclipseHeight:Number;

        public function BTButton(x:Number, y:Number, width:Number, height:Number, color:uint, alpha:int, eclipseWidth:Number = undefined, eclipseHeight:Number = undefined ):void
        {   
            _x = x;
            _y = y;
            _width = width;
            _height = height;
            _color = color;
            _alpha = alpha;
            _eclipseWidth = eclipseWidth;
            _eclipseHeight = eclipseHeight;
           
            _mc = new MovieClip();
            _mc.graphics.beginFill(_color, 1);
           
            if (_eclipseWidth == undefined){
                _mc.graphics.drawRect(_x, _y, _width, _height);
      } else {
       if (_eclipseHeight == undefined){
        _mc.graphics.drawRoundRect(_x, _y, _width, _height, _eclipseWidth );
       } else {
        _mc.graphics.drawRoundRect(_x, _y, _width, _height, _eclipseWidth, _eclipseHeight);
       }
      }
      
            _mc.graphics.endFill();
            addChild(_mc);

            super();
        }
       
        /**
        * Returns the state of the button instance
        */
        private function get state():String
        {
            return _state
        }
       
        /**
        * @private
        */
        private function set state(value:String):void
        {
            _state = value;
           
            switch (_state) {
                case "up":
                    trace("up");
                    break;
                case "selected":
                    trace("selected");
                    break;
                case "down":
                    trace("down");
                    break;
                case "over":
                    trace("over");
                    break;
                default:
                    trace ("defsult");
                    break;
            }
        }
    }
}

Usage

ActionScript Code:
package {
    import flash.display.Sprite;
    import BTButton;

    public class DummyProject extends Sprite
    {
        private var bt_btn:BTButton;
        public function DummyProject()
        {
            bt_btn = new BTButton(0, 0, 100, 100, 0xff0000, 1);
            addChild(bt_btn)
        }
    }
}

How Do I Add A Button Press To My Class?
Hey guys i just want to modify a ButtonClass to work with a banner clickTag.

here is my ButtonClass.as file that i want to change into a ClickTag.as file.


ActionScript Code:
class com.mysitename.ButtonClass extends MovieClip {
   
    public function ButtonClass () {
        this.onRollOver = this.over;
        this.onRollOut = this.out;
    }
   
    private function over() {
        this.gotoAndPlay("over");
    }
   
    private function out() {
        this.gotoAndPlay("out");
    }
}


i'm trying to add the following button press code:


ActionScript Code:
on (release) {
    getURL(clickTag, "_blank");
}


Thanks =)

Custom Button Class
Hello,

I am creating a button class, but the problem is that when I add a
TextField, the hand cursor doesn't show, I've tried with MouseChildren
with no results.

I also want to know if this is the best way to create a custom button, I
only need three states and a label on the button, here's the code:

package {
//import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.display.SimpleButton;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;

import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;

public class Boton extends Sprite {
private var _boton:SimpleButton;
private var _etiqueta:Sprite;
private var Home:Object;
private var formato:TextFormat;
private var texto:TextField;
private var mensaje:String;
private var alineacion:String;
private var textoCreado:Boolean = false;
private var ancho:Number;
private var alto:Number;

public function Boton(Level:Object, txt:String) {
Home = Level;
mensaje = txt;
_etiqueta = new Sprite();
_etiqueta.buttonMode = false;
_etiqueta.mouseChildren = false;

_boton = new SimpleButton();
_boton.upState = cargarImagen('boton_normal.png');
_boton.overState = cargarImagen('boton_over.png');
_boton.downState = cargarImagen('boton_down.png');
_boton.hitTestState = _boton.upState;

addChild(_boton);
}

protected function cargarImagen(img:String):Sprite {
var picLoader:Loader = new Loader();
var imagen:String = img;
var request:URLRequest = new URLRequest(imagen);
picLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
imagenCargada);
picLoader.load(request);
var carg:Sprite = new Sprite();
carg.addChild(picLoader);
return carg;
}

private function imagenCargada (ev:Event) {
if (!textoCreado) {
textoCreado = true;
ancho = _boton.width;
alto = _boton.height;
crearEtiqueta();
}
}
public function crearEtiqueta(posX:int = 0, posY:int = 0) {
formato= Home.formato_boton;
texto= new TextField();
texto.autoSize= TextFieldAutoSize.CENTER;
texto.selectable= false;
texto.embedFonts= true;
texto.antiAliasType = "advanced";
texto.defaultTextFormat= formato;
texto.x= posX;
texto.y= posY;
texto.width= 100;
texto.text= mensaje;
texto.selectable = false;
texto.x = (ancho - texto.width) / 2;
texto.y = (alto -texto.height) / 2;
_etiqueta.addChild(texto);
addChild(_etiqueta);
}
}
}


Best regards!
Hugo.

Custom Button Class
I'm experimenting with creating a simple custom button class. I will have a movieclip in the library set to export as an instance of this class. The class will handle the onRollOver, onRollOut, etc. Of course I will want to have some code in my FLA that will do specific things onPress/onRelease and so on.

I've got it up and working fairly well. In my class I'm using the EventDispatcher to dispatch the various events. And this is the part where it becomes much more cumbersome than the traditional button. To catch the events dispatch I have to addEventListener for each button and for each event I want to listen to. Is that correct. So for example, if I have a cancel button and a submit button I will have to do this:

var listener:Object = new Object();
listener.submit=function(event){ // some submit code here};
listener.cancel=function(event){ // some cancel here};

submitButton.addEventListener("release",listener.submit);
cancelButton.addEventListener("release",listener.cancel);

hmmmm, looking at it and it doesn't seem too bad. but of course if I wanted to do other things for the other events it would start getting a bit much. So I guess I'm asking if this is a route others have gone down and found the trade off worth it? Or is there a better way?

Custom Button Class
Hello,

I am creating a button class, but the problem is that when I add a
TextField, the hand cursor doesn't show, I've tried with MouseChildren
with no results.

I also want to know if this is the best way to create a custom button, I
only need three states and a label on the button, here's the code:

package {
//import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.display.SimpleButton;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;

import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;

public class Boton extends Sprite {
private var _boton:SimpleButton;
private var _etiqueta:Sprite;
private var Home:Object;
private var formato:TextFormat;
private var texto:TextField;
private var mensaje:String;
private var alineacion:String;
private var textoCreado:Boolean = false;
private var ancho:Number;
private var alto:Number;

public function Boton(Level:Object, txt:String) {
Home = Level;
mensaje = txt;
_etiqueta = new Sprite();
_etiqueta.buttonMode = false;
_etiqueta.mouseChildren = false;

_boton = new SimpleButton();
_boton.upState = cargarImagen('boton_normal.png');
_boton.overState = cargarImagen('boton_over.png');
_boton.downState = cargarImagen('boton_down.png');
_boton.hitTestState = _boton.upState;

addChild(_boton);
}

protected function cargarImagen(img:String):Sprite {
var picLoader:Loader = new Loader();
var imagen:String = img;
var request:URLRequest = new URLRequest(imagen);

picLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imagenCargada);
picLoader.load(request);
var carg:Sprite = new Sprite();
carg.addChild(picLoader);
return carg;
}

private function imagenCargada (ev:Event) {
if (!textoCreado) {
textoCreado = true;
ancho = _boton.width;
alto = _boton.height;
crearEtiqueta();
}
}
public function crearEtiqueta(posX:int = 0, posY:int = 0) {
formato = Home.formato_boton;
texto = new TextField();
texto.autoSize = TextFieldAutoSize.CENTER;
texto.selectable = false;
texto.embedFonts = true;
texto.antiAliasType = "advanced";
texto.defaultTextFormat = formato;
texto.x = posX;
texto.y = posY;
texto.width = 100;
texto.text = mensaje;
texto.selectable = false;
texto.x = (ancho - texto.width) / 2;
texto.y = (alto -texto.height) / 2;
_etiqueta.addChild(texto);
addChild(_etiqueta);
}
}
}


Best regards!
Hugo.

Problem With My Button Class
I'm sure someone can spot this straight away. I'm still fairly new but I'm slaving away at this...

Why will this not work? It keeps returning 1120: Access of undefined property currentFrame...and...1180: Call to a possibly undefined method gotoAndStop. And I have no idea why. I thought gotoAndStop was part of the MovieClip class.

package
{
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.display.MovieClip;

public class NextPage extends SimpleButton
{
public function NextPage(event:MouseEvent):void
{
this.addEventListener(MouseEvent.CLICK, GoToNext);
}

private function GoToNext(event:MouseEvent):void
{
gotoAndStop(currentFrame + 5);
}
}
}

Writing A Button Class
I'm sure this is real easy but I'm a bit of a newbie so I'm still working out my MovieClip methods from my Stage methods.

Basically, I need to write code for a button class I call NextButton.as which on a Mouseclick will move the stage along by 5 frames to the next page in my presentation. I've tried to do this by writing things like this in my onClick method:

gotoAndStop(stage.currentFrame + 5);

But it doesn't like that at all because gotoAndStop is a method of the MovieClip class but not the Stage class.
So I need to get a MovieClip to move the STAGE along 5 frames to the next page in my presentation.

My only other option is to forget the button class altogether and write code in every 5 pages of my frame, giving each "NextPage" function a different name like NextPage1, NextPage2, NextPage3. I'm sure there's a more intelligent way to do this! I'm too stubborn to give in!!

Many thanks,
Marc

Extending Button Class?
Hi all, sorry if this has been answered somewhere else (I searched) or if the answer is super easy (It's possible I'm just retarded).

I am working on an interface that will have literally hundreds of buttons, navigating back/forth/in-between dozens of sections and subsections. I love the ease of skinning/labeling the built-in button component, but my fingers are rebelling at the thought of typing(or at least copy/pasting) "on(release)/gotoandplay/lastSection=/etc".

So, I figured since I was already planning on having extensive frame labeling, I would just make the instance name of the button the same as the frame label where I wanted it to go. Then just have "gotoAndPlay(this._name)" on each Button.

My question then is thus: How do i make the following a part of the button component (or a different version of it, so I still use the default component for the couple of buttons I don't want to do this), everytime I drag one onto the stage?


Code:
on (click) {
nextSection = this._name;
lastSection = _root._currentframe;
gotoAndPlay(nextSection);
}
Thanks so much to anyone who can help me out! And if there is a super easy way of doing this, please smack me, then let me know what it is

Extending The Button Class
I have an AS file named MovieClipTLnd which I created to add a property to the MovieClip class, plus a function to trace the current value of the property I added.
I works out just fine.
But when I do the same trying to extend the Button Class, it won't work.

check the last lines of this LiveDoc, a few days ago someone posted a comment regarding this problem

http://livedocs.macromedia.com/flash/mx2004/main_7_2/00001211.html#4716791

I know there are some workarounds for this problem... like embedding the button into movieclips and assigning properties as objects, but I need to know if it's possible to Extend the Built-in Button class itself just like it can be done with the MovieClip Class.

A Separate Class For Every Button?
Do I need to create a separate class for every button that I make? I am trying to use OOP correctly. So I might end up with 20 different .as files that correspond to my 20 different buttons that get used at various points in my game? Files like "quitButton.as, quitButtonConfirm.as, quiButtonDeny.as, newGameButton.as, newGameButtonConfirm.as,..." etc. Is there a better way to do this? Am I making myself clear? Thanks for any help.

Using Tween Class With A Button?
Hello, I'm trying to move a movieclip from off stage into a position on stage using the tween and easing classes. I have the code written out on an actions layer, not on the button and for some reason it's not working. I'm not getting any errors either. The codes pasted below. Thanks!!

import mx.transitions.Tween;
import mx.transitions.easing.*;

//Button
_root.products_mc.onEnterFrame = function() {
if (mouse_over_products_mc) {
_root.products_mc.nextFrame();
}
else {
_root.products_mc.prevFrame();
}
};

//action when clicked
prod_btn.onRelease = function() {
new Tween(prod_content_mc, "x", Elastic.easeOut, 962, 341, 3, true);
}

Extending Button Class?
Hi all, sorry if this has been answered somewhere else (I searched) or if the answer is super easy (It's possible I'm just retarded).

I am working on an interface that will have literally hundreds of buttons, navigating back/forth/in-between dozens of sections and subsections. I love the ease of skinning/labeling the built-in button component, but my fingers are rebelling at the thought of typing(or at least copy/pasting) "on(release)/gotoandplay/lastSection=/etc".

So, I figured since I was already planning on having extensive frame labeling, I would just make the instance name of the button the same as the frame label where I wanted it to go. Then just have "gotoAndPlay(this._name)" on each Button.

My question then is thus: How do i make the following a part of the button component (or a different version of it, so I still use the default component for the couple of buttons I don't want to do this), everytime I drag one onto the stage?


Code:
on (click) {
nextSection = this._name;
lastSection = _root._currentframe;
gotoAndPlay(nextSection);
}
Thanks so much to anyone who can help me out! And if there is a super easy way of doing this, please smack me, then let me know what it is

Extending The Button Class
I have an AS file named MovieClipTLnd which I created to add a property to the MovieClip class, plus a function to trace the current value of the property I added.
I works out just fine.
But when I do the same trying to extend the Button Class, it won't work.

check the last lines of this LiveDoc, a few days ago someone posted a comment regarding this problem

http://livedocs.macromedia.com/flash/mx2004/main_7_2/00001211.html#4716791

I know there are some workarounds for this problem... like embedding the button into movieclips and assigning properties as objects, but I need to know if it's possible to Extend the Built-in Button class itself just like it can be done with the MovieClip Class.

Help Creating A Button Class
This is my first try at creating a class. It's still unfinished and I could use some hints and advice for debugging. I'm not really sure if I even have everything set up

By the way - Thank you Rob for such a wonderful book...


Code:
#include "shape_drawing_basic.as"
//MakeButon Class
/* PARAMETERS
butPosX =X button position
butPosY= Y button position
butFont= font used for the buton text
butPoints=size of the font
butText=text for the button
butTextColor=text color
*/
/* DEPENDENCIES
drawRectRel - R. Penner
*/

_global.MakeButon=function (butPosX,butPosY,butFont,butPoints,butText,butTextColor){
//properties
this.butPosX=butPosX;
this.butPosY=butPosY;
this.butFont=butFont;
this.butPoints=butPoints;
this.butText=butText;
this.butTextColor=butTextColor;


//initialize
this.MakeButonHolder();
this.MakeHitarea();

}
//buton holder method
MakeButon.prototype.MakeButonHolder=function(){
this.depthCounter=0;
// this.butDepth.push=i;

this.createEmptyMovieClip("BH"+depthCounter,this.depthCounter);
x=BH._x=butPosX; //posicion x
y=BH._y=butPosY;//posicion y
this.depthCounter++;
};

//buton text method
MakeButon.prototype.MakeButonText=function(){
this.createTextField("text"+depthCounter,this.depthCounter,0,0,0,0);
//PROPERTIES
dc=depthCounter;
text[dc].selectable=false;
text[dc].embedFonts=true;
text[dc].autoSize=true;
text[dc].background=0xFF0000;
//METHODS
formatoBoton=new TextFormat(butFont,butPoints,butTextColor,true,null,null,null,null,null,null,null,null,null);
text[dc].setNewTextFormat(formatoBoton);
};
//Hitarea method button will have same size as text(autosize)
MakeButon.prototype.MakeHitarea=function(){
this.createEmptyMovieClip("hitarea",this.depthCounter++);
this.hitarea.beginFill(0,0);
this.hitarea.drawRectRel(x,y,dentrode._width,dentrode._height);
this.hitarea.endFill();

this._listners= new Array(); //to substitue the one created by Asbroadcaster.initialize()
//not sure of how to make the button work...
this.hitarea.onRelease=function(){
trace("onrelease");
};
this.hitarea.onRollOver=function(){
trace("onrollover");
};
};

Asbroadcaster.initialize (MakeButon.prototype);

...

AS2 - Basic Button Class
Hi,

If i have a movieclip with a button_1 on the first frame and a button_2 on the second frame, why doesn't the following class which is called in the first frame apply the action to the second frame?


Code:
class button{
public function button() {
_root.button_1.onPress = function() {
_root.gotoAndStop(2);
};
//
_root.button_2.onPress = function() {
trace(this);
};
}
}
Thanks!

Extending Button Class
Hi im trying to extend the button class from lees tut - so that it has a mouse up/down effect aswell - the problem is that when you click the same effect happens to all the buttons not just the one you click - anyone got any ideas

thanks



Code:

class ButtonClass extends MovieClip {
   public function ButtonClass () {
      this.onRollOver = this.over;
      this.onRollOut = this.out;
      this.onMouseDown = this.down;
      this.onMouseUp = this.up;
}
private function over() {
   this.gotoAndPlay(2);
}
private function out() {
   this.gotoAndPlay(12);
}
private function down() {
   this.gotoAndPlay(11);
}
private function up() {
   this.gotoAndPlay(12);
}
}[/code]

AS3 Button / MC / Tween Class
Hello,
I have been 'using' Flash on & off for a year or more but still consider myself very much a newbie.

My Question:
What is the best way to create a Movie Clip that animates when you rollover it?

Please take a look at what I'm attempting to build here:
http://www.matthewellis.co.uk/tvcmheader/tcv_header.html

I basically have a hit area: hifiHit_mc (currently 10% alpha, just for reference)
The hifi: hifi_mc
And then 4 speech bubble mc's that move when you roll over the hifiHit_mc... and the hifiHit_mc is disabled while the animation resets itself.

It kind of works how I'd like it to, BUT just seems a bit glitchy.
EG, sometimes it will freeze half way through the animation, or the speech bubbles wont return to the correct place, or it'll just suddenly jump from one state to another.

Below is my AS3 code. Is this a good method of achieving what I'm trying to do? Is there a Flash standard method of coding this?
Any help / advice / tutorials would be greatly appreciated! I just dont know if I'm doing this a stupid way!!?


Code:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.MouseEvent;

this.chargers_mc.enabled = false;
this.toLaunch_mc.enabled = false;

// HI FI + 'Click On This' Bubble move
var myTween1:Tween = new Tween(this.hifi_mc, "y", Elastic.easeOut, 320, 281, 2, true);
var myTween2:Tween = new Tween(this.clickThis_mc, "y", Elastic.easeOut, 171, 181, 2, true);
// Other text on left
var myTween3:Tween = new Tween(this.weNeed_mc, "alpha", Strong.easeOut, 0, 1, 1, true);
var myTween4:Tween = new Tween(this.helpText_mc, "alpha", Strong.easeOut, 0, 1, 1, true);
var myTween5:Tween = new Tween(this.readMore_mc, "alpha", Strong.easeOut, 0, 1, 2, true);

// On Rollover
hifiHit_mc.buttonMode = true; // show hand icon when mouse is over the movie clip
hifiHit_mc.addEventListener (MouseEvent.MOUSE_OVER, hifiGrow);

function hifiGrow ($event:MouseEvent) {
   var myTween1:Tween = new Tween(this.hifi_mc, "scaleY", Elastic.easeOut, 1, 1.1, 1.5, true);
   var myTween2:Tween = new Tween(this.hifi_mc, "scaleX", Elastic.easeOut, 1, 1.1, 1.5, true);
   var myTween3:Tween = new Tween(this.clickThis_mc, "scaleY", Elastic.easeOut, 1, 1.2, 1.5, true);
   var myTween4:Tween = new Tween(this.clickThis_mc, "scaleX", Elastic.easeOut, 1, 1.2, 1.5, true);
   var myTween5:Tween = new Tween(this.clickThis_mc, "x", Elastic.easeOut, clickThis_mc.x, clickThis_mc.x-40, 1.5, true);
   var myTween6:Tween = new Tween(this.clickThis_mc, "y", Elastic.easeOut, clickThis_mc.y, clickThis_mc.y-3, 1.5, true);
   var myTween7:Tween = new Tween(this.toLaunch_mc, "scaleY", Elastic.easeOut, 1, 1.2, 1.5, true);
   var myTween8:Tween = new Tween(this.toLaunch_mc, "scaleX", Elastic.easeOut, 1, 1.2, 1.5, true);
   var myTween8b:Tween = new Tween(this.toLaunch_mc, "x", Elastic.easeOut, toLaunch_mc.x, toLaunch_mc.x-45, 1.5, true);
   var myTween9:Tween = new Tween(this.theAudioPlayer_mc, "scaleY", Elastic.easeOut, 1, 1.5, 1.7, true);
   var myTween10:Tween = new Tween(this.theAudioPlayer_mc, "scaleX", Elastic.easeOut, 1, 1.5, 1.7, true);
   var myTween11:Tween = new Tween(this.toLaunch_mc, "alpha", Strong.easeOut, 0, 1, 1, true);
   var myTween12:Tween = new Tween(this.theAudioPlayer_mc, "alpha", Strong.easeOut, 0, 1, 1, true);
}

// Rollout
hifiHit_mc.buttonMode = true; // show hand icon when mouse is over the movie clip
hifiHit_mc.addEventListener (MouseEvent.MOUSE_OUT, hifiShrink);

function hifiShrink ($event:MouseEvent) {
   var myTween1:Tween = new Tween(this.hifi_mc, "scaleY", Elastic.easeOut, 1.1, 1, 1, true);
   var myTween2:Tween = new Tween(this.hifi_mc, "scaleX", Elastic.easeOut, 1.1, 1, 1, true);
   var myTween3:Tween = new Tween(this.clickThis_mc, "scaleY", Elastic.easeOut, 1.2, 1, 1, true);
   var myTween4:Tween = new Tween(this.clickThis_mc, "scaleX", Elastic.easeOut, 1.2, 1, 1, true);
   var myTween5:Tween = new Tween(this.clickThis_mc, "x", Elastic.easeOut, clickThis_mc.x, clickThis_mc.x+40, 1.5, true);
   var myTween6:Tween = new Tween(this.clickThis_mc, "y", Elastic.easeOut, clickThis_mc.y, clickThis_mc.y+3, 1.5, true);
   var myTween7:Tween = new Tween(this.toLaunch_mc, "scaleY", Elastic.easeOut, 1.2, 1, 1.5, true);
   var myTween8:Tween = new Tween(this.toLaunch_mc, "scaleX", Elastic.easeOut, 1.2, 1, 1.5, true);
   var myTween8b:Tween = new Tween(this.toLaunch_mc, "x", Elastic.easeOut, toLaunch_mc.x, toLaunch_mc.x+45, 1.5, true);
   var myTween9:Tween = new Tween(this.theAudioPlayer_mc, "scaleY", Elastic.easeOut, 1.5, 1, 1.5, true);
   var myTween10:Tween = new Tween(this.theAudioPlayer_mc, "scaleX", Elastic.easeOut, 1.5, 1, 1.5, true);
   var myTween11:Tween = new Tween(this.toLaunch_mc, "alpha", Strong.easeOut, 1, 0, .3, true);
   var myTween12:Tween = new Tween(this.theAudioPlayer_mc, "alpha", Strong.easeOut, 1, 0, .3, true);
   hifiHit_mc.enabled=false;

var myTimer:Timer = new Timer(1500);
myTimer.addEventListener("timer", timedFunction);
myTimer.start();   
}

function timedFunction(eventArgs:TimerEvent) {
hifiHit_mc.enabled=true;
}

// Pop up
hifiHit_mc.buttonMode = true; // show hand icon when mouse is over the movie clip
hifiHit_mc.addEventListener (MouseEvent.MOUSE_DOWN, hifiPop);

function hifiPop ($event:MouseEvent) {
   var jscommand:String = "window.open('http://www.mysite.com','win','height=200,width=300,toolbar=no,scrollbars=yes');"; var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);"); navigateToURL(url, "_self");
}


Thanks guys!

Listening To A Button In MX 2004 Class
Hi

I'm making a ui in MX 2004. I want to have several buttons within movie clips. I extend the movie clips with .as classes. What code can I use within the class to listen for when the button is pressed and trigger a function. Is this possible?

Thanks

Custom Class To Extend Button ?
Can this be done? I got my custom class to extend an MovieClip no problem. Can't seem to get it to work when I try applying it to a Button. I've found no examples of this. Just curious as to if this is even an option.

[f8] Dynamic Button Function Within A Class
ello


I've a little problem with AS2... namely I need to attach buttons and dynamically assign to them a function within the class. Something like this:


PHP Code:



class meh {

      public function meh(target: MovieClip) {

            addAButton(target, "traceParam", "hello!");
      }

      private function addAButton(target: MovieClip, btnfn: String, btnparam: Object): Void {
            
            var mc: MovieClip = target.attachMovie("btn", "b", 1);
            mc.onRelease = this[btnfn];
            mc.btnparam = btnparam;
      }

      private function traceParam(): Void {

            trace(this.btnparam);
      }
}




so 'this' within the traceParam function references the button instance when called by the button, however, the compiler of course doesn't recognise this fact and assumes that 'this' refrerences the class instance, meaning it detects that btnparam isn't a declared variable and throws a compile error.... even though its valid code!!

Don't know if theres a better way to do what I'm trying to achieve here, i'm open to all suggestions!


cheers

Button Effects - Write A Class Or Not?
Hi all,

in building a prototype, I took the easy path for animating a button and simply attached movie clips to the up/over/down/hit states (no chuckles from the peanut gallery). I decided I to go ahead with the style, but don't want to leave clips on the hit states for various reasons. In general, I use movie clips instead of buttons.

Now that I'm going to convert to movie clips for production, I wonder if it might be better to create a custom class to handle some complicated actions, e.g., things that would take multiple functions if scripted in the FLA itself. For example, I'd like the button to have an animation that fades out on rollout, and picks up where it left off if rolled over before the fade completes. This can't be done with typical button states (the clip disappears as expected).

I imagine the class would allow me to react to mouse events on the button, as well as choose a particular animation/effect from my library, and have some kind of persistence for the down state.

Any thoughts on approaching this? I am starting to work on this as a set of functions, but have not had any experience actually writing classes.

Button Class - Reposition Buttons
Hey, having some troubles wrapping my head around how to do this. basically i use my button class to create some links, and what I want to accomplish is when you click a button, it swaps places with the currently selected button (which is always in the same place). I create a new class for each button:


Code:
var yPos:Number = 20;
var lineHeight:Number = 20;

var photos:ButtonMC = new ButtonMC(yPos+=lineHeight);
photos.buttonText.text = "PHOTOS";
addChild(photos);

var store:ButtonMC = new ButtonMC(yPos+=lineHeight);
store.buttonText.text = "STORE";
addChild(store);

var resources:ButtonMC = new ButtonMC(yPos+=lineHeight);
resources.buttonText.text = "RESOURCES";
addChild(resources);

var home:ButtonMC = new ButtonMC(yPos+=lineHeight);
home.buttonText.text = "HOME";
home.buttonText.textColor = 0xFF0000;
addChild(home);
As you can see the home button is red (for selected), so if you were to click on resources, resources would go in the home button position and become red, while home would go in the resources position. I can figure this out if it was not using a class, but I have no clue how to do it as is. Thanks for the help!

Button Event Within My Document Class
Hi. I have the following code:

proceedBut.addEventListener(MouseEvent.CLICK, myLink);
function myLink(event: MouseEvent) {
var linkMain:URLRequest = new URLRequest("http://www.myURL/home.html");
navigateToURL(linkMain,"_self");
}

If I place a Movie Clip on my stage, give it the instance name "proceedBut" and place the above code on the same frame of my timeline, it works perfectly.

If I am using the document class 'Main.as', where does this code appear in the package?

When I do this:

package {
import flash.display.Sprite;
import flash.net.navigateToURL;
import flash.net.URLRequest;
public class Main extends Sprite {
public function Main() {
proceedBut.addEventListener(MouseEvent.CLICK, myLink);
function myLink(event: MouseEvent) {
var linkMain:URLRequest = new URLRequest("http://www.myURL/home.html");
navigateToURL(linkMain,"_self");
}
}
}
}

I get the error:
1046: Type was not found or was not a compile-time constant: MouseEvent.

Please help

Custom Button And Library Class
Hello,

I am trying to use a custom button, so far it works if I put it at the default position and all.
The problem is, I need to move this button, with
myButton.move() and stuff like that, since I'll be adding several buttons of the same "library class" at the same time.
However, when I look at the Base Class in the library properties, it tells me its "flash.display.SimpleButton", which sucks to say the least, since SimpleButton has nothing, it doesn't implement move(), setStyle (which I'm using to pass parameters in a weird way since making custom event handlers just gave me headaches for 2 days) etc.

Now, I need the base class to be "fl.controls.Button", since that's the one I can move() and stuff.
But I cannot do it, the compiler reports


Code:
5000: The class 'fl.controls.Button' must subclass 'flash.display.SimpleButton' since it is linked to a library symbol of that type.
So basically, there is no way to have a library symbol that extends (or whatever) the fl.controls.Button class? I can't even dynamically move a custom button in runtime?

Thanks a lot for your time!!

Can't Animate Background Of Button Class
I've made a class that creates a simple button with a label and background. When I rollover the button the background should tween to a color and that's where it's going wrong. It's probably something simple I'm missing but I can't find it.
The text label does tween correctly, but the background doesn't do anything. It also doesn't give any errors when I test it.

ActionScript Code:
package classes
{
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
   
    import gs.TweenFilterLite;
    import gs.easing.Circ;

    public class NavButton extends Sprite
    {
        private var _text:String;
        private var _background:Sprite;
        private var _label:Sprite;
       
        public function NavButton(textLabel:String)
        {
            _text = textLabel;
            addEventListener(Event.ADDED_TO_STAGE, init);
        }
        private function init(e:Event):void
        {
            buttonMode = true;
            mouseChildren = false;
            addLabel();
            drawBackground();
            addEventListener(MouseEvent.ROLL_OVER, onOver);
            addEventListener(MouseEvent.ROLL_OUT, onOut);
        }
        private function onOver(e:MouseEvent):void
        {
            TweenFilterLite.to(_background, 0.2, {tint: 0xfff59b, ease: Circ.easeOut});
            TweenFilterLite.to(_label, 0.2, {tint: 0x333333, ease: Circ.easeOut});
        }
        private function onOut(e:MouseEvent):void
        {
            TweenFilterLite.to(_background, 0.3, {tint: null, ease: Circ.easeOut});
            TweenFilterLite.to(_label, 0.3, {tint: null, ease: Circ.easeOut});
        }
        private function addLabel():void
        {
            _label = new Sprite();
            var tf:TextField = new TextField();
            tf.autoSize = TextFieldAutoSize.LEFT;
            tf.selectable = false;
            tf.x = 5;
            tf.y = 2;
           
            var format:TextFormat = new TextFormat("Arial", 16, 0xffffff, true);
            tf.defaultTextFormat = format;
            tf.text = _text;
           
            _label.addChild(tf);
            addChild(_label);
        }
        private function drawBackground():void
        {
            _background = new Sprite();
            var w:Number = _label.width + 10;
            var h:Number = 24;
            _background.graphics.beginFill(0x333333);
            _background.graphics.drawRect(0, 0, w, h);
            _background.graphics.endFill();
            addChildAt(_background, 0);
        }
    }
}

Creating A Simple Button Class
I'm trying to create a class for a simple button that can reference objects on the stage. How do reference the stage from inside a class definition?

Creating Custom Button Class In AS3.
Hi Guys,

I'm having a problem with creating some custom buttons and wondered if anyone would be able to help?

Basically I am trying to create some buttons that look like hyperlinks, so white background with coloured writting, and on mouseover, click etc. I would like the text to change transparency and so have created functions to do this (see below). HOWEVER, it doesn't appear to be working....there are no compiling errors but the button isnt appearing on the stage at runtime. I am trying to make the custom functions generic as I am going to have to create 4 buttons. Can anyone point me in the right direction?

Thanks


Code:
var homeBtnText:String = "Home";

var btnHome:SimpleButton = createBtn(homeBtnText);
btnHome.x = 500;
btnHome.y = 500;
addChild(btnHome);

function createBtn(btnText:String):SimpleButton
{
var ovCol:uint = Color.interpolateColor(thirdColour,0xFFFFFF,0.3);
var dnCol:uint = Color.interpolateColor(thirdColour,0x000000,0.3);
var btn:SimpleButton = new SimpleButton();
btn.upState = createLabel(thirdColour,btnText);
btn.overState = createLabel(ovCol,btnText);
btn.downState = createLabel(dnCol,btnText);
btn.hitTestState = btn.upState;
return btn;
}

function createLabel(colour:uint, btnText:String):TextField
{
var txt:TextField = new TextField();
txt.width = 20;
txt.height = 5;

var navButton:TextFormat = new TextFormat();
navButton.font = "Arial";
navButton.color = colour;
navButton.size = 14;
navButton.align = TextFormatAlign.CENTER;

txt.defaultTextFormat = navButton;
txt.text = btnText;
txt.selectable = false;

return txt;
}

Scaling A Button Using The Tween Class In AS3
Ok.. this should be simple. Trying to grow/shrink a simple button. I have it in AS2 but trying to redo it in AS3.

This is my AS2 code.. which is great:

import mx.transitions.Tween;
import mx.transitions.easing.*;

box.onRelease = function() {
if(box._xscale < 200) {
grow(box);
}
else {
shrink(box);
}
}

function grow(box) {
var tw:Tween = new Tween(box,"_xscale",Strong.easeOut,100,400,1,true) ;
var tw2:Tween = new Tween(box,"_yscale",Strong.easeOut,100,400,1,true) ;
}

function shrink(box) {
var tw:Tween = new Tween(box,"_xscale",Strong.easeOut,400,100,1,true) ;
var tw2:Tween = new Tween(box,"_yscale",Strong.easeOut,400,100,1,true) ;
}


Now this is my AS3 version. What am I missing? I'm not that experienced with AS3. The box just moves locations instead of expanding:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.events.MouseEvent;

box.x = 100;
box.y = 100;

box.buttonMode = true;
box.addEventListener (MouseEvent.CLICK, reloadListener);

function reloadListener($event:MouseEvent) {
if(box.scaleX < 200) {
grow(box);
}
else {
shrink(box);
}

function grow(box) {
var tw:Tween = new Tween(box,"scaleX",Regular.easeOut,100,200,1,true) ;
var tw2:Tween = new Tween(box,"scaleY",Regular.easeOut,100,200,1,true) ;
}

function shrink(box) {
var tw:Tween = new Tween(box,"scaleX",Regular.easeOut,200,100,1,true) ;
var tw2:Tween = new Tween(box,"scaleY",Regular.easeOut,200,100,1,true) ;
}

}

Button Class Active Listener
Hi All
I have a cutom button class. it has a rollover , rollout and active states. I have 5 instances of this button in a container called container. What I want is when one puttone is in the in the active satate and another button is pressed it puts the first button in its default state, removes its active state. I used to do this in as2 by just looping through all buttons and returning them to default state onpress and onrelease I would set the new button to active. Not quite working in as3 also hoping there is a better way with a listener or something. read something about using prototype for this but cant find anything concrete. any help would be greate

Help Me Create A Button Manager Class
I am trying to create a create a class that stores an array of movie clips. I want the class to register itself to receive onRelease events from each button in the array. I have been trying to us AsBroadcaster but I suspect I'm not understanding it to I'm not implementing it correctly.

Here's what I have so far:








Attach Code

class ButtonGroup {
private var groups_array:Array = new Array();

public function ButtonGroup() {

}

public function new_group( button_array:Array, id:String ):Void {
groups_array[ id ] = new Array();
groups_array[ id ].push( button_array );
for ( var p in groups_array[ id ] ) {
AsBroadcaster.initialize( groups_array[ id ][p] );
groups_array[ id ][p].addListener( this );
groups_array[ id ][p].broadcastMessage( "onRelease" );
}
}

public function onRelease() {
trace( "test" );
}
}

























Edited: 04/28/2007 at 02:00:09 PM by nudnic

How Do I Add A Tween Class On Button Rollover?
Basically, I want to have one tween class effect running on my button by default. The button's scale will be "pulsating" in and out.

Then, when you mouse over the button, it tweens up to 120%, until you roll off, then it goes back to "pulsating"....

I can get it to "pulsate," but I can't figure out how to get that effect to stop, and apply a different tween to scale it up on rollover...

Make sense?

Here is the code for the first part,,,

(on rollover, I send it to a frame that applies the rollover tween effect, however, the initial tween keeps playing)....is there a way to do this in one frame? (and get it to work)

Any help much appreciated!

Thanks!
Elliott







Attach Code

var scaleUp:Number = 115;
var buttonXscale:Number = audioButton._xscale;
var buttonYscale:Number = audioButton._yscale;

import mx.transitions.Tween;
import mx.transitions.easing.*;

//tween the button
var button_scaleX:Tween = new Tween(audioButton, "_xscale", Regular.easeOut, buttonXscale, scaleUp, 1, true);
button_scaleX.onMotionFinished = function (){ this.yoyo(); }

var button_scaleY:Tween = new Tween(audioButton, "_yscale", Regular.easeOut, buttonYscale, scaleUp, 1, true);
button_scaleY.onMotionFinished = function (){ this.yoyo(); }

audioButton.onRollOver = function():Void{

gotoAndPlay("button_on");

}

Copyright © 2005-08 www.BigResource.com, All rights reserved