0

am new in flash

here am using a javascript function for views a flash video

the flash files name are a0.swf,a1.swf ...

this is my javascript function

<script>
var count=0;
function mafunct(newSrc){
    alert("hi");
var path="a"+count+".swf";  

 flash+='<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" WIDTH="100%" HEIGHT="100%">';          
    flash+='<PARAM NAME=movie VALUE="'+path+'">';          
    flash+='<PARAM NAME="PLAY" VALUE="false">';  
    flash+='<PARAM NAME="LOOP" VALUE="false">';
    flash+='<PARAM NAME="QUALITY" VALUE="high">';
    flash+='<PARAM NAME="SCALE" VALUE="SHOWALL">';
    flash+='<EMBED NAME="testmovie" SRC="Menu.swf" WIDTH="100%" HEIGHT="100%"PLAY="false" LOOP="false" QUALITY="high" SCALE="SHOWALL"swLiveConnect="true"PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">';
    flash+='</EMBED>';
    flash+='</OBJECT>';     

count++;
alert(path+"aa");
}
</script>

<button onclick="mafunct()">next</button>

when this button click nothing will happen

Is here any problem with coding...

if you have the same isuue happened before and solve it or you know the answer for this please mention below

with regards ..Prasanth AR

Update my Question here..

<script>
var count=0;
function mafunct(flash){
var path="a"+count+".swf";  

    flash+='<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" WIDTH="100%" HEIGHT="100%">';          
    alert(path);
    flash+='<PARAM NAME=movie VALUE='+path+' >';          
    flash+='<PARAM NAME="PLAY" VALUE="false">';  
    flash+='<PARAM NAME="LOOP" VALUE="false">';
    flash+='<PARAM NAME="QUALITY" VALUE="high">';
    flash+='<PARAM NAME="SCALE" VALUE="SHOWALL">';
    flash+='<EMBED NAME="testmovie" SRC="Menu.swf" WIDTH="100%" HEIGHT="100%"PLAY="false" LOOP="false" QUALITY="high" SCALE="SHOWALL"swLiveConnect="true"PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">';
    flash+='</EMBED>';
    flash+='</OBJECT>';     
    alert(flash);
count++;

}
</script>

<button onclick="mafunct()">next</button>

and here the alerts are work but the flash id not viewed...

22
  • 2
    Is it just a typo in your question that you try to add to flash before declaring it? Line 3 of mafunct Commented Jun 12, 2013 at 11:03
  • 1
    In the line below var path="a"+count+".swf" you have flash += '<OBJECT CLASSID...', before the variable flash exists. In the next line, var flash = ... is when you actually declare flash. And since you're assigning it to the same string in those two lines, do you actually need the line flash += '<OBJECT CLASSID...'? Commented Jun 12, 2013 at 11:08
  • 1
    Are you getting the alerts? Or is the video just not showing? Commented Jun 12, 2013 at 11:12
  • 1
    You want to keep the line that started with var flash = <OBJECT CLASSID..., not the one that started flash += <OBJECT CLASSID... Commented Jun 12, 2013 at 11:13
  • 1
    use value="file://"+path Commented Jun 12, 2013 at 11:15

1 Answer 1

2

Using what I found in this question, I think this should help.

var path = var path = document.location.href;
path = path.substr(0, path.lastIndexOf('/') + 1);
var count = 0;
function isIE() {
    return navigator.userAgent.lastIndexOf('Trident') > 0;
}

function mafunct(newSrc) {
    var version = '6,0,29,0';

    var name = document.createElement('param');
    name.setAttribute('name', 'movie');
    name.setAttribute('value', path + 'a' + count + '.swf');

    if (!isIE()) {
        var inner = document.createElement('object');
        inner.setAttribute('type', 'application/x-shockwave-flash');
        inner.setAttribute('data', path + 'a' + count + '.swf');
        inner.setAttribute('width', '100%');
        inner.setAttribute('height', '100%');
    }

    var flash = document.createElement('object');
    flash.setAttribute('id', 'flashMovie');
    flash.setAttribute('classid', 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');
    flash.setAttribute('width', '100%');
    flash.setAttribute('height', '100%');
    flash.appendChild(name);
    if (!isIE()) {
        flash.appendChild(inner);
    }

    if (document.getElementById('flashMovie')) {
        var movieObject = document.getElementById('flashMovie');
        movieObject.parentNode.replaceChild(flash, movieObject);
    } else {
        var div = document.createElement('div');
        div.setAttribute('id', 'multimedia');
        div.appendChild(flash);
        document.appendChild(div);
    }
    count++;
 }

EDIT: Changed the code from always adding a new flash object to replacing the existing one if there is one.

Sign up to request clarification or add additional context in comments.

2 Comments

I did'nt mean this i just update my question please review it
@PrasanthAR Please see my edit at the bottom of the code. I changed it to add the flash object if there isn't one already, and if there is, it replaces the old one with the new one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.