A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: HTML Link from XML - Flash 8

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Location
    Essex, UK
    Posts
    11

    HTML Link from XML - Flash 8

    Hi Forum,

    I've been scratching my head now for 3 days trying to work this out, as you can probably guess, another newbie question so sorry in advance.

    Using Flash 8 & AS2, I have a video gallery that loads from a scrolling menu, all I want is to be able to put a link somewhere - probably on the video title is easiest! so that viewers can click and download the video they are watching - sounds simple ..... not to me!

    Question is, where or what do I put in to make a URL load from XML to the Flash?


    The code I am using is below:

    XML:
    <?xml version="1.0" encoding="utf-8"?>
    <item>

    <list name="Me Driving my car " videotitle="My Car" link="video/154_t3.flv" >
    <thumb>thumb/154_t3.jpg</thumb>
    </list>
    </item>
    The Flash code:
    stop();
    System.useCodepage = true;
    var space = 4;
    var path = "2005.xml";//xml path
    contentMain4.createEmptyMovieClip("back_mc", this.getNextHighestDepth());
    contentMain4.setMask(maskedView);
    var myxml = new XML();
    myxml.ignoreWhite = true;
    myxml.onLoad = function(success) {
    var item = this.firstChild.childNodes;
    trace(this.firstChild.firstChild.attributes.videot itle+linky);
    if (success) {

    for (var i:Number = 0; i<item.length; i++) {
    var temp_mc = contentMain4.attachMovie("item", "item"+i, i);
    temp_mc._y += i*(temp_mc._height+space);
    contentMain4.back_mc._height = i*(temp_mc._height+space);
    temp_mc.tname = item[i].attributes.name;
    temp_mc.tlink = item[i].attributes.link;
    temp_mc.videotitle = item[i].attributes.videotitle;
    temp_mc.thumb = item[i].firstChild.firstChild.nodeValue;
    temp_mc.item_txt.text = temp_mc.tname;
    temp_mc.item_thumb.loadMovie(temp_mc.thumb);
    contentHolder_mc.contentinfo.htmlText = item[0].childNodes[1].firstChild.nodeValue;
    temp_mc.onRelease = function() {
    vtitle_txt.text = this.videotitle;
    playBut.onRelease();
    videoDisplay.setMedia(this.tlink,"FLV");

    };
    }

    vtitle_txt.text = this.firstChild.firstChild.attributes.videotitle;
    videoDisplay.setMedia(this.firstChild.firstChild.a ttributes.link,"FLV");
    scrolling(easing, auto, mouseWheel, mouseCoord, barVisual);

    } else {
    trace("error");
    }
    };

    myxml.load(path);
    function scrolling(easing, auto, mouse) {
    //you can modify scroll speed.
    var moveSpeed = 1;
    //you can modify easing speed.
    var easingSpeed = 10;
    var scrollHeight = scrollbg4._height;
    //you donnot need modify the fellowing code.if you are a AS coder you can do .
    var scrollable = contentMain4._height-maskedView._height+2;
    var top_scroll = contentMain4._y;
    var left = scrollbg4._x-2;
    var top = scrollbg4._y;
    var right = scrollbg4._x-2;
    var bottom = scrollbg4._y+scrollbg4._height-dragger4._height;
    if (scrollable<0) {
    dragger4._visible = false;
    btnup4._alpha = 0;
    btndown4._alpha = 0;
    scrollbg4._alpha = 0;
    btnup4.enabled = false;
    btndown4.enabled = false;
    return;
    }
    }
    Thanks for looking anyway

    Tigger7

  2. #2
    Member
    Join Date
    Aug 2004
    Location
    UK
    Posts
    88
    can you create a button and use get url eg

    get_video_button.onPress = function(){
    getURL("movieName.mov", "_blank");
    }
    http://robotnic.co.uk/
    -----------------------------------------

  3. #3
    Junior Member
    Join Date
    Jun 2007
    Location
    Essex, UK
    Posts
    11
    Quote Originally Posted by tiny_legoman
    can you create a button and use get url eg

    get_video_button.onPress = function(){
    getURL("movieName.mov", "_blank");
    }
    Excellent Idea Legoman but I need it to associate with the XML document which holds the data of each movie!

    Can this method be used but call up the url from the xml document and then point it to "Save as" to the hard drive?
    It would be cool if it could.

    Tigger7
    Last edited by Tigger7; 03-12-2008 at 04:32 PM.

  4. #4
    Member
    Join Date
    Aug 2004
    Location
    UK
    Posts
    88
    yeah im sure you can, but im not sure how. i think some browsers will do that anyway, look up the geturl command. the open browser method bit might hold the answer, im using "_blank", but there are a couple of other options. You could also use fscommand to trigger a javascript function in the page that would do it, again im not sure what you would actually do with javascript, but there must be some example code somewhere....
    http://robotnic.co.uk/
    -----------------------------------------

  5. #5
    Junior Member
    Join Date
    Jun 2007
    Location
    Essex, UK
    Posts
    11
    OK, I'll do a bit of googling about the geturl function, got to be a step in the right direction :-)

    Thanks for your help

    Tigger7

  6. #6
    Member
    Join Date
    Aug 2004
    Location
    UK
    Posts
    88
    man its a nightmare try to suss code out without indents!! anyway to extract the video file you might try something like this:

    ive added a videofile attribute to the list node -

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <item>
    
    <list name="Me Driving my car " videotitle="My Car" link="video/154_t3.flv" videoFile="path/movieFile.wmv" >
    <thumb>thumb/154_t3.jpg</thumb>
    </list>
    </item>




    Code:
    stop();
    System.useCodepage = true;
    var space = 4;
    var path = "2005.xml";//xml path
    contentMain4.createEmptyMovieClip("back_mc", this.getNextHighestDepth());
    contentMain4.setMask(maskedView);
    var myxml = new XML();
    myxml.ignoreWhite = true;
    myxml.onLoad = function(success) {
    var item = this.firstChild.childNodes;
    trace(this.firstChild.firstChild.attributes.videot itle+linky);
    if (success) {
    
    for (var i:Number = 0; i<item.length; i++) {
    var temp_mc = contentMain4.attachMovie("item", "item"+i, i);
    temp_mc._y += i*(temp_mc._height+space);
    contentMain4.back_mc._height = i*(temp_mc._height+space);
    temp_mc.tname = item[i].attributes.name;
    temp_mc.tlink = item[i].attributes.link;
    temp_mc.videotitle = item[i].attributes.videotitle;
    temp_mc.thumb = item[i].firstChild.firstChild.nodeValue;
    
    
    //create a button and stick it in the library and attach it to the contentMain4 clip, im assuming thats where all the action is. ive positioned it 50 from the left 50 from the top relative to contentMain4.
    
    contentMain4.attachMovie("get_video_button", "get_video_button", contentMain4.getnextHighestDepth(), {_y: 50, _x:50});
    contentMain4.get_video_button.onPress = function(){
    	getURL(item[i].attributes.videoFile, "_blank");
    }
    
    
    temp_mc.item_txt.text = temp_mc.tname;
    temp_mc.item_thumb.loadMovie(temp_mc.thumb);
    contentHolder_mc.contentinfo.htmlText = item[0].childNodes[1].firstChild.nodeValue;
    temp_mc.onRelease = function() {
    vtitle_txt.text = this.videotitle;
    playBut.onRelease();
    videoDisplay.setMedia(this.tlink,"FLV");
    
    };
    }
    
    vtitle_txt.text = this.firstChild.firstChild.attributes.videotitle;
    videoDisplay.setMedia(this.firstChild.firstChild.a ttributes.link,"FLV");
    scrolling(easing, auto, mouseWheel, mouseCoord, barVisual);
    
    } else {
    trace("error");
    }
    };
    
    myxml.load(path);
    function scrolling(easing, auto, mouse) {
    //you can modify scroll speed.
    var moveSpeed = 1;
    //you can modify easing speed.
    var easingSpeed = 10;
    var scrollHeight = scrollbg4._height;
    //you donnot need modify the fellowing code.if you are a AS coder you can do .
    var scrollable = contentMain4._height-maskedView._height+2;
    var top_scroll = contentMain4._y;
    var left = scrollbg4._x-2;
    var top = scrollbg4._y;
    var right = scrollbg4._x-2;
    var bottom = scrollbg4._y+scrollbg4._height-dragger4._height;
    if (scrollable<0) {
    dragger4._visible = false;
    btnup4._alpha = 0;
    btndown4._alpha = 0;
    scrollbg4._alpha = 0;
    btnup4.enabled = false;
    btndown4.enabled = false;
    return;
    }
    }

    is that what you were after - i havent tried this btw!?
    http://robotnic.co.uk/
    -----------------------------------------

  7. #7
    Junior Member
    Join Date
    Jun 2007
    Location
    Essex, UK
    Posts
    11
    Legoman,
    Not quite working yet but it's deffo given me hope. Got a couple of errors but I can see where this is going now so I'll have a play with it.

    Thanks Sooooo much for you time and a thousand apologies for the non idented code, I'll do it properly next time .. coz I'm bound to have more questions in the future.

    Top man

    Tigger7

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