A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: XML Text rollover

  1. #1
    Junior Member
    Join Date
    Dec 2006
    Posts
    8

    XML Text rollover

    Hello,
    Any direction to this would be helpful.

    I have a flash file and the menu is loaded in with xml. I would like for users to know its a menu by having the text change colors when you rollover them. Now I'm not so good with actionscripting, but I can pull things out that I need. If anyone knows of a good link or can post a simple example that would be great.

    Thanks
    Ashley

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    can you post the code that generates the menu?
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Junior Member
    Join Date
    Dec 2006
    Posts
    8
    code:

    stop();


    desc_txt.embedFonts = true;

    rollover = new Sound(this);
    rollover.attachSound("click.mp3")
    click = new Sound(this);
    click.attachSound("click2.mp3");



    function loadXML(loaded) {
    if (loaded) {
    xmlNode = this.firstChild;
    /* image = [];
    gallerytitle = [];
    menutitle = [];
    copy = [];*/
    for (i=0; i<xmlNode.childNodes.length; i++) {
    /* image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    gallerytitle[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
    menutitle[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
    copy[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;*/
    menutitle_fn(i);
    }
    _root.attachMovie("TopBar","Bar",_root.getNextHigh estDepth())
    Bar._x = -100
    g = 0;
    n = 0;
    Info_mc.onRollOver = function(){
    this.onEnterFrame = function(){
    if(n < 10){this._y -= 0
    this.spinArrow._rotation += 9
    n++
    }else{this.onEnterFrame = null}
    }}
    Info_mc.onRollOut = function(){
    this.onEnterFrame = function(){
    if(n > 0){this._y += 0
    this.spinArrow._rotation -= 9
    n--
    }else{this.onEnterFrame = null}
    }}
    Info_mc.createTextField("comment_text",1,-Info_mc._width/2,20-Info_mc._height/7,Info_mc._width,Info_mc._height)
    //Format the gallery buttons
    infofrmt = new TextFormat()
    infofrmt.font = "Arial";
    infofrmt.size = 14;
    infofrmt.bold = false;
    infofrmt.italic = false;
    //end info text formatting
    Info_mc.comment_text.multiline = true;
    Info_mc.comment_text.wordWrap = true;
    Info_mc.comment_text.background = false;
    Info_mc.comment_text.border = false;
    Info_mc.comment_text.selectable = false;
    Info_mc.comment_text.setTextFormat(infofrmt);
    firstImage();
    } else {
    content = "file not loaded!";
    }
    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("printfolio.xml");
    /////////////////////////////////////
    listen = new Object();
    listen.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
    click.start();
    prevImage();
    } else if (Key.getCode() == Key.RIGHT) {
    click.start();
    nextImage();
    }
    };
    Key.addListener(listen);
    previous_btn.onRelease = function() {
    prevImage();
    };
    next_btn.onRelease = function() {
    nextImage();
    };
    /////////////////////////////////////
    p = 0;
    cols = 1; //the number of columns you want
    this.onEnterFrame = function() {
    filesize = picture.getBytesTotal();
    loaded = picture.getBytesLoaded();
    gallerytitle_txt.text = xmlNode.childNodes[g].attributes.name;
    Info_mc.comment_text.text = xmlNode.childNodes[g].childNodes[p].attributes.info;
    Info_mc.comment_text.setTextFormat(infofrmt);
    preloader._visible = true;
    if (loaded != filesize) {
    preloader.preload_bar._xscale = 100*loaded/filesize;
    } else {
    /* picture.onRelease = function(){
    getURL(xmlNode.childNodes[g].childNodes[p].attributes.source,_blank)
    }*/
    preloader._visible = false;
    if (picture._alpha<100) {
    picture._alpha += 7;
    }
    }
    };
    function nextImage() {
    if (p<(xmlNode.childNodes[g].childNodes.length-1)) {
    p++;
    } else {
    p = 0; // Resets to first image
    }
    if (loaded == filesize) {
    picture._alpha = 0;
    picture.loadMovie(xmlNode.childNodes[g].childNodes[p].attributes.source,1);
    Info_mc.comment_text.text = xmlNode.childNodes[g].childNodes[p].attributes.info;
    //gallerytitle_txt.text = gallerytitle[p];
    picture_num();
    }
    }
    function prevImage() {
    if (p>0) {
    p--;
    //picture._alpha = 0;
    //picture.loadMovie(xmlNode.childNodes[g].childNodes[p].attributes.source, 1);
    //gallerytitle_txt.text = gallerytitle[p];
    //picture_num();
    } else {
    p = xmlNode.childNodes[g].childNodes.length-1; // resets to last image
    }
    picture._alpha = 0;
    picture.loadMovie(xmlNode.childNodes[g].childNodes[p].attributes.source,1);
    Info_mc.comment_text.text = xmlNode.childNodes[g].childNodes[p].attributes.info;
    //gallerytitle_txt.text = gallerytitle[p];
    picture_num();
    }
    function firstImage() {
    if (loaded == filesize) {
    picture._alpha = 0;
    picture.loadMovie(xmlNode.childNodes[g].firstChild.attributes.source,1);
    Info_mc.comment_text.text = xmlNode.childNodes[g].firstChild.attributes.info;
    gallerytext_txt.text = xmlNode.childNodes[g].attributes.name;
    picture_num();
    }
    }
    function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+xmlNode.childNodes[g].childNodes.length;
    }

    function nextGallery() {
    if (loaded == filesize) {
    picture._alpha = 0;
    /* if(g < xmlNode.childNodes.length){g++
    }else{g = 0}*/
    p = 0;
    picture.loadMovie(xmlNode.childNodes[g].firstChild.attributes.source, 1);
    Info_mc.comment_text.text = xmlNode.childNodes[g].childNodes[p].attributes.info;
    gallerytext_txt.text = xmlNodes.childNodes[g].attributes.name;
    picture_num();
    }
    }
    function menutitle_fn(k) {

    target_mc = _root.createEmptyMovieClip("t"+k, _root.getNextHighestDepth());

    target_mc.createTextField("txt",1,0,0,90,40);
    //Format the gallery buttons
    btntxtstyle = new TextFormat()
    btntxtstyle.font = "times";
    btntxtstyle.size = 18;
    btntxtstyle.bold = false;
    btntxtstyle.italic = false;
    btntxtstyle.color = 0x000000 //hexadecimal RGB color of button text
    overColor = new TextFormat();
    //create standardColor textFormat
    target_mc.txt.border = false;
    target_mc.txt.backgroundColor = 0xFFFFFF //hexadecimal RGB color of button
    target_mc.txt.autoSize = "right"
    //end gallery button formatting
    target_mc.txt.background = false;
    target_mc.txt.selectable = false;
    target_mc.txt.text = xmlNode.childNodes[k].attributes.name
    target_mc.txt.setTextFormat(btntxtstyle);


    /* tlistener = new Object();
    tlistener.onLoadInit = function(target_mc)
    {*/

    target_mc._x = (slider_mc._x + (k%cols)*(target_mc._width+7));
    target_mc._y = slider_mc._y + Math.floor(k/cols)*(target_mc._height+7);
    target_mc.pictureValue = k;
    target_mc.onEnterFrame = function(){
    this._y = slider_mc._y + slider_mc.menu_mc._y + Math.floor(this.pictureValue/cols)*(this._height+7)}
    target_mc.onRelease = function() {
    click.start();
    g = this.pictureValue;
    nextGallery();
    this.txt._alpha = 30;
    };
    target_mc.onRollOver = function() {
    rollover.start();
    this.txt._alpha = 50;
    };
    target_mc.onRollOut = function() {
    this.txt._alpha = 100;
    };
    };/*
    image_mcl = new MovieClipLoader();
    image_mcl.addListener(tlistener);
    image_mcl.loadClip("images/menu_cat.jpg", "slider_mc.menu_mc.t"+k);
    }*/



  4. #4
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    I believe where you would need to do that is:

    target_mc.onRollOver = function() {

    rollover.start();

    this.txt._alpha = 50;
    this.txt.textColor = 0xFF0000
    };

    target_mc.onRollOut = function() {

    this.txt._alpha = 100;
    this.txt.textColor = 0xFFFFFF
    };
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  5. #5
    Junior Member
    Join Date
    Dec 2006
    Posts
    8
    oh my goodness thank you soooo much. You have no idea.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center