Thank you John, the Delegate has been just what
I needed - I've just replaced the 2 lines and it works:
listener.onLoadProgress =
Delegate.create(this, display_progress);
listener.onLoadInit =
Delegate.create(this, resize_clip);
Proxy looks nice too, but the license is unclear?
Regards
Alex
On 9/12/06, John Axel Eriksson <[EMAIL PROTECTED]> wrote:
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;
};
}
--
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