TwelvestoneFlash

Flash Classes organization


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
Storm
 
2010-06-02

Part of my frustration with where Flash has gone is that I really fail to see where using classes REALLY saves time and effort on code changes.....I've never had any problem changing code in any type of FLA file created by any different type of designer or developer on any project. Now I have to make sure files weren't changed if I recompile if something new comes in, etc etc.

What the hell do you guys do to stay sane???!!!

ok, I understand most agencies have specific ways and methods and they don't deviate from them but since I have to work across Flash, Flex, and FlashDevelop I'm at a loss and any advice you have to give would be great.

It's like I have to have 3 different sets of classes now.

With FlashDevelop its' best to make the classes extend the MC in an SWC. But if I try to use the same class of code with an MC in Flash, I can't have it extend another MC that doesn't exists so I have to write another class or completely reverse the best method in FD.

Example, I created a really really easy GradientRectangle class. Pass it w,h and 2 colours. But the class declares the variables and Flash chokes because it conflicts with the namespaces of the variables in the timeline. So, then you're either going to the preferences to uncheck the automatically declare setting and have to set it back when you just want to make a quick banner because it chokes if you don't explicitly declare the variables in that file! ARGH.

So, now I have to make classes for FD and classes for Flash because shit doesn't compile. I don't even want to get into Flex because I'm sure the way my XP is installed by the IT department fucks that up on its own. Nothing compiles there. Even if I write the code in Flex it dies.

So, how do you guys deal with multiple methods of developing with the Flash Platform?

In learning about 'proper' OOP, you have completely independant Objects (hence the name) and you pass it only the info it needs. new Class(param1, param2).

But if you make an MC in Flash on the stage it can't 'pass' params so you have to take out the params when you use that class or add it in code and not put the Object on the timeline. Being a hybrid designer in Flash now really really sucks ass.

JLM
 
2010-06-03

Storm

for my views I go with composites and signals it allows me the option to switch projects to other platforms with less work as it does not rely on EventDispatcher inheritance chains that are flash specific, and allows total seperation of code and graphics movies.

A haXe example class ( replace HSL with Signals if your using as3 )

package zpartan.generic.views;

import flash.geom.Rectangle; import flash.events.MouseEvent; import flash.display.MovieClip; import flash.events.Event; import flash.display.Stage;

// hsl signal classes import hsl.avm2.translating.AVM2Signaler; import hsl.haxe.Signaler; import hsl.haxe.null.NullSignaler; import hsl.haxe.direct.DirectSignaler;

class SliderBar { private var _scope: MovieClip; private var _slidee: MovieClip; private var _sliderBar: MovieClip; private var _min: Float; private var _max: Float; private var _range: Float; private var _y: Float; private var _x: Float; private var _width: Float; public static inline var DX: Float = 15; private var _ratio: Float; private var _val: Float; private var _dragging: Bool;

public var changeSignaler(          default, null):     Signaler<Void>;
public var changeFinishSignaler(    default, null):     Signaler<Void>;
public var moveSignaler(            default, null):     Signaler<Void>;
public var downSignaler(            default, null):     Signaler<Void>;
public var upSignaler(              default, null):     Signaler<Void>;

public var value( _get_value, _set_value ):Float;

private function _get_value():Float{ return _val; }
private function _set_value( val_: Float ):Float
{ 

    _val            = val_;
    _slidee.x       = _x + _val/_ratio - _min/_ratio + _slidee.width/2;
    return val_; 

}


public function new(    
                        scope_:         MovieClip,
                        slidee_:        MovieClip,
                        sliderBar_:     MovieClip, 
                        min_:           Float,
                        max_:           Float,
                        val_:           Float
                    )
{

    _scope          = scope_;
    _slidee         = slidee_;
    _sliderBar      = sliderBar_;
    _min            = min_;
    _max            = max_;
    var moviesExist: Bool = true;
    if( _slidee == null )
    {
        trace( '_slidee not found' );
        moviesExist = false;
    }
    if( _sliderBar == null )
    {
        trace( '_sliderBar not found' );
        moviesExist = false;
    }

    if( moviesExist == true )
    {

        _y              = _slidee.y;
        _x              = _sliderBar.x + DX;
        _width          = _sliderBar.width - 2*DX - _slidee.width/2;
        _range          = _max - _min;
        _ratio          = _range/_width;

        value           = val_;
        _dragging       = false;

        init();
    }


}


private function init():Void
{

    changeSignaler          = new DirectSignaler( this, false );
    changeFinishSignaler    = new DirectSignaler( this, false );

    downSignaler = new AVM2Signaler( this, _slidee, MouseEvent.MOUSE_DOWN );
    downSignaler.bindVoid( dragMe );
    upSignaler = new AVM2Signaler( this, _scope, MouseEvent.MOUSE_UP );

}


private function update():Void
{

    _val = ( _slidee.x - _x )*_ratio + _min;

    changeSignaler.dispatch();
    //trace(changeSignaler.hasSlots());
    trace('update');

}


private function dragMe():Void
{
    _dragging = true;
    _slidee.startDrag( false, new Rectangle( _x, _y, _width, 0 ) );
    moveSignaler = new AVM2Signaler( this, _scope, MouseEvent.MOUSE_MOVE);
    moveSignaler.bindVoid( update );
    upSignaler.bindVoid( dragEnd );

}


private function dragEnd():Void
{
    if( _dragging == true )
    {

        _slidee.stopDrag();
        moveSignaler.unbindVoid(     update );
        upSignaler.unbindVoid(      dragEnd );

        changeFinishSignaler.dispatch();
        _dragging = false;

    }
}

}

I have not experimented much with other targets, but created this tutorial based on some code of Hugh's;http://haxe.org/doc/start/cpp Maybe I will try compiling the above as C++ sometime, and with some modifications would like to get it working in javascript.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

Flash Classes organization