dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Loading an FLV from a variable

  1. #1
    Member
    Join Date
    Nov 2000
    Posts
    90

    Loading an FLV from a variable : SOLVED!!

    I could have sworn I saw something about this in the forums, but after doing a few searches I came up with nothing so here goes...

    I want to be able to pass a variable to load an flv video...here is the script I'm using

    code:

    function videoLoad(videoChoice) {
    videoPath = "videos/" + videoChoice
    var connection_nc:NetConnection = new NetConnection();
    connection_nc.connect(null);
    var stream_ns = new NetStream(connection_nc);
    _level0.video_window.my_video.attachVideo(stream_n s);
    stream_ns.play(videoPath);
    }

    And then on my button I have something like this...

    on (release){
    videoLoad("video1.flv");
    }



    Doesn't work though... any thoughts???

    Ideally I will load the list of my videos from either XML or a database or even a text file or whatever...so they variable idea is important...

    Thanks!!!
    Last edited by Branden; 01-26-2005 at 09:36 AM.

  2. #2
    Member
    Join Date
    Nov 2000
    Posts
    90
    Well...figured it out for myself, but I thought I<d post my results here in case someone else gets into this situation...

    It came down to a code placement issue...had to remove most of the video init section outside of the videoLoad function...example below...

    code:

    //this goes in the root timeline with all my other AS

    var connection_nc:NetConnection = new NetConnection();
    connection_nc.connect(null);
    var stream_ns = new NetStream(connection_nc);
    _level0.video_window.my_video.attachVideo(stream_n s);

    //Now that the video is initialized, I can launch the video based on the variable...

    function videoLoad(videoChoice) {
    videoPath = "videos/" + videoChoice;
    stream_ns.play(videoPath);
    }

    // Button script stays the same
    on (release){
    videoLoad("video1.flv");
    }


    Last edited by Branden; 01-26-2005 at 09:36 AM.

  3. #3
    Member
    Join Date
    Nov 2000
    Posts
    90
    Bump to show that it's been solved....

  4. #4
    Senior Member
    Join Date
    May 2001
    Posts
    493
    hey Branden,
    I'm also trying to load flvs from a variable.
    I've got the MediaDisplay and MediaController components on the stage, they are linked up and working great. The flv that plays at present is set in the component Inspector panel.
    Now that It's working fine with one flv, i'd like to be able to change the choice of flv without having to have multiple instances of the components on stage - do you know how i'd go about this?

    any help/time you can give is greatly appreciated
    G

  5. #5
    Member
    Join Date
    Nov 2000
    Posts
    90
    Hey there...

    DO something like this...^

    code:


    videoPath = "url to your video.flv"


    myComponent.setMedia(videoPath, "FLV");




    where myComponent is the instance name of your Media Display component



    Hope that helps!!

  6. #6
    Senior Member
    Join Date
    May 2001
    Posts
    493
    cheers m8,
    will let you know how i get on
    G

  7. #7
    Senior Member
    Join Date
    May 2001
    Posts
    493
    tnx Branden,
    working perfectly - cheers again for your help
    G

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