Not signed in (Sign In)

Vanilla 1.0.3 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthormanesh
    • CommentTimeJul 18th 2007
     
    Hello evryone,
    I am using SWFObjct for showing a flash on html page. Actually my requirement is, i have a "browse" button on my page using which i will select some ".swf" file on my local machine, and on select of that file, the flash should be displayed on page and the action should take place on Client side. following is the code am using. when i run this code on my local machine as a stand-alone html page, it works fine. but when i use client-server application, it does not work. actually the object loads all parameters except movie param. on page i can see a blank box of given size and when i right click on the box i get this "movie not loaded".
    I am using Tomcat as my application server. i tried to use various methods of flashobject(u can see in the code), but were not really usuful.


    Can somebody please help me to sort out the prb?????



    <HEAD>
    <script type="text/javascript" src="swfobject.js"></script>
    <script language="javascript">
    <!--

    function setImg(path)
    { var type= ".swf";
    var isSwf = path.search(type);
    var path1 = path.replace(/\\/g, "/");
    var path2 = path1.replace(/\ /g, "%20");
    alert(path2);
    if(isSwf > -1) {

    var so = new SWFObject(path2, "flashPreview", "640", "450", "6","#FF000F");
    so.addParam("quality", "high");
    so.addParam("wmode", "transparent");
    so.write("flashContent");

    var movie = window.document.flashPreview;
    alert(movie.PercentLoaded());
    if (movie.PercentLoaded() == 100) { alert("Movie Loaded"); }
    movie.Play();
    if (movie.IsPlaying()) { alert("movie is playing"); }

    }

    }
    //-->
    </script>
    </HEAD>

    <BODY>

    <form name="form1">
    <input type="file" id="file" onChange="javascript:setImgthis.value)" size="30"/>

    <p id="flashcontent">
    Flash Preview
    </p>

    </form>

    </BODY>
    </HTML>
    • CommentAuthorAran
    • CommentTimeJul 18th 2007
     
    When you alert path2 does it give you the expected path location? If you were to copy an paste that location (I am assuming it is a relative path) from your curernt context (say your page is at http://some.com/flashform/index.jsp), does the file actually resolve?

    As an example:
    path2 alerts to "uploads/file1.swf"

    If you then go to http://some.com/flashform/uploads/file1.swf can you catually view the file there?

    If you can do that:

    then if you set path2 to an absoute link to the flash file, then swfobject HAS to load the file from the right place...


    In regards to your other code:

    var movie = window.document.flashPreview;
    alert(movie.PercentLoaded());
    if (movie.PercentLoaded() == 100) { alert("Movie Loaded"); }
    movie.Play();
    if (movie.IsPlaying()) { alert("movie is playing"); }

    Do you need to do this? Flash should play itself when it is loaded anyhow.

    The above method of scripting flash is outdated too, and not all methods are cross browser compatible. If you need to do flash<>browser communication, then check out this post: http://blog.deconcept.com/swfobject/forum/discussion/499/flash-to-browser-communication-with-swfobject/#Item_1
    • CommentAuthormanesh
    • CommentTimeJul 18th 2007
     
    Thanks for the reply aran.

    Actually the file i want to upload is on my local machine located at C:/myFlash.swf, so when i alert for the path2, i actually get the correct path as "C:/myFlash.swf" . but when put it swfobject tag, it doesnt work.

    about the other code, yes ur right, its not of any use. i had added that code just to see if i get clue by using some already available methods of flashObject.

    I will go through the link u given but if u could help on this issue would be really greatful cause its kinda urgent. Thanks in adavance :)
    • CommentAuthorAran
    • CommentTimeJul 18th 2007
     
    Manesh.

    But once you upload it, it should be somewhere on your Tomcat server.

    If you are not actually loading it into a web accessable location (e.g. http://localhost/some/folder/file1.swf), then you will have issues, as all file references need to be either an absolute URL, or a realative path from where your HTML page is located.
    • CommentAuthormanesh
    • CommentTimeJul 18th 2007 edited
     
    Hi Aran,
    Actually the prb is this functionality is taking place on client side, no server call exist here. basically the requirement is i want to see preview of the flash before i upload it on the server. The thing is when i upload it on server and then view it works fine but thats not what i want. i want to preview it before i upload it on the server.

    The funny thing is when i do the same for previewing images, it works fine. i am using following code for it.it completely works on client side and For the swf files, it isnt working n i dont get why?? could it be issue of browser, i am using IE 7


    <HEAD>
    <script language="javascript">
    <!--

    function setImg(path,targetImage)
    {
    document.images[targetImage].src=path;
    }
    //-->
    </script>
    </HEAD>

    <BODY>

    <form name="form1">
    <img src="$viewhelper.getAbsoluteLink("/pics/RenaultSITe/cars/global/clear.gif")" name ="distimg_PT" border="1" vspace="4" hspace="4" />

    <input type="file" id="file" onChange="javascript:setImg(this.value,distimg_PT)" size="30"/>


    </form>

    </BODY>
    • CommentAuthorphilip
    • CommentTimeJul 18th 2007 edited
     
    i'm not sure if you're using site-relative links, but for what it's worth:

    site-relative links ( /foldername/filename.xxx ) don't work when previewing your page locally. file-relative links ( ../foldername/filename.xxx ) work locally, and absolute links ( http://yourserver.com/foldername/filename.xxx ) work locally if you have an internet connection.

    so if you have a forward-slash (/) without two periods preceding the forward-slash (../), it's a site-relative link and shouldn't work locally... unless you're running a server on your local machine!

    - philip
    • CommentAuthormanesh
    • CommentTimeJul 18th 2007
     
    Hi Philip,
    I already tried with file-relative links, but actually dint serve my purpose.
    • CommentAuthorzhangsisi
    • CommentTimeOct 1st 2007
     
    the find best www.ConnectAsia.info/en/lang104082about_sisi11 welcome you