A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: AS2 Load Video From XML In Respective Video Objects

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Location
    Toronto Canada
    Posts
    7

    AS2 Load Video From XML In Respective Video Objects

    Hello Flash Kit

    Iv been a long time troller of the flash kit forums but never needed to ask for help until today. Me and XML are not friends, it never wants to work for me. So i have come to you for help. I need to load videos via XML into its respective video objects.

    so ..... this is what i need to do

    onClick of video1_btn play the first video in the XML in videoObj_1


    onClick of video2_btn play the second video in the XML in videoObj_2


    onClick of video3_btn play the third video in the XML in videoObj_3

    I know the flash Kit Community can help me.

    Thanks Very Much

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    what does the xml file look like ?

  3. #3
    Junior Member
    Join Date
    Feb 2008
    Location
    Toronto Canada
    Posts
    7
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <videos>
    <video url="video1.flv"/>
    <video url="video2.flv"/>
    <video url="video3.flv"/>
    <video url="video4.flv"/>
    <video url="video5.flv"/>
    <video url="video6.flv"/>
    <video url="video7.flv"/>
    <video url="video8.flv"/>
    <video url="video9.flv"/>
    </videos>
    also i have failed at creating the functional as2 code. after doing it 5 times i have just taken it out and started to seek out help from communities. so AS code would be a blessing

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PHP Code:
    // load the xml file
    xmlData = new XML();
    xmlData.ignoreWhite true;
    xmlData.onLoad loadXML;
    xmlData.load("videos.xml");

    // parse the nodes of the xml into an array
    function loadXML(){
    vidArray = new Array();
    aNode this.firstChild.childNodes;
    len aNode.length;
    for(var 
    n=0;n!=len;n++){
    vidArray[n] = aNode[n].attributes.url;
    }
    };

    // buttons
    video1_btn.onRelease = function(){
    trace(vidArray[0]);
    // videoObj_1 - instance name of FLVPlayback component
    videoObj_1.contentPath vidArray[0];
    }; 

    video2_btn.onRelease = function(){
    trace(vidArray[1]);
    videoObj_2.contentPath vidArray[1];
    }; 
    hth

  5. #5
    Junior Member
    Join Date
    Feb 2008
    Location
    Toronto Canada
    Posts
    7
    Flash crashes on export but thanks for the help, if you have the FLA post it and ill see if it works

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Flash 8 file attached
    Attached Files Attached Files

  7. #7
    Junior Member
    Join Date
    Feb 2008
    Location
    Toronto Canada
    Posts
    7
    You are the best. i have it working right now

  8. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176

  9. #9
    Junior Member
    Join Date
    Feb 2008
    Posts
    3
    Okay, I did all of this and when I trace the array it keeps coming up undefined? Does anyone have a clue what's going on?

    I should clarify that I'm trying that trace statement outside of the loadXML function.

    Right. Further searching tells me that it's trying to trace the array before it's been populated and that the XML hasn't fully loaded yet.

    This place is awesome.
    Last edited by BPiaB; 02-27-2008 at 09:10 PM.

  10. #10
    Junior Member
    Join Date
    Oct 2009
    Posts
    2
    Hello a_modified_dog

    I'm kind of new with AS and Flash ..

    The thing i want to do is almost what you publish on your FLA.

    What i want is...

    Having 2 buttons(image) to let the visitor choose the video they want to see.

    After that the video play .. and a button appear ( back to choice ) or automaticly reload the swf to return to the "first frame"

    Actually i need something like ... 195 width and almost 200 height.

    So i try to put your script / button in a new one, but if they are suppose to play inside my little space, actually they play both but, i'm not able to play the choice #1 ( it's over #2) because #2 overlap #1 player!

    Hope all that information can help.

  11. #11
    Junior Member
    Join Date
    Oct 2009
    Posts
    2
    Now that i have a good solution.

    I want to know ifit's possible to add a link to the specific site..

    In the XML ???

    In the AS ???

    Give me your advice on that!

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