Random swf/f4v load

Hey I have this problem - with help from Kglad in a previous post plus a look on another post I have the underneath action script.
What I really need it to do, is to load a random movie from my array, and when it replay the movie it has to be the same movie as which was randomly loaded... So far I have this code:
var movies:Array =["film/film1.f4v", "film/film2.f4v"]
function shuffle(a:Array) {
for (var ivar = a.length-1; ivar>=0; ivar--) {
var p = Math.floor(Math.random())(ivar+1);
var t = a[ivar];
a[ivar] = a[p];
a[p] = t;
var timedelay:Number = 10;  // seconds delay in replay
var video;
var nc:NetConnection;
var ns:NetStream;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.client = this;
ns.addEventListener(NetStatusEvent.NET_STATUS,netStatusf);
function netStatusf(e:NetStatusEvent) {
    if (e.info.code == "NetStream.Play.Stop" && Math.abs(durationNum-ns.time)<.1) {
setTimeout(replayF,timedelay*1000);
function replayF(){
ns.play(shuffle(movies));
var durationNum:Number;
function onMetaData(iObj:Object):void {
    durationNum = iObj.duration;
video = new Video(287,263);
video.x = 231.1;
video.y = 140.5;
addChild(video);
video.attachNetStream(ns);
ns.play(shuffle(movies));
but doesn't seem to work it comes with this error:
TypeError: Error #1006: value is not a function.
at cv/shuffle()
at cv/frame3()
at flash.display::MovieClip/gotoAndStop()
at cv/index()
Hope someone can help...

Nothing really happens - dosen't come with any error message, but doesn't play any movies...
So don't know if that means that it dosen't return any URL..?
var movies:Array =["film/film1.f4v", "film/film2.f4v"]
function shuffle(a:Array):String{
     for (var ivar = a.length-1; ivar>=0; ivar--) {
          var p = Math.floor(Math.random())*(ivar+1);
          var t = a[ivar];
          a[ivar] = a[p];
          a[p] = t;
          var url = "url"
     return url;
var timedelay:Number = 10;  // seconds delay in replay
var video;
var nc:NetConnection;
var ns:NetStream;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.client = this;
ns.addEventListener(NetStatusEvent.NET_STATUS,netStatusf);
function netStatusf(e:NetStatusEvent) {
    if (e.info.code == "NetStream.Play.Stop" && Math.abs(durationNum-ns.time)<.1) {
setTimeout(replayF,timedelay*1000);
function replayF(){
ns.play(shuffle(movies));
var durationNum:Number;
function onMetaData(iObj:Object):void {
    durationNum = iObj.duration;
video = new Video(287,263);
video.x = 231.1;
video.y = 140.5;
addChild(video);
video.attachNetStream(ns);
ns.play(shuffle(movies));

Similar Messages

  • AS3 array used to load and play random swfs?

    Hi, I'm trying to use an array adapted from AS2 script to load random swfs called "koan_1.swf" or "koan_2.swf" etc into a "koan_loader_mc" on the stage.  Each "koan_#.swf" has code in its last frame to both advance the "shuffle" array in the action script in the first frame of the stage and to load the next koan swf.  The code below -- almost -- works, but....?
    Frame on main stage:
    // creates function called at the end of koan_#.swfs
    function shuffle(a:Array) {
    for (var ivar = a.length-1; ivar>=0; ivar--) {
    var p = Math.floor(Math.random())(ivar+1);
    var t = a[ivar];
    a[ivar] = a[p];
    a[p] = t;
    // loads koans into koan_loader_mc
    var index:uint = 0;
    var koan_loader:Loader = new Loader();
    var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
    koan.shuffle();
    koan_loader.load(new URLRequest(koan[index]));
    MovieClip(this).koan_loader_mc.addChild(koan_loader);
    MovieClip(this).stop();
    Code is on the last frame of the loaded koan swfs:
    MovieClip(stage).index++
    if(MovieClip(stage).index>MovieClip(stage).koan.length-1){
    MovieClip(stage).index=0;
    MovieClip(stage).koan.shuffle();
    MovieClip(stage).koan_loader.load(new URLRequest(koan[MovieClip(stage).index]));
    MovieClip(stage).koan_loader_mc.addChild(koan_loader);
    Thanks for -- any -- guidance and suggestions...at my wit's end...

    Thank you for taking the time to help, but......unfortunately it still isn't working.  When the "koan.shuffle():" segment of code on the first frame of the stage timeline, below, is commented out, everything else in the movie (except randomizing of swfs) works fine.
    This code loads swfs (but they are not randomized/shuffled):
    // loads koans into koan_loader_mc
    var index:uint = 0;
    var koan_loader:Loader = new Loader();
    var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
    //koan.shuffle(); 
    koan_loader.load(new URLRequest(koan[index]));
    MovieClip(this).koan_loader_mc.addChild(koan_loader);
    Thanks again for your help....

  • Loading random .swf's in html page

    Desired scenario: I have a site which I want random .swf
    files to load into index page each time a user refreshes or visits
    the site.
    Solution: I used a Javascript array solution in the .html
    page. Note: it works perfectly in Firefox and Safari.
    The javascript code for that is listed below.
    Problem: In IE, the page which is supposed to load the
    random .swfs in blank. I tried to solve the problem by using an IE
    conditional statement with a single .swf embedded (so at least
    visitor could have interactive experience).
    <!--[if IE]>
    <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"
    width="800" height="600">
    <param name="movie" value="drinks.swf" />
    <param name="quality" value="high" />
    <embed src="drinks.swf" quality="high" pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    type="application/x-shockwave-flash" width="800"
    height="600"></embed>
    </object>
    <script type="text/javascript"
    src="fixit.js"></script>
    <![endif]-->
    Any help would be appreciated. The link to the site in
    question is:
    http://www.jayminnickinteractive.com

    Thank you for checking. Yes right now they are all working.
    But many times I visit the flv's don't load - i wonder if it is a
    flash thing or more connected to my web host.
    Gary

  • Load random swf but not same

    someone here helped with the code to load random SWF files
    into a movie clip...however, i need to make sure it doesnt load the
    one that's already playing, that it goes on to a new one
    everytime..

    i dont think saying thank you really does it, but really,
    thank you.. you've helped me countless number of times, and it's
    only made me better at what I do, so I really am great full .
    Thanks again

  • Make a random swf play on my html website

    I am looking for a way to have a random swf play on the index
    page of my website. I have five products I want to showcase and
    have built five different swf files, one for each. I would now like
    some code that would randomly load one of the 5 files into the
    page, so anyime some one visits the site there will most likely be
    a different swf playing. Also, is there a better way to do this.
    Thanks

    I found this tutorial on Google. If you use Flash, maybe this
    will help
    you.
    http://www.kirupa.com/developer/actionscript/loading_random_movie.htm
    Or, you could use an array and a random rotator JavaScript.
    --Nancy O.
    Alt-Web Design & Publishing
    www.alt-web.com
    "Dreameager" <[email protected]> wrote in
    message
    news:fg4u2r$ejm$[email protected]..
    > I am looking for a way to have a random swf play on the
    index page of my
    > website. I have five products I want to showcase and
    have built five
    different
    > swf files, one for each. I would now like some code that
    would randomly
    load
    > one of the 5 files into the page, so anyime some one
    visits the site there
    will
    > most likely be a different swf playing. Also, is there a
    better way to do
    this.
    >
    > Thanks
    >
    >

  • HOW can I make a .SWF default load after its first load?

    When you have the SAME parent API on every page of an (X)HTML website, can a .SWF tell itself to load from a default position when a website user navigates to different HTML pages?
    Here's my parent API as it stands:
    http://www.playingthepoet.com/
    HOW can you tell the .SWF to load from a default position once the .SWF has loaded a first time? AND from any page of the website, not just the Home page? This is an advanced .SWF networking issue. And I'm not sure if the best solution is a Javascript of if there's a direct AS3 programming solution.
    The blurs and fade-ins are a bunch of timer variables and timer event methods timer event listeners. I want that intro ONLY ONCE. And NOT every time a user changes HTML pages. Please help, and MANY thanks for your time!!
    NT

    Hi ,
    You can set a variable say "count" on stage composition ready -
    sym.setVariable("count" , 0);
    On stage click , you keep checking the value of this variable -
    if(sym.getVariable("count") == 5)
      sym.$("Symbol_2").show();
    //Here "Symbol_2" is the next button that you want to appear on screen(which is initially invisible) when the symbol_1 is clicked say 5 times.
    Now, on click of a button , you keep updating the variable count -
    var countnew = sym.getVariable("count");
    countnew = countnew+1;
    sym.setVariable("count" , countnew);
    Attaching the sample for reference.
    Thanks and Regards,
    Sudeshna Sarkar

  • At random times firefox loads an unrequested page. Sometimes it is the Google search page but more often it is a random page which sometimes loads or stays blank. I do not recognise them as sites from my directory. Otherwise Firefox works well. Any su

    At random times firefox loads an unrequested page. Sometimes it is the Google search page but more often it is a random page which sometimes loads or stays blank. I do not recognise them as sites from my directory. Otherwise Firefox works well. Any suggestion for a cure?
    == This happened ==
    A few times a week
    == one month ago

    Glad to see its working.
    To help other users find solutions, click on the '''"Solved It"''' button Next to the Reply that BEST solved your Question
    Please DO NOT click "Solved It" next to this reply

  • Gallery tree swf not loading

    I am using the gallery_tree.fla provided in the Samples for
    Flash 8 Pro to build a small photo gallery, substituting the name
    of my xml file in this line of code in the action script:
    treeDP_xml.load("bbq_gallery_07.xml"); .
    I used the gallery_tree.xml, substituting my image filenames
    in the nodes. I placed the images, the .xml and the .swf in the
    same folder. The .swf will play if I open it on my local machine in
    a browser, but on the web server, it just continues to show the
    loader but no images or tree.
    My .xml and Actionscript is attached. Suggestions as to my
    problem?

    Seems odd it will only run once. Usually if a cache problem
    you get the same
    results even when you update the movie or server scripts.
    If it is
    http:// it is not local even if from the browser
    cache.
    Verify the html is validated.
    Check to see if this applies to all swfs. Create a simple
    hello world swf
    that connects to a JSP script that returns a simple value to
    Flash. If that
    seems to work, then the problem is in the JSP or
    Actionscripting coding.
    Check you can load the JSP script repeatedly using a direct
    call to it on
    the browser line using
    http://.
    Lon Hosford
    www.lonhosford.com
    Flash, Actionscript and Flash Media Server examples:
    http://flashexamples.hosfordusa.com
    May many happy bits flow your way!
    "srikanth_s_india" <[email protected]> wrote
    in message
    news:e6obld$lfb$[email protected]..
    > Thanks for the article link.
    >
    > I can't provide the URL as it is within our application
    which requires
    > logging
    > in. However, one more interesting thing about it is that
    it always works
    > for
    > the first time (in the browser/machine) but not from the
    next time.
    >
    > My doubt is whether it is because of the caching? When
    it loads for the
    > first
    > time, the HTML and SWF files load from our server and
    hence are allowed to
    > communicate with our JSP. However, when it loads the
    subsequent times, it
    > probably loads from the cache and hence considered as a
    local file and not
    > allowed to communicate with our JSP file which is on the
    Internet.
    >
    > Can anybody tell me how to enable a local SWF file to
    load SWF files from
    > the
    > Internet & access URLs from the Internet in Flash 8
    pluggin?
    >

  • Checking an external swf is loaded?

    Hi
    I'm loading an external .swf via typing the swf name into an input text field and hitting a submit button.
    The swf loads fine, but I'm trying to incorporate updating a status text field on a succesful load or if there is an error during loading.
    I can't find my mistake in the code - to me it should be making  load_status_txt display "ok", but the swf just loads with no status update.
    All the text fileds are fine, because if I code  load_status_txt.text = "hello" straight after addChild(loader); -  load_status_txt displays "hello"
    Can anyone see an obvious mistake below?
    Thanks so much again.
    Shaun
    loadSwfBut.addEventListener("mouseDown", sendData)
    function sendData(evt:Event){
        if(loadSwf.text !=""){
    var Xpos:Number = 0;
    var Ypos:Number = 100;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest(loadSwf.text);
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
            loader.addEventListener(Event.COMPLETE, dataOnLoad);
        } else load_status_txt.text = "All fields are mandatory"
    function dataOnLoad(evt:Event): void{
        load_status_txt.text = "ok";
    stop();

    use:
    loadSwfBut.addEventListener("mouseDown", sendData)
    function sendData(evt:Event){
        if(loadSwf.text !=""){
    var Xpos:Number = 0;
    var Ypos:Number = 100;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest(loadSwf.text);
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, dataOnLoad);
        } else load_status_txt.text = "All fields are mandatory"
    function dataOnLoad(evt:Event): void{
        load_status_txt.text = "ok";
    stop();

  • GetURL not working when swf is loaded into another swf

    Ok, I need some help for something relatively simple which
    for some reason I've not been able to find any information on at
    all?
    Hopefully it will be something easy to fix.
    Essentially I have the following:
    my main movie "Home.swf"
    another movie "Sub.swf"
    I've loaded "Sub.swf" into "Home.swf" via an empty movieclip.
    Within "Sub.swf" I have some links which when clicked call
    getURL and open a HTML page in the browser.
    But for some reason the getURL isn't working and I believe
    its because the getURL is called from a loaded movie within
    "Home.swf".
    I've tried changing the actionscript to:
    _root.getURL('/mypage.html');
    _parent.getURL('/mypage.html');
    but neither (_root / _parent) seems to work?
    Need help here please.
    Many thanks.
    Kind regards,
    M.

    Hi kglad,
    Yes the button is definitely firing ok.
    In the "Sub.swf" movie, on the second frame of the timeline
    (the first frame is some preloader code) there is the following
    code:
    imgMC.mascara.onPress = function() {
    //trace('mc[activo] = ' + mc[activo]);
    switch(mc[activo])
    case _level0.imgMC.MC0:
    trace('0 - ' + mc[activo])
    break;
    case _level0.imgMC.MC1:
    trace('1 - ' + mc[activo])
    break;
    case _level0.imgMC.MC2:
    trace('2 - ' + mc[activo])
    break;
    case _level0.imgMC.MC3:
    trace('3 - ' + mc[activo])
    break;
    case _level0.imgMC.MC4:
    trace('4 - ' + mc[activo])
    break;
    case _level0.imgMC.MC5:
    trace('5 - ' + mc[activo])
    break;
    If I run this movie in Flash (ctrl-enter) then the trace
    works fine.
    But the trace stops working when I run the main "Home.swf"
    movie in Flash (ctrl-enter) when the "Sub.swf" is loaded into an
    empty movie clip.
    And when I change the trace for a getURL and test in a
    browser it still doesn't work?
    What do you reckon?
    Thanks.
    M.

  • Urgent! external swf not loading with swfobject!

    hello there,
    I have a swf that loads another one into it through an empty
    movieclip - When i embed it with swfobject it doesnt appear.
    My guess is that i would have to mention the external swf in
    the flashvars ... Done that with no success.
    Does anyone have an idea of what could be causing me this
    trouble?
    thanks

    Generally the problem will be that the path of all externally
    loaded content is relative to the html page, NOT the swf location.
    If everything is in the same folder then that isn't it.
    Otherwise nice dice is correct, we will need to see your code
    to go further.

  • SWF not Loaded 100% using SWFLoader !!!!!!!

    HI all,
    Iam working in Flex Project, i got hung up with a issue with SWFLoader, I have main application and a sub application developed in FLEX 3, the sub application contains the flex pages of DashBoard screen, the SWF of sub application is loaded in main application using SWFLoader. if the browser is opened full , the SWF is loaded 100% , if the browser is opened 75% the swf is not loaded fully. when the browser is maximized the SWF is not displayed full screen. the issue is THE SWF IS GETTING LOADED ACCORDING TO THE BROWSER SIZE, WHEN BROWSER IS MAXIMIZED THE SWF IS DISPLAYED SAME WHEN BROWSER WAS 75% AND NOT EXPANDED .if anybody come across this issue, pls post reply , thanks.
    The swf of subApplication is loaded in the main with the code:
    <mx:Canvas id="dashCanvas" creationPolicy="all" cachePolicy="on"width="100%" backgroundColor="#FFFFFF" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
    <mx:SWFLoader id="dashBoard" trustContent="true" width="100%" height="100%" scaleContent="true" autoLoad="true" source="@Embed(source='../../../../assets/appl/dashboard/dashboard.swf')" />
    </mx:Canvas>
    The width and height of thr subApplication and the Main Application are set as 100%.
    when the width and height of the subApplication is set as :
    width=Capabilities.screenResolutionX;
    height = Capabilities.screenResolutionY;
    the SWF loads fully and correctly when the browser is opened 100% but when the browser is 75% open, the SWF gets loaded according to the browser.
    Thanks & Regards
    Gowrishankar R

    Setting width/height will turn off % sizing and might affect resizing as you have now fixed its width/height.
    See if the resizeHandler gets called on the Application.  You may also need height=100% on the Canvas
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • How can I found out which swf is loaded?

    I need to write an if statement for my menu to find out which
    swf is loaded into a certain level.
    On my menu, I have code that when a user clicks on a button,
    it reloads a new swf over itself into the same level. I have the
    menu in a shared library, but the code is in the menu itself.
    Probably not the best design, but I have to work with it now.
    I need some code to figure out which swf is loaded into level
    5. How can I do that? I need to be able to determine the swf and
    store it as a virable such as "calendar.swf"

    That didn't work...
    When the user clicks on the calendar (it's instance name is
    "calendar") it stores a global variable:
    calendar.onRelease = function() {
    _global.newpage = "calendar";
    _level0.myMCL.loadClip("calendar.swf", 5);
    Now, I need to send it through and if, else if, else if, etc.
    statement looking for the _global.newpage
    This is the code for the else if for the calendar:
    } else if (_global.newpage == "calendar") {
    greenbar._y = -56.4;
    greenbar._visible = true;
    _global.newpage.enabled = false;
    And, that code isn't working. Everything works except for the
    enabled = false line. What do I need to change that to so that it
    works?

  • Passing parameter to  swf being loaded

    When loading an SWF using loadMovieNum() how shall I pass a
    parameter to the
    swf being loaded?

    aa,
    > appending variables using syntax
    filename.swf?var1=something
    > resulted in an error
    > Error opening URL
    "file:///E|/filename.swf?var1=something"
    Charles said it wasn't tested, and I said it was something
    you could
    try, but like Charles, I wasn't certain that was a valid
    approach.
    > Obviously it forces it to look for a file named
    > filename.swf?var1=something
    That depends on how you're loading it. When the file is
    loaded from a
    server, you won't have that problem. I just tested the
    suggestion Charles
    and I made, and it turns out our hunces were correct -- so
    you're in luck.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • SWFs not loading in Air 4.0... for iOS

    Hi,
    I've read some of the posts about the problem of SWFs not loading in iOS.  This seemed to have to do with the SWFs having code.  We removed code from the SWFs and In previous releases, using previous SDKs (I don't remember the last one that worked) we had everything working.  But in the latest version compiled with the latest SDK (4.0...) none of the SWFs load.
    of course I'm learning about this late in the game.
    One more piece of information.  I did a test with an application that just loads one codeless SWF and have exactly the same result. 
    If anyone has any ideas, I would be very grateful.
    Best regards,
    Chris McLaughlin

    Hi,
    So code or no code external SWFs require a loader context.
    I borrowed this directly from a kglad response:
         var lc:LoaderContext=new LoaderContext(false,ApplicationDomain.currentDomain,null);
    When I add the LoaderContext to the loader (at least with my experimental app) the SWF loads.
    Also from kglad's example: yourloader.load(yourexternalswf.swf,lc);
    Thanks kglad.

Maybe you are looking for