is it possible to change the playback speed of a flash object without having to recompile the flash object, i.e through the html attributes or javascript?
thanks in advance
No, but you can call a function within your SWF file from JavaScript (ExternalInterface. addCallback) that changes your animation's FPS... However, you would need to create the function in your flash file and recompile it once.
You could also create a loader SWF that has this functionality, and load your old flash movie from it.
Related
It is possible to block a link from flash object? (Link is hardcoded inside a flash object).
no, the link is managed by flash plugin.
At most you can just overlap the flash object with an element (with a transparent background) so the link is not clickable (but this is not a real solution since it can be circumvented)
You cannot do that, since Flash "lives in it's own world" in the browser. All JavaScript sees is an object, it doesn't know what's in there.
If possible, generate a new swf which embeds the current flash swf & disable its mouse events, using:
mc.mouseEnabled = false;
You can control the new swf by defining an ExternalInterface & calling from javascript, using:
document.getElementById('flash-obj').ExternalMethodInFlash();
I want a frame with a PDF document. The main document will use javascript to tell the PDF document what page to display and zoom level. Can this be done? If so, how or could you point me to documentation on it. Thanks.
You can't/shouldn't do it in a frame, but you can create an <object> on your page that is controllable using the JavaScript API.
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf
Not easily. It all depends on what's being used to display the PDF in the browser. Not all browsers have built-in PDF viewers, and then there's many different external viewers (e.g. Acrobat, Fox-It, etc...) as well. As far as I know, there's
You can try hacking up the URL like this:
http://example.com/somedocument.pdf#page=5
but this may work in Acrobat only, as documented here: http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf
Do you need a PDF reader to be loaded and running? If not, you could write a back end script/program to render a specified page as an image (GIF, PNG, etc.) at a particular zoom level. Then your main page could load an image with something like:
<img src="render_pdf?page=4&zoom=150">
The src value could be controlled with javascript to make it dynamic.
To convert from PDF to an image in your render_pdf script, you can use ghostscript, or an image specific library like ImageMagick or GD, depending on what backend technology you are using.
Have a look at jsPDF - it may not output a .pdf onscreen in IE6 and IE7 due to limitations with datauri's, but its a good start. I dont see why this couldnt be built up in an iframe either.
As Jordan pointed out, you should use the <object> tag to embed the PDF. Then, in the PDF itself, you need to embed Javascript to handle the messages you pass in, such as:
if(!this.hostContainer.messageHandler) this.hostContainer.messageHandler = new Object();
this.hostContainer.messageHandler.onMessage = handleMessage;
function handleMessage(msg) {
// do stuff here
}
Finally, in your HTML JS, you pass messages in with:
document.getElementById('yourpdfobject').postMessage('some message or array');
Is there anyway to take take a "screenshot", "save" or "capture" the active SWF element on a page as an image? I'd like for users to be able to simply click a button on my page, instead of having to need to manually take a screenshot of the entire page and then crop the image to show only the SWF element.
I found a Jquery method, although I am unsure if it could work with SWF files. It basically captures an area of an Image element on the page and allows you to save that as a separate image. What I would need however, is to capture the SWF as the image instead. Note: I do not have access to the SWF code so I cannot achieve this using Actionscript or anything like that -it has to be purely done with PHP and Javascript.
Thanks for any ideas :)
I don't think that there is a way to do this from Javascript, but if you host those swf files on your own server you could create a wrapper swf which loads the swfs you want to screenshot dynamically and then draws them into a BitmapData object.
The snapshot process inside of the swf can be triggered from Javascript via ExternalInterface, after that you can either serialize the raw pixels or use a PNG or JPEG encoder inside the wrapper swf to convert the bitmapdata to a image file and then send that data back to Javascript via ExternalInterface. Or you use the FileReference class in the swf to save the image file directly on the user's hard drive - one caveat in this is though that in order to trigger the save process the user will have to click a button inside the swf (that's a security feature).
There is one more prerequisite and that is that the swfs that you load into the wrapper have to be hosted on the same domain as the wrapper swf, otherwise the security sandboy will not allow to take a bitmap snapshot of it.
Look at ByteArray.getPixels(0,0,stage.stageWidth,stage.stageHeight) or var b;BitMap = BitMapData(stageW,stageH).draw(stage), depending on your needs. Note that the above two lines are not proper code, just the correct object and function names written in shorthand and from my head.
How can I use javascript to determine when a Flash movie has ended? ie like an SWF "MovieEnded" event
The right way would be to modify the flash movie to call a javascript function whenever it has ended. The right way to call the javascript function would be using the ExternalInterface class:
ExternalInterface.call("javascriptFunction");
However, if you don't have access to the inner workings of the flash movie, the simplest way would probably be to just poll the current frame number of the flash movie on some interval and determine whether or not it has ended. An ugly and deprecated way to get the current frame number of the flash movie would be to use the ancient, but working, TellTarget method:
document.getElementById('idOfEmbeddedFlash').TCurrentFrame('/');
I would recommend that you add some code into the final frame of the SWF which would trigger the Javascript code in your HTML page. You can use getURL to do this simply, or there are some more robust methods.
Is there any way of detecting an error when a Flash-plugin loads its content?
Basically, what I want to do is to provide some alternate content, in case something goes wrong when the Flash-plugin tries to load it's .swf file.
The .swf file is managed by a CMS type system and hence I want to create some kind of fall back default content, in case something has gone wrong, e.g the .swf file has been deleted.
I know how to detect the flash version etc. but I can't find any resources on this type of scenario.
If you are embedding with SWFObject, then I think you want to look at the result of your embedding javascript:
var so = swfobject.createSWF( ... );
Here are some details:
http://pipwerks.com/lab/swfobject/test-embed-success/index.html
Unfortunately there is no such event and you can't detect this with SWFObject either.
It is only possible if you own the SWF files.
NOTE: success is report as true if the minimum Flash player required is available and that the Flash plugin-in DOM element for the SWF was created. SWFObject cannot detect if the swf file request has actually loaded or not.
from: https://code.google.com/p/swfobject/wiki/api