Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-09-2012, 05:41 PM   PM User | #1
gwolff2005
New to the CF scene

 
Join Date: Nov 2012
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
gwolff2005 is an unknown quantity at this point
embedding Trajan Pro to ActionScript - HELP!!!

Hi guys,
I am desperate. I try to use Trajan Pro on my website and have it in a swf file. What do I need to write to embed Trajan Pro into it.

Thanks very much in advance for your help!

Code:
var width = 590;
var height = 60;
var offset_x = 0;
var offset_y = 0;
var button_scale_off = false;
var button_style = ["mainbutton", "subbutton"];
var button_transparency = [100, 0];
var button_bk_color_on = [0, 0];
var button_bk_color = [13882323, 13882323];
var scroll_speed = [5, 5];
var button_space_horizontal = [5, 5];
var button_space_vertical = 0;
var shadowed_button = [false, false];
var submenu_shows_on = "Over";
var empty_text = "";
var empty_text_font_valign = "middle";
var empty_text_style = new TextFormat("Trajan Pro", 18, 8033950, true, false, false, "", "", "center");
var text_style = [];
text_style[0] = new TextFormat("Trajan Pro", 20, 16777200, false, false, false);
var text_color_normal = [16777200, 16777215];
var text_color_over = [16777215, 16777215];
var background_color_normal = [5266588, 5266588];
var background_color_over = [5266588, 5266588];
var background_color_animation = [5266588];
text_style[1] = new TextFormat("Trajan Pro", 13, 16777215, false, false, false);
[Embed(source="/fonts/trajanpro-regular-webfont.ttf", fontName="TrajanPro", mimeType="application/x-font- truetype")]
function drawShadow(in_mc, in_button)
{
    with (in_mc)
    {
        beginFill(0, 100 - 60);
        var sx = in_button._x + 5;
        var sy = in_button._y + 5;
        var sw = in_button.movie._width;
        var sh = in_button.movie._height;
        moveTo(sx, sy);
        lineTo(sx + sw, sy);
        lineTo(sx + sw, sy + sh);
        lineTo(sx, sy + sh);
        endFill();
    } // End of with
} // End of the function
function showSubmenu(in_mc)
{
    if (in_mc.level_ == 0)
    {
        if (active_sub_menu != in_mc.sub_menu_)
        {
            var color_ = new Color(active_button.movie.button_color);
            color_.setRGB(background_color_normal[0]);
            active_sub_menu.effect_state = "off";
            active_sub_menu = in_mc.sub_menu_;
            active_sub_menu.effect_state = "on";
            active_button = in_mc;
            active_sub_menu._x = offset_x;
        } // end if
    } // end if
    if (active_sub_menu != 0)
    {
        empty_tf._visible = false;
    }
    else
    {
        empty_tf._visible = true;
    } // end else if
} // End of the function
function doPressButton()
{
    sound_down.start();
    if (length(this._parent._parent.link_) > 0)
    {
        getURL(this._parent._parent.link_, this._parent._parent.target_);
    } // end if
    if (submenu_shows_on != "Over")
    {
        showSubmenu(this._parent._parent);
    } // end if
} // End of the function
function setOverColor()
{
    sound_over.start();
    this._parent._parent._text.textColor = text_color_over[this._parent._parent.level_];
    var color_ = new Color(this._parent.button_color);
    color_.setRGB(background_color_over[this._parent._parent.level_]);
    if (active_sub_menu != this._parent._parent.sub_menu_ & this._parent._parent.level_ == 0)
    {
        active_sub_menu.effect_state = "off";
    } // end if
    if (submenu_shows_on == "Over")
    {
        showSubmenu(this._parent._parent);
    } // end if
} // End of the function
function setOutColor()
{
    this._parent._parent._text.textColor = text_color_normal[this._parent._parent.level_];
    if (active_sub_menu != this._parent._parent.sub_menu_ | this._parent._parent.sub_menu_ == 0)
    {
        var color_ = new Color(this._parent.button_color);
        color_.setRGB(background_color_normal[this._parent._parent.level_]);
    } // end if
} // End of the function
function xshift(x, koef, zsuv, level_)
{
    b = _root._xmouse * (1 - koef) - x + offset_x;
    r = b * scroll_speed[level_] * 10 / zsuv;
    return (r);
} // End of the function
function addButton(par_movie, text_, link_, target_, in_level, x, ind)
{
    var name_ = "button" + ind;
    var ref_ = par_movie.attachMovie(button_style[in_level], name_, ind);
    with (ref_)
    {
        _x = x;
        _y = 0;
        var color_ = new Color(movie.button_color);
        color_.setRGB(background_color_normal[in_level]);
        if (in_level == 0)
        {
            var color1_ = new Color(movie.effect_color);
            color1_.setRGB(background_color_animation[in_level]);
        } // end if
    } // End of with
    ref_.link_ = link_;
    ref_.target_ = target_;
    ref_._alpha = 100 - button_transparency[in_level];
    ref_.level_ = in_level;
    ref_.movie.hotspot.onRollOver = setOverColor;
    ref_.movie.hotspot.onRollOut = setOutColor;
    ref_.movie.hotspot.onPress = doPressButton;
    with (ref_._text)
    {
        _x = 0;
        _y = 0;
        autoSize = "left";
        selectable = false;
        background = false;
        border = false;
        html = true;
        htmlText = "  " + text_ + "  ";
        setTextFormat(2, length(text_) + 2, text_style[in_level]);
    } // End of with
    with (ref_)
    {
        if (!button_scale_off)
        {
            movie._width = _text._width;
            movie._height = _text._height;
        }
        else
        {
            _text._x = (movie._width - _text._width) / 2;
            _text._y = (movie._height - _text._height) / 2;
        } // end else if
        movie._x = 0;
        movie._y = 0;
        movie._x = movie._width / 2;
        movie._y = movie._height / 2;
    } // End of with
    return (ref_);
} // End of the function
function buildMenu(inNodes, x, y, level_)
{
    var shift_ = 0;
    var items_count = 0;
    var name_ = "container" + menus_count;
    var ref_ = 0;
    ref_ = createEmptyMovieClip(name_, 1000 - menus_count);
    ref_.onEnterFrame = on_enter_frame;
    ++menus_count;
    ref_._x = x;
    ref_._y = y;
    ref_.level_ = level_;
    if (level_ > 0)
    {
        ref_._visible = false;
        ref_._alpha = 0;
    } // end if
    ref_.effect_state = 0;
    var button_ = 0;
    var i = 0;
    
    while (i++, i < inNodes.length)
    {
        var node = inNodes[i];
        var text_ = node.attributes.text;
        var link_ = node.attributes.link;
        var target_ = node.attributes["target-frame"];
        button_ = addButton(ref_, text_, link_, target_, level_, shift_, items_count);
        if (shadowed_button[level_])
        {
            drawShadow(ref_, button_);
        } // end if
        shift_ = shift_ + (button_.movie._width + button_space_horizontal[level_]);
        button_.sub_menu_ = 0;
        shed_shift = 0;
        if (node.childNodes.length > 0)
        {
            button_.sub_menu_ = buildMenu(node.childNodes, button_._x, ref_._y + button_.movie._height + button_space_vertical, level_ + 1);
        } // end if
        ++items_count;
    } // end while
    if (level_ == 0)
    {
        if (length(empty_text) > 0)
        {
            tf_yshift = ref_._y + button_.movie._height + button_space_vertical;
            createTextField("empty_tf", -1, 0, tf_yshift, 0, 0);
            with (empty_tf)
            {
                autoSize = true;
                selectable = false;
                background = false;
                border = false;
                text = " " + empty_text + " ";
                setTextFormat(1, length(empty_text) + 1, empty_text_style);
                if (empty_text_style.align == "center")
                {
                    _x = (width - textWidth) / 2;
                } // end if
                if (empty_text_style.align == "right")
                {
                    _x = width - textWidth;
                } // end if
            } // End of with
        } // end if
    } // end if
    ref_.zsuv = shift_ - button_space_horizontal[level_];
    ref_.koef = shift_ / width;
    return (ref_);
} // End of the function
function isLoaded()
{
    active_sub_menu = 0;
    active_button = 0;
    menus_count = 0;
    buildMenu(this.firstChild.childNodes, offset_x, offset_y, 0);
} // End of the function
on_enter_frame = function ()
{
    var shed_shift = 0;
    if (shadowed_button[this.level_])
    {
        shed_shift = 5;
    } // end if
    if (width < this._width)
    {
        if (this._ymouse > 0 & this._ymouse < this._height - shed_shift)
        {
            this._x = this._x + xshift(this._x, this.koef, this.zsuv, this.level_);
        } // end if
    } // end if
    ef_s = this.effect_state;
    if (ef_s != 0)
    {
        transp_ = 100 - button_transparency[this.level_];
        if (ef_s == "on")
        {
            this._visible = true;
            if (transp_ < this._alpha)
            {
                this._alpha = transp_;
                this.effect_state = 0;
            }
            else
            {
                this._alpha = this._alpha + 5;
            } // end if
        } // end else if
        if (ef_s == "off")
        {
            if (this._alpha <= 0)
            {
                this._alpha = 0;
                this.effect_state = 0;
                this._visible = false;
            }
            else
            {
                this._alpha = this._alpha - 5;
            } // end if
        } // end if
    } // end else if
};
xmlDoc = new XML();
xmlDoc.ignoreWhite = true;
xmlDoc.onLoad = isLoaded;
xmlDoc.parseXML("<items><item text=\"Home\" link=\"http://www.guntmarwolff.com\" target-frame=\"_self\"/><item text=\"Info\" link=\"\" target-frame=\"_self\"><subitem text=\"Über Guntmar\" link=\"info.php\" target-frame=\"_self\"/><subitem text=\"Presseartikel\" link=\"presse.php\" target-frame=\"_self\"/></item><item text=\"Vorträge\" link=\"vortraege.php\" target-frame=\"_self\"><subitem text=\"Themen\" link=\"vthemen.php\" target-frame=\"_self\"/><subitem text=\"Anfrage\" link=\"vanfrage.php\" target-frame=\"_self\"/></item><item text=\"Seminare\" link=\"\" target-frame=\"_self\"><subitem text=\"Themen\" link=\"sthemen.php\" target-frame=\"_self\"/><subitem text=\"Kalender\" link=\"skalender.php\" target-frame=\"_self\"/><subitem text=\"Buchung\" link=\"sbuchung.php\" target-frame=\"_self\"/><subitem text=\"Inhouse-Anfrage\" link=\"sanfrage.php\" target-frame=\"_self\"/></item><item text=\"Interaktion\" link=\"\" target-frame=\"_self\"><subitem text=\"Forum\" link=\"http://www.guntmarwolff.com/forum\" target-frame=\"_blank\"/><subitem text=\"Blog\" link=\"http://www.guntmarwolff.com/blog\" target-frame=\"_blank\"/><subitem text=\"Presseportal\" link=\"presseportal.php\" target-frame=\"_self\"/><subitem text=\"Facebook\" link=\"http://www.facebook.com/pages/Guntmar-Wolff/211668775601453?ref=ts&amp;fref=ts\" target-frame=\"_blank\"/><subitem text=\"Kontakt\" link=\"kontakt.php\" target-frame=\"_self\"/></item></items>");
xmlDoc.onLoad(true);
gwolff2005 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:32 PM.


Advertisement
Log in to turn off these ads.