All pastes #622409 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-07-16 21:04 UTC
rendered paste body
#initclip 1
MovieClip.prototype.setTooltip = function (theText, timer, text_color, bg_color, border_color)
{
    if (timer == undefined)
    {
        timer = 500;
    } // end if
    var addMsg = function (theMsg, col, bg_color, border_color, level)
    {
        var x = _root._xmouse;
        var y = _root._ymouse;
        var f = new TextFormat();
        f.font = "Verdana";
        f.size = 11;
        f.color = col != undefined ? (col) : (0);
        level.createTextField("tooltip", 123456, x, y, 150, 20);
        with (level.tooltip)
        {
            setNewTextFormat(f);
            text = theMsg;
            selectable = false;
            autoSize = true;
            background = true;
            border = true;
            borderColor = border_color != undefined ? (border_color) : (0);
            backgroundColor = bg_color != undefined ? (bg_color) : (16777198);
            _y = _y - _height;
        } // End of with
        clearInterval(level.q_t);
    };
    this.q_t = setInterval(addMsg, timer, theText, text_color, bg_color, border_color, _root);
};
MovieClip.prototype.unsetTooltip = function ()
{
    _root.tooltip.removeTextField();
    clearInterval(this.q_t);
};
FPanoramic = function ()
{
    if (this.image != undefined && this.image != "")
    {
        this.loadImage("", this.scale_x, this.scale_y, this.autoSpin, this.image);
        this.setSpeed(this.speed || 10);
        this.setMaxZoom(this.maxZoom);
        this.setLoadedHandler(this.loadedHandler);
    } // end if
};
FPanoramic.changed = function (id, oldval, newval, userData)
{
    if (newval >= 4)
    {
        clearInterval(this.__q);
        this.constructor.activateImages(this);
        return;
    } // end if
    if (userData.type == "external")
    {
        this.constructor.loadInto(this.imageContainer["_cont" + newval].theImage, undefined, userData.path);
        this.__q = setInterval(this.constructor.preloader, 10, this, undefined, userData.path);
    }
    else
    {
        this.constructor.loadInto(this.imageContainer["_cont" + newval].theImage, userData.path, undefined);
        this.__q = setInterval(this.constructor.preloader, 10, this, userData.path, undefined);
    } // end else if
    return (newval);
};
FPanoramic.preloader = function (obj, img, external)
{
    if (external != undefined)
    {
        obj.imageContainer["_cont" + obj.clipLoaded].theImage._x = obj.imageContainer["_cont" + obj.clipLoaded].theImage._x - obj.imageContainer["_cont" + obj.clipLoaded].theImage._width / 2;
        obj.imageContainer["_cont" + obj.clipLoaded].theImage._y = obj.imageContainer["_cont" + obj.clipLoaded].theImage._y - obj.imageContainer["_cont" + obj.clipLoaded].theImage._height / 2;
        clearInterval(obj.__q);
        ++obj.clipLoaded;
        return;
    } // end if
    if (obj.imageContainer["_cont" + obj.clipLoaded].theImage._url != obj._url && obj.imageContainer["_cont" + obj.clipLoaded].theImage.getBytesLoaded() == obj.imageContainer["_cont" + obj.clipLoaded].theImage.getBytesTotal() && obj.imageContainer["_cont" + obj.clipLoaded].theImage._width != 0)
    {
        clearInterval(obj.__q);
        obj.imageContainer["_cont" + obj.clipLoaded].theImage._x = obj.imageContainer["_cont" + obj.clipLoaded].theImage._x - obj.imageContainer["_cont" + obj.clipLoaded].theImage._width / 2;
        obj.imageContainer["_cont" + obj.clipLoaded].theImage._y = obj.imageContainer["_cont" + obj.clipLoaded].theImage._y - obj.imageContainer["_cont" + obj.clipLoaded].theImage._height / 2;
        ++obj.clipLoaded;
    }
    else
    {
        return (false);
    } // end else if
};
FPanoramic.loadInto = function (obj, image, external)
{
    if (image != undefined)
    {
        obj.loadMovie(image);
    }
    else
    {
        obj.attachMovie(external, "external", 1);
    } // end else if
};
FPanoramic.activateImages = function (obj)
{
    var a = 0;
    while (a < 3)
    {
        obj.imageContainer["_cont" + a]._x = obj.imageContainer["_cont" + a]._width * (a - 1);
        ++a;
    } // end while
    if (obj.imageContainer._width * 3 < obj.theMask._width)
    {
        obj.imageContainer._width = obj.theMask._width * 3;
        obj.options.image_xscale = obj.imageContainer._xscale;
    } // end if
    if (obj.imageContainer._height < obj.theMask._height)
    {
        obj.imageContainer._height = obj.theMask._height;
        obj.options.image_yscale = obj.imageContainer._yscale;
    } // end if
    obj.imageContainer._visible = true;
    obj.imageContainer._xscale = obj.imageContainer._xscale / (obj._xscale / 100);
    obj.imageContainer._yscale = obj.imageContainer._yscale / (obj._yscale / 100);
    obj.refreshSpot();
    obj.imageContainer.setMask(obj.theMask);
    if (obj.options.autoSpin)
    {
        obj.attachMovie("FP_autoSpin", "FP_autoSpin", obj.theMask.getDepth() + 1);
        obj.Fp_autoSpin._width = 15 / (obj._xscale / 100);
        obj.Fp_autoSpin._height = 15 / (obj._yscale / 100);
        obj.Fp_autoSpin._x = obj.theMask._x + obj.Fp_autoSpin._width / 2 - obj.theMask._width / 2 + 1;
        obj.Fp_autospin._y = obj.theMask._y - obj.Fp_autoSpin._height / 2 + obj.theMask._height / 2 - 1;
    } // end if
    if (!isNaN(obj.options.max_zoom) && obj.options.max_zoom != undefined)
    {
        obj.attachMovie("FP_maxZoom", "FP_maxZoom", obj.theMask.getDepth() + 2);
        obj.FP_maxZoom._width = 15 / (obj._xscale / 100);
        obj.Fp_maxZoom._height = 15 / (obj._yscale / 100);
        obj.FP_maxZoom._x = obj.theMask._x + obj.FP_maxZoom._width / 2 - obj.theMask._width / 2 + obj.Fp_autoSpin._width + 2;
        obj.FP_maxZoom._y = obj.theMask._y - obj.FP_maxZoom._height / 2 + obj.theMask._height / 2 - 1;
        obj.attachMovie("FP_minZoom", "FP_minZoom", obj.theMask.getDepth() + 3);
        obj.FP_minZoom._width = 15 / (obj._xscale / 100);
        obj.FP_minZoom._height = obj.Fp_maxZoom._height;
        obj.FP_minZoom._x = obj.FP_maxZoom._x + obj.FP_maxZoom._width + 1;
        obj.FP_minZoom._y = obj.theMask._y - obj.FP_minZoom._height / 2 + obj.theMask._height / 2 - 1;
    } // end if
    if (obj.theMask.onPress != undefined)
    {
        obj.theMask.onPress = undefined;
    } // end if
    if (obj.theMask.onEnterFrame != undefined)
    {
        obj.theMask.onEnterFrame = undefined;
    } // end if
    if (obj.theMask.onRelease != undefined)
    {
        obj.theMask.onRelease = obj.theMask.onReleaseOutside = undefined;
    } // end if
    obj.theMask.onPress = function ()
    {
        obj.isMouseDown = true;
        obj.options.autospin = false;
        obj.x_origin = _root._xmouse;
        obj.y_origin = _root._ymouse;
    };
    obj.theMask.onEnterFrame = function ()
    {
        if (obj.isMouseDown)
        {
            var end_x = _root._xmouse;
            var end_y = _root._ymouse;
            obj.__x = (end_x - obj.x_origin) / obj.options.speed;
            obj.__y = (end_y - obj.y_origin) / obj.options.speed;
        }
        else
        {
            obj.__y = obj.__y * 7.000000E-001;
            obj.__x = obj.__x * 7.000000E-001;
        } // end else if
        if (obj.options.autoSpin)
        {
            obj.imageContainer._x = obj.imageContainer._x - 1;
        } // end if
        obj.imageContainer._y = obj.imageContainer._y - obj.__y;
        obj.imageContainer._x = obj.imageContainer._x - obj.__x;
        var imageBound = obj.imageContainer.getBounds(_root);
        var maskBound = obj.theMask.getBounds(_root);
        if (imageBound.yMax <= maskBound.yMax)
        {
            obj.imageContainer._y = -(obj.imageContainer._height - obj.theMask._height) / 2;
        } // end if
        if (imageBound.yMin >= maskBound.yMin)
        {
            obj.imageContainer._y = (obj.imageContainer._height - obj.theMask._height) / 2;
        } // end if
        if (imageBound.xMin + obj.imageContainer._width / 6 > maskBound.xMin)
        {
            obj.imageContainer._x = obj.imageContainer._x - obj.imageContainer._width / 3;
        } // end if
        if (imageBound.xMax - obj.imageContainer._width / 6 < maskBound.xMax)
        {
            obj.imageContainer._x = obj.imageContainer._x + obj.imageContainer._width / 3;
        } // end if
    };
    obj.theMask.onRelease = obj.theMask.onReleaseOutside = function ()
    {
        obj.isMouseDown = false;
    };
    _root[obj.options.loadedHandler]();
    obj.__loaded = true;
};
FPanoramic.prototype = new MovieClip();
FPanoramic.prototype.setSpeed = function (spe)
{
    if (isNaN(parseInt(spe, 10)))
    {
        return;
    } // end if
    this.options.speed = parseInt(spe, 10);
};
FPanoramic.prototype.getSpeed = function ()
{
    return (this.options.speed);
};
FPanoramic.prototype.setEnabled = function (bool)
{
    if (bool == undefined)
    {
        return;
    } // end if
    if (!bool)
    {
        this.createEmptyMovieClip("veil", this.options.depth * 100);
        this.veil._x = -this.theMask._width / 2;
        this.veil._y = -this.theMask._height / 2;
        with (this.veil)
        {
            beginFill(0, 50);
            moveTo(0, 0);
            lineTo(this.theMask._width, 0);
            lineTo(this.theMask._width, this.theMask._height);
            lineTo(0, this.theMask._height);
            lineTo(0, 0);
            endFill();
        } // End of with
        this.theMask.old_onEnterFrame = this.theMask.onEnterFrame;
        this.theMask.onEnterFrame = undefined;
        this.enable = false;
    }
    else
    {
        this.veil.removeMovieClip();
        this.theMask.onEnterFrame = this.theMask.old_onEnterFrame;
        this.enable = true;
    } // end else if
};
FPanoramic.prototype.getEnabled = function ()
{
    return (this.enable);
};
FPanoramic.prototype.getBytesTotal = function ()
{
    var value = this.imageContainer._cont0.theImage.getBytesTotal() * 3;
    return (value);
};
FPanoramic.prototype.getBytesLoaded = function ()
{
    var value = this.imageContainer._cont0.theImage.getBytesLoaded() + this.imageContainer._cont1.theImage.getBytesLoaded() + this.imageContainer._cont2.theImage.getBytesLoaded();
    return (value);
};
FPanoramic.prototype.init = function ()
{
    this.imageContainer.removeMovieClip();
    this.Fp_autoSpin.removeMovieClip();
    this.Fp_maxZoom.removeMovieClip();
    this.Fp_minZoom.removeMovieClip();
    this.theMask.removeMovieClip();
    this.spotContainer.removeMovieClip();
    this.veil.removeMovieClip();
    delete this.__loaded;
    delete this.options;
    delete this.__x;
    delete this.__y;
    delete this.__q;
    this.unwatch("clipLoaded");
    delete this.clipLoaded;
    delete this.y_origin;
    delete this.x_origin;
    delete this.isMouseDown;
    this.setEnabled(true);
    this.enable = true;
    this.options = {};
    this.options.depth = 2;
    this.options.speed = 15;
    this.createEmptyMovieClip("imageContainer", this.options.depth++);
    this.imageContainer._visible = 0;
    this.attachMovie("theMask", "theMask", 100);
    this.theMask.useHandCursor = false;
    this.options.hot_spot = {};
    this.createEmptyMovieClip("spotContainer", this.options.depth++);
    var a = 0;
    while (a < 3)
    {
        this.imageContainer.createEmptyMovieClip("_cont" + a, this.options.depth++);
        this.imageContainer["_cont" + a].createEmptyMovieClip("theImage", 2);
        ++a;
    } // end while
};
FPanoramic.prototype.loadImage = function (imagePath, scale_x, scale_y, autoSpin, static)
{
    this.init();
    this.options.imagePath = imagePath;
    this.options.objectName = static;
    this.options.autoSpin = autoSpin || false;
    this.options.image_xscale = scale_x || 100;
    this.options.image_yscale = scale_y || 100;
    this.imageContainer._xscale = this.options.image_xscale;
    this.imageContainer._yscale = this.options.image_yscale;
    this.clipLoaded = 0;
    if (this.options.objectName != undefined && this.options.objectName != "")
    {
        this.watch("clipLoaded", this.constructor.changed, {type: "external", path: this.options.objectName});
        this.__q = setInterval(this.constructor.preloader, 10, this, undefined, this.options.objectName);
        this.constructor.loadInto(this.imageContainer["_cont" + this.clipLoaded].theImage, undefined, this.options.objectName);
    }
    else
    {
        this.watch("clipLoaded", this.constructor.changed, {type: "img", path: imagePath});
        this.__q = setInterval(this.constructor.preloader, 10, this, imagePath, undefined);
        this.constructor.loadInto(this.imageContainer["_cont" + this.clipLoaded].theImage, imagePath, undefined);
    } // end else if
};
FPanoramic.prototype.setMaxZoom = function (value)
{
    this.options.max_zoom = value;
    if (this.imageContainer._xscale >= value)
    {
        this.imageContainer._xscale = this.imageContainer._yscale = value;
        if (this.imageContainer._width * 3 < this.theMask._width || this.imageContainer._height < this.theMask._height)
        {
            this.imageContainer._width = this.theMask._width * 3;
            this.imageContainer._height = this.theMask._height;
            this.options.image_xscale = this.imageContainer._xscale;
            this.options.image_yscale = this.imageContainer._yscale;
            this.options.max_zoom = this.imageContainer._xscale;
        } // end if
    } // end if
    return;
};
FPanoramic.prototype.getMaxZoom = function ()
{
    return (this.options.max_zoom);
};
FPanoramic.prototype.setLoadedHandler = function (args)
{
    this.options.loadedHandler = args;
};
FPanoramic.prototype.defineHotSpot = function (spotName, x, y, handler)
{
    this.options.hot_spot[spotName] = new Array();
    this.options.hot_spot[spotName].name = spotName;
    this.options.hot_spot[spotName].x = x;
    this.options.hot_spot[spotName].y = y;
    this.options.hot_spot[spotName].handler = handler;
    if (this.__loaded)
    {
        this.refreshSpot();
    } // end if
};
FPanoramic.prototype.refreshSpot = function ()
{
    this.imageContainer.__hot.removeMovieClip();
    this.imageContainer.createEmptyMovieClip("__hot", 19999);
    this.imageContainer.__hot._x = -this.imageContainer._width / 2 / (this.imageContainer._xscale / 100);
    this.imageContainer.__hot._y = -this.imageContainer._height / 2 / (this.imageContainer._yscale / 100);
    var max_y = this.imageContainer._height;
    var min_y = 0;
    var max_x = this.imageContainer._width / 3;
    var min_x = 0;
    for (var a in this.options.hot_spot)
    {
        var b = 0;
        while (b < 3)
        {
            if (typeof(this.options.hot_spot[a]) != "function")
            {
                var this_spot = this.imageContainer.__hot.attachMovie("spot_arrow", this.options.hot_spot[a].name + "_" + b, this.options.depth++);
                if (this.options.hot_spot[a].x < min_x)
                {
                    this.options.hot_spot[a].x = min_x;
                } // end if
                if (this.options.hot_spot[a].x + this_spot._width > max_x)
                {
                    this.options.hot_spot[a].x = max_x - this_spot._width;
                } // end if
                this_spot._x = this.options.hot_spot[a].x + this.imageContainer._width / 3 / (this.imageContainer._xscale / 100) * b;
                this_spot._y = this.options.hot_spot[a].y;
                if (this_spot._y < min_y)
                {
                    this_spot._y = min_y;
                } // end if
                if (this_spot._y + this_spot._height > max_y)
                {
                    this_spot._y = max_y - this_spot._height;
                } // end if
                this_spot.handler = this.options.hot_spot[a].handler;
                this_spot.onMouseUp = function ()
                {
                    if (this._parent._parent._parent.getEnabled())
                    {
                        if (this.hitTest(_root._xmouse, _root._ymouse, false))
                        {
                            _root[this.handler]();
                        } // end if
                    } // end if
                };
            } // end if
            ++b;
        } // end while
    } // end of for...in
};
Object.registerClass("FPanoramic", FPanoramic);
#endinitclip