A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: [Note] mtasc, v2 components and Delegate

  1. #1
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926

    [Note] mtasc, v2 components and Delegate

    Not sure how many of you will use a combination of mtasc, v2 components and the Delegate class, but just in case you do this may stop you wasting 2 hours like I just have.

    When using v2 components in mtasc you have to use the -mx flag, but as I've found out ( After 2 hours, did I mention that ? ) the -mx flag basically stops mtasc compiling any classes in the mx package ( Would have been good to have actually found that out on the mtasc site itself ), including mx.utils.Delegate.

    There's a solution here: http://osflash.org/mx_v2_components_patch but that seems like a ton of work, and if like me, you're only ever going to use components once every blue moon ( This is my first time with v2 ones ), it's not worth the effort.
    So a quick and dirty fix is to just duplicate the Delegate class and put it in a different package, and then import it from there.

    And that's that

    Squize.

  2. #2
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    thanks for the heads up. Why is a person like yourself using silly components anyways?
    lather yourself up with soap - soap arcade

  3. #3
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Got it in my head that writing a profiler would be a good idea, so I'm doing it as an external swf and spitting the data over using a localConnection, and I'm just adding a trace function to it now ( Basically Alcon mixed in with a profiler )

    Not a big fan of trying to be a proper programmer, not sure why it's a million times easier to write a scroller than getting a component to work, but I guess I have to try sometimes.

    Squize.

  4. #4
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    nice to hear you´re working on the profiler blue,i wondered what kept you up so long =)
    And yup,thanks for the heads up,think this could come in handy for people working with components,too.
    But regarding what you said: I think its easier to write scroller for you than to work with components cause the v2 components suck
    I don´t use that word often but yeah,i worked on apps a lot at the office and its crazy how much work goes into using the components because they aren´t intuitive to use in so many areas and many of em also have heavy bugs.
    I hope all that gets way better with the v3 components of flash9 since people like grant skinner are working on em.

  5. #5
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    oh yeah,maybe you wanna check out http://www.as2lib.org/ ,too,i remember they had a good profiler,maybe gives some inspiration

  6. #6
    hmm Pugger's Avatar
    Join Date
    Sep 2003
    Location
    Perth, Australia
    Posts
    616
    Quote Originally Posted by tomsamson
    I hope all that gets way better with the v3 components of flash9 since people like grant skinner are working on em.
    I hope so too! I have had too many late nights at the office due to those damn components. I only just recently managed to skin the combo box. wooo

    Anyway, sorry to maybe be a little off topic but I was wondering what is a profiler?

  7. #7
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Yeah normally I'd rather wake up next to my mum than use a component, but as ever I need a really quick turnaround ( Blue, you know what it's like with projects lined up I can't afford to spend too much time on a personal project these days ).
    It's only textArea anyway, radio buttons etc. I'm coding myself.

    Thanks for the link, I've been looking at stuff like this:
    http://eclipsecolorer.sourceforge.ne..._profiler.html
    http://www.intel.com/cd/software/pro...une/219898.htm

    So as well as the time it takes for a method to run, I'm planning on recording metrics data too.
    Hopefully all this effort will get my code running a bit quicker

    Oops, Pugger just caught your post before replying. A profiler is just a way of recording how long a function takes, so in theory this bad boy will record the number of ms functions take to run, with a view to speeding them up.

    Squize.

  8. #8
    hmm Pugger's Avatar
    Join Date
    Sep 2003
    Location
    Perth, Australia
    Posts
    616
    Hmm, thanks mate. Sounds very useful, but too hard to create for me . Good luck.

  9. #9
    Senior Member UnknownGuy's Avatar
    Join Date
    Jul 2003
    Location
    Canada
    Posts
    1,361
    Can someone explain to me what the delegate class does?

    I've heard it mentioned quite a few times, and don't quite understand.

    Thanks (Didn't think it was worth it to start a new thread)

    And yes, components are PURE evil. Those and embedded fonts. :P

    Hope your profiler works out!

  10. #10
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    The Delegate class is something that came with the 7.2 update.

    Basically it allows you to set the scope on a function a million times easier, for example, doing it without delegate;

    someButton.onPress=buttonPressedFunc;

    function buttonPressedFunc(){
    trace(this);
    //This will output the button, not the class this code is in. Bit of a pain
    }

    Whereas with Delegate...

    someButton.onPress=Delegate.create(this,buttonPres sedFunc);

    function buttonPressedFunc(){
    trace(this);
    //This outputs the class ( ie, "this" ), it's the first parameter in the create method, that's what sets the scope.
    }

    I believe it's been made obsolete with AS3, but in the mean time, it's a cheeky little winner.

    Squize.

  11. #11
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Oops forgot to mention when it comes in really handy, when you're using things like the loadVars class, and you have all the eventListeners in there, you never know what the hell the scope is inside those, so it sorts out that problem really easily.

    Squize.

  12. #12
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    That profile thing sounds cool, have to look into it.

    Ya, components suck bad when coding for them. At work we deal with a good many of them. And I think one or two were easy too use. The reset you could basically write a book on how to use them.

  13. #13
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Yeah had a quick play trying to just alter the font in the textArea component but it just wasn't having it, and I didn't want to get too bogged down with it as it's more than likely only going to be an internal app anyway.

    Squize.

  14. #14
    Senior Member UnknownGuy's Avatar
    Join Date
    Jul 2003
    Location
    Canada
    Posts
    1,361
    Thanks for the info Squize.

    This is easier than passing this as a parameter for a function call. Done that a few times.

  15. #15
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Mate, I'm so dirty with my as1 that I've used this a lot

    function whatever(arg){
    this=arg;
    }

    Where arg is the calling "this".

    Shock to the system moving over to as2, all my lazy cheaty ways came back to haunt me.

    Squize.

  16. #16
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    for those that don't know, check out your mx classes, there's some useful utils in there. I've used the ClassFinder one many times
    lather yourself up with soap - soap arcade

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center