Very simple. You have defined the method resize_clip in the User
class which
does have a loaded_txt var but doesn't have the box_width and
box_height etc vars.
The fact that you use that function in another context doesn't matter
to the compiler.
That's why you get those errors. You could look into Delegate or
Proxy... makes these
things much nicer and tidier.
/J
11 sep 2006 kl. 23.53 skrev Alexander Farber:
Hello,
I have an mc which loads an external image file (a user avatar)
using MovieClipLoader.loadClip and while doing so displays
percentage of currently loaded bytes in a TextField loaded_txt:
class User extends MovieClip {
private var loaded_txt:TextField;
private var avatar_mc:MovieClip;
private var loader_mcl:MovieClipLoader;
public function User() {
loaded_txt.text = '0%';
var listener:Object = new Object();
// pass container dimensions and
// the TextField reference to the callbacks:
listener.box_width = avatar_mc._width;
listener.box_height = avatar_mc._height;
listener.box_ratio = avatar_mc._width / avatar_mc._height;
listener.loaded_txt = loaded_txt;
listener.onLoadProgress = display_progress;
listener.onLoadInit = resize_clip;
loader_mcl = new MovieClipLoader();
loader_mcl.addListener(listener);
loader_mcl.loadClip(image, avatar_mc);
}
I'm trying to pass 4 variables as members to the onLoadInit
callback, so that I can delete the percentage text in loaded_txt
and also resize the loaded image to make it fit into the box:
private function resize_clip(target_mc:MovieClip):Void {
loaded_txt.text = '';
var clip_ratio:Number = target_mc._width / target_mc._height;
if (clip_ratio > this['box_ratio'])
target_mc._xscale = target_mc._yscale =
100 * this['box_width'] / target_mc._width;
else
target_mc._xscale = target_mc._yscale =
100 * this['box_height'] /
target_mc._height;
};
The code above with this['box_ratio'] works, but if I try
to refer to this.box_ratio or just box_ratio, I get the error
message (and same for box_width and box_height):
There is no property with the name 'box_ratio'.
Why is it so? And what irritates me even more, I'm able
to access loaded_txt.text from the callback just fine...
I've tried to print out properties of this in resize_clip(),
but haven't noticed there anything special:
--- this in resize_clip() ---
onLoadInit: [type Function]
onLoadProgress: [type Function]
loaded_txt: _level0.user_mc.loaded_txt
box_ratio: 1.32786885245902
box_height: 61
box_width: 81
Regards
Alex
--
http://preferans.de
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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