Yeah, exactly. You can use it for anything. You should also check this out:
http://www.person13.com/articles/proxy/Proxy.htm

A "nicer" version of Delegate.

What a Delegate/Proxy does is to execute a callback in another scope. So instead you could do it like this(I'm using Proxy, but you can use Delegate almost the same way):



class User extends MovieClip {
        private var loaded_txt:TextField;
        private var box_width:Number;
        private var box_height:Number;
        private var box_ratio:Number;
        //-------
        private var avatar_mc:MovieClip;
        private var loader_mcl:MovieClipLoader;
        
        public function User() {
                loaded_txt.text = '0%';

                var listener:Object = new Object();

                box_width = avatar_mc._width;
                box_height = avatar_mc._height;
                box_ratio = avatar_mc._width / avatar_mc._height;
                loaded_txt = loaded_txt;

                listener.onLoadProgress = Proxy.create(this, display_progress);
                listener.onLoadInit = Proxy.create(this, resize_clip);
                
                loader_mcl = new MovieClipLoader();
                loader_mcl.addListener(listener);
                loader_mcl.loadClip(image, avatar_mc);
        }

        private function resize_clip(target_mc:MovieClip):Void {
                loaded_txt.text = '';

                var clip_ratio:Number = avatar_mc._width / avatar_mc._height;

                if (clip_ratio > box_ratio)
                        avatar_mc._xscale = avatar_mc._yscale =
                           100 * box_width / avatar_mc._width;
                else
                        avatar_mc._xscale = avatar_mc._yscale =
                           100 * box_height / avatar_mc._height;
        };
}


/John

12 sep 2006 kl. 09.57 skrev Hans Wichman:

Hi,
Delegate is not only for components, it works for anycase where you wish to
run functions in another scope.
greetz
JC


On 9/12/06, Alexander Farber <[EMAIL PROTECTED]> wrote:

Hello John,

On 9/12/06, John Axel Eriksson <[EMAIL PROTECTED]> wrote:
> You could look into Delegate or Proxy... makes these

I've looked up the Delegate and it is for Components
and I don't use them. And the "Proxy" is a bad keyword
for searching - could you please give me an URL?

I have put my full source code User.as + User.fla here:
http://preferans.de/user/ - just in case someone has any
other suggestions. Thank you

Regards
Alex

--
http://preferans.de
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to