class IMG_Loader_Stretch extends mx.core.UIComponent { var parent_mc, _x, _y, auto_load, image_str, image_width, image_height, easing_type, easing_speed, stretch_amount, invalidate, __get____width, __get____height, __get__autoLoad, __get__contentPath, scale_content, __get__scaleContent, __get__easingType, __get__easingSpeed, __get__stretchAmount, loader_visible, __get__preloader, loader_color, __get__preloaderColor, transition_bool, __get__transition, dispatchEvent, loader_mc, bytesLoaded, bytesTotal, percentLoaded, loader_brd, onEnterFrame, image_msk, stretch_mc, __set____height, __set____width, __set__autoLoad, __set__contentPath, __set__easingSpeed, __set__easingType, __set__preloader, __set__preloaderColor, __set__scaleContent, __set__stretchAmount, __set__transition; function IMG_Loader_Stretch() { super(); parent_mc = this; parent_mc._x = Math.ceil(_x); parent_mc._y = Math.ceil(_y); mx.events.EventDispatcher.initialize(this); if (auto_load) { this.load(image_str); } // end if } // End of the function function get_parent_mc() { return (parent_mc); } // End of the function function get_image_str() { return (image_str); } // End of the function function get_image_width() { return (image_width); } // End of the function function get_image_height() { return (image_height); } // End of the function function get_easing_type() { if (easing_type == "none") { return (IMG_Loader_Stretch.easeNone); } else if (easing_type == "in") { return (IMG_Loader_Stretch.easeIn); } else if (easing_type == "out") { return (IMG_Loader_Stretch.easeOut); } // end else if } // End of the function function get_easing_speed() { switch (easing_speed) { case 1: { return (3000); break; } case 2: { return (2000); break; } case 3: { return (1000); break; } case 4: { return (400); break; } case 5: { return (350); break; } case 6: { return (250); break; } case 7: { return (200); break; } case 8: { return (150); break; } case 9: { return (50); break; } case 10: { return (10); break; } } // End of switch } // End of the function function get_stretch_amount() { switch (stretch_amount) { case 1: { return (100); break; } case 2: { return (500); break; } case 3: { return (1000); break; } case 4: { return (3000); break; } case 5: { return (4000); break; } case 6: { return (5000); break; } case 7: { return (6000); break; } case 8: { return (7000); break; } case 9: { return (8000); break; } } // End of switch } // End of the function function set __width(w) { image_width = Math.ceil(w); this.invalidate(); //return (this.__width()); null; } // End of the function function get __width() { return (image_width); } // End of the function function set __height(h) { image_height = Math.ceil(h); this.invalidate(); //return (this.__height()); null; } // End of the function function get __height() { return (image_height); } // End of the function function set autoLoad(bool) { auto_load = bool; this.invalidate(); //return (this.autoLoad()); null; } // End of the function function get autoLoad() { return (auto_load); } // End of the function function set contentPath(str) { image_str = str; this.invalidate(); //return (this.contentPath()); null; } // End of the function function get contentPath() { return (image_str); } // End of the function function set scaleContent(bool) { scale_content = bool; this.invalidate(); //return (this.scaleContent()); null; } // End of the function function get scaleContent() { return (scale_content); } // End of the function function set easingType(str) { easing_type = str; this.invalidate(); //return (this.easingType()); null; } // End of the function function get easingType() { return (easing_type); } // End of the function function set easingSpeed(num) { easing_speed = num; this.invalidate(); //return (this.easingSpeed()); null; } // End of the function function get easingSpeed() { return (easing_speed); } // End of the function function set stretchAmount(num) { stretch_amount = num; this.invalidate(); //return (this.stretchAmount()); null; } // End of the function function get stretchAmount() { return (stretch_amount); } // End of the function function set preloader(str) { loader_visible = str; this.invalidate(); //return (this.preloader()); null; } // End of the function function get preloader() { return (loader_visible); } // End of the function function set preloaderColor(num) { loader_color = num; this.invalidate(); //return (this.preloaderColor()); null; } // End of the function function get preloaderColor() { return (loader_color); } // End of the function function set transition(str) { transition_bool = str; this.invalidate(); //return (this.transition()); null; } // End of the function function get transition() { return (transition_bool); } // End of the function function draw() { } // End of the function function dsp_img() { this.get_parent_mc().createEmptyMovieClip("stretch_mc", 1); this.get_parent_mc().createEmptyMovieClip("stretch_msk", 2); with (this.get_parent_mc().stretch_msk) { beginFill(0, 0); moveTo(0, 0); lineTo(10, 0); lineTo(10, 10); lineTo(0, 10); lineTo(0, 0); endFill(); } // End of with this.get_parent_mc().createEmptyMovieClip("image_mc", 3); this.get_parent_mc().createEmptyMovieClip("image_msk", 4); with (this.get_parent_mc().image_msk) { beginFill(0, 0); moveTo(0, 0); lineTo(10, 0); lineTo(10, 10); lineTo(0, 10); lineTo(0, 0); } // End of with } // End of the function function dsp_preloader() { this.get_parent_mc().createEmptyMovieClip("loader_brd", 5); this.get_parent_mc().loader_brd._x = this.image_width / 2 - 40; this.get_parent_mc().loader_brd._y = this.image_height / 2 - 5; with (this.get_parent_mc().loader_brd) { lineStyle(0, 0, 100); moveTo(0, 0); lineTo(80, 0); lineTo(80, 9.500000E+000); lineTo(0, 9.500000E+000); lineTo(0, 0); } // End of with var color = new Color(this.get_parent_mc().loader_brd); color.setRGB(this.loader_color); this.get_parent_mc().createEmptyMovieClip("loader_mc", 6); this.get_parent_mc().loader_mc._x = this.image_width / 2 - 38; this.get_parent_mc().loader_mc._y = this.image_height / 2 - 3; with (this.get_parent_mc().loader_mc) { beginFill(0, 100); moveTo(0, 0); lineTo(1, 0); lineTo(1, 6); lineTo(0, 6); lineTo(0, 0); endFill(); } // End of with var color = new Color(this.get_parent_mc().loader_mc); color.setRGB(this.loader_color); } // End of the function function load() { this.dsp_img(); var obj = new Object(); obj.path = this.get_parent_mc().image_mc; if (loader_visible == "on") { this.dsp_preloader(); } // end if this.get_parent_mc().onEnterFrame = function () { this.dispatchEvent({type: "progress", target: this}); if (obj.path.getBytesLoaded() > 10) { var _loc2 = obj.path.getBytesLoaded() / obj.path.getBytesTotal() * 77; loader_mc._width = _loc2; bytesLoaded = obj.path.getBytesLoaded(); bytesTotal = obj.path.getBytesTotal(); percentLoaded = Math.round(obj.path.getBytesLoaded() / obj.path.getBytesTotal() * 100); if (obj.path.getBytesLoaded() >= obj.path.getBytesTotal()) { loader_brd.removeMovieClip(); loader_mc.removeMovieClip(); delete this.onEnterFrame; if (transition_bool == "on") { obj.path._visible = false; this.load_msk(this.get_image_str()); } else if (scale_content) { obj.path._width = image_width; obj.path._height = image_height; } // end if } // end if } // end else if }; obj.path.loadMovie(this.get_image_str()); } // End of the function function load_msk(img) { var obj = new Object(); obj.path = this.get_parent_mc().stretch_mc; this.get_parent_mc().onEnterFrame = function () { if (obj.path.getBytesLoaded() > 10) { if (obj.path.getBytesLoaded() >= obj.path.getBytesTotal()) { delete this.onEnterFrame; obj.path._visible = false; if (scale_content) { this.prep_fx(image_width, image_height); } else { this.prep_fx(obj.path._width, obj.path._height); } // end if } // end if } // end else if }; obj.path.loadMovie(img); } // End of the function function prep_fx(w, h) { this.dispatchEvent({type: "complete", target: this}); var _loc2 = w + this.get_stretch_amount(); if (_loc2 > 9000) { _loc2 = 9000; } // end if this.get_parent_mc().stretch_msk._width = w; this.get_parent_mc().stretch_msk._height = h; this.get_parent_mc().stretch_mc._width = _loc2; this.get_parent_mc().stretch_mc._height = h; this.get_parent_mc().stretch_mc._visible = true; this.get_parent_mc().stretch_mc.setMask(this.get_parent_mc().stretch_msk); this.get_parent_mc().image_msk._width = 0; this.get_parent_mc().image_msk._height = h; this.get_parent_mc().image_mc._width = w; this.get_parent_mc().image_mc._height = h; this.get_parent_mc().image_mc._visible = true; this.get_parent_mc().image_mc.setMask(this.get_parent_mc().image_msk); this.dsp_fx(w, -(_loc2 - w)); } // End of the function function dsp_fx(w_num, x_num) { var current_num = 0; var timer = getTimer(); this.get_parent_mc().onEnterFrame = function () { var _loc3 = w_num - image_msk._width; var _loc2 = x_num - stretch_mc._x; stretch_mc._x = this.get_easing_type()(current_num, stretch_mc._x, _loc2, this.get_easing_speed(), 1); image_msk._width = this.get_easing_type()(current_num, image_msk._width, _loc3, this.get_easing_speed(), 1); if (Math.round(image_msk._width) >= w_num) { delete this.onEnterFrame; stretch_mc._x = x_num; image_msk._width = w_num; } // end if if (getTimer() - timer > 60000) { delete this.onEnterFrame; stretch_mc._x = x_num; image_msk._width = w_num; } // end if ++current_num; }; } // End of the function static function easeIn(t, b, c, d) { t = t / d; return (-c * (Math.sqrt(1 - t / d * t) - 1) + b); } // End of the function static function easeOut(t, b, c, d) { t = t / d - 1; return (c * ((t / d - 1) * t * t + 1) + b); } // End of the function static function easeNone(t, b, c, d) { return (c * t / d + b); } // End of the function var className = "IMG_Loader_Stretch"; static var symbolOwner = IMG_Loader_Stretch; static var symbolName = "IMG_Loader_Stretch"; } // End of Class