SWF object params - scale or scaleMode - object

In my job I'm embedding SWF files into HTML documents all the time. I often asked myself a few things:
Is it scaleMode="noscale" or scale="noscale"? And are the values case-sensitive? I saw a few code snippets like scale="noScale" etc.
How is the syntax in ActionScript? Is it the Camelcase noScale? I don't care about the HTML standards I'd just like to know how it is from the Flash developers perspective.
Anyone has a clue? I checked Google a lot of times but I have never found something like a conformance description. I just found the Adobe page that describes the parameters and values but that does not answer any of my questions.
Thanks a lot! :)

Found answer in Google in 3 seconds:
scale - Possible values: showall, noborder, exactfit, noscale.
Specifies how Flash Player scales SWF content to fit the pixel area
specified by the OBJECT or EMBED tag. default (Show all) makes the
entire SWF file visible in the specified area without distortion,
while maintaining the original aspect ratio of the movie. Borders can
appear on two sides of the movie. noborder scales the SWF file to fill
the specified area, while maintaining the original aspect ratio of the
file. Flash Player can crop the content, but no distortion occurs.
exactfit makes the entire SWF file visible in the specified area
without trying to preserve the original aspect ratio. Distortion can
occur. noscale prevents the SWF file from scaling to fit the area of
the OBJECT or EMBED tag. Cropping can occur.
More info here
Edit: I think case-sensitivity depends on the browser, but following xhtml standards you should always use lowercase.
Edit2: scaleMode on the other hand is a property of Stage object in ActionScript, so it is used to set scale mode in SWF movie, that is not embeded. When you embed the swf, that param is overriden with what you've set up in your HTML.

If you're setting your scale mode via ActionScript, you use the scaleMode property of the Stage object. If you're setting it via JavaScript or HTML markup, you use scale in a <param> node.
Regarding capitalization, Adobe's documentation for scaleMode (ActionScript) has used camel case consistently for as long as I can remember (at least the last 6 years). The current AS3 docs clearly use camel case. The article linked above is referring to scale in JavaScript/HTML, not ActionScript. It seems that camel case across-the-board is the safest route, you can be sure it will be supported.
Here are some scale examples using using SWFObject:
SWFObject dynamic:
var flashvars = {};
var params = { scale: "noScale" };
var attributes = {};
swfobject.embedSWF("/swf/sample.swf", "flash", "100%", "100%", "9", false, flashvars, params, attributes);
SWFObject static:
<object id="flash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%">
<param name="movie" value="/swf/sample.swf" />
<param name="scale" value="noScale" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="/swf/sample.swf" width="100%" height="100%">
<param name="scale" value="noScale" />
<!--<![endif]-->
<p>Place fallback content here for users who don't have Flash<p>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
Examples and a description of the scale options:
http://learnswfobject.com/advanced-topics/100-width-and-height-in-browser/

Related

How to reference SVGs in html with access to css styling

I have a number of different SVGs to include in my project (Angular 10).
Some of them are used multiple times with different sizes and fill colors etc.
I am trying to find a way to reference them in my html code and have access to via styling:
CSS:
.svg {
fill: red;
}
Referencing:
<svg>
<use></use>
</svg>
<object></object>
<img></img>
<embed></embed>
As yet, I have not been able to find a solution that allows me to reference them but also have the ability to access the fill property in the SVG itself as i can when adding inline.
Inline:
<svg>
<path>
</path>
</svg>
Adding them inline is going to be messy.
How is this usually handled?
Your help is appreciated!
You can't. CSS does not apply across document boundaries. If the CSS rules are in the HTML (or imported into the HTML via <link>) then it cannot affect the content of external files.
One solution people have used in the past is to use a bit of Javascript to inline SVG files at runtime.
Otherwise, you will need to put the CSS in the external SVG itself.

Embedding 'Open Sans' font in svg - gstatic urls

I need to embed the 'Open Sans' font in an svg. I found a method that works but in order to use it with Google fonts, I plucked out the src listed in http://fonts.googleapis.com/css?family=Open+Sans:
<defs>
<style type='text/css'>
<![CDATA[#font-face{font-family:'Open Sans';src:local('Open Sans'), local('OpenSans'), url(http://fonts.gstatic.com/s/opensans/v9/cJZKeOuBrn4kERxqtaUH3ZBw1xU1rKptJj_0jans920.woff2) format('woff2'), url(http://fonts.gstatic.com/s/opensans/v9/cJZKeOuBrn4kERxqtaUH3bO3LdcAZYWl9Si6vvxL-qU.woff) format('woff');}]]>
</style>
</defs>
Should I be worried about the gstatic links moving over time, or are they truly "static"?
My concern is that http://fonts.googleapis.com/css?family=Open+Sans is static, but the links it resolves may actually expire and move.
Any other issues with this solution I should be aware of?
The other issue I encountered was the font owner may revise their font glyphs and woff files are updated silently (WITHOUT my knowledge). Hence all the nicely designed webpages may end up looking like it was haphazardly slapped together.
An easy solution is to host these fonts on your site or perhaps Amazon S3; I'd ignore the "truly static" claims because sites can be unreachable for a variety of reasons and it is out of your control.
Sidenote: *Open Sans" is designed by Steve Matteson, along with a few others like Liberation fonts, which is worth checking out.

Change multiple colors of a SVG object

I have a SVG logo rendered to the canvas using fabric.js, the original SVG is all black in color but I need the user to be able to change the color of each different parts of the logo, resulting in a object with multiple colors, e.g.:
wikimediauruguay.org/images/5/53/Wikimedia-logo.png
How can I achieve this? If I just use object.setFill() it changes the color of the entire object but I need to change the color of every part separately to whatever colors the user choose. Thanks.
EDIT: found the solution, just posted my answer below in case somebody else has the same question.
Perhaps someone who knows something about fabric.js would answer in a way that makes more sense for your case, but with plain old svg, an object is often a <g< element with things ( like <rect>, <path>, <ellipse>) inside. Each child of the group, can have its own event handler:
<g>
<path onclick='handle(evt)' attrs=stuff />
<rect onclick='handle(evt)' attrs=stuff />
<circle onclick='handle(evt)' attrs=stuff />
</g>
The function activated by the click can then interrogate evt.target to see which of the subelements received the click, sorta like this:
if (evt.target.nodeName=="path") {evt.target.setAttribute("fill","purple")}
Solved mi problem in a very simple way: I just needed to edit the SVG on Illustrator so that every different colored part of the logo will be on a different layer, then when I loaded the SVG via fabric.loadSVGFromURL() each layer will be treated as a different object by fabric.js, then I just could edit each object (layer) separately (setFill(), etc).

Does openlaszlo has a feature like data uri?

i want to know wheter open laszlo has data uri feature. The following example will show a red dot where the red dot is an image and base64 data is passed to it. Is it possible to do something like this?
example is given below
<div>
<p>Taken from wikpedia</p>
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />
</div>
You are referring to Data URLs as specified in RFC 2397. That feature not supported in OpenLaszlo, and it only would be relevant for DHTML applications anyway. For the SWF runtime, images can be compiled into a SWF file as static resources, increasing the file size and reducing the number of requests needed to send to the server.
There are size limitations for inline images as well. Browsers are only required to support URLs up to 1,024 bytes in length, according to the above RFC. Browsers are more liberal in what they'll accept, however. Opera limits data URLs to about 4,100 characters. Firefox supports data URLs up to 100K, which means you should only use the technique for small to medium size images.
Even though Data URLs are not supported in OpenLaszlo, a similar - and in my eyes - more powerful option is available. The automatic generation of a CSS sprites for images you add as static resources. When you select the 'Use master sprite' compile option, the OpenLaszlo compiler will create one PNG sprite map containing all those static resources.
Here is an example of the master sprite PNG for the OpenLaszlo weather widget. Instead of making multiple requests to download the individual images, the browser just has to make one request.

scale videos in p:media tag

how to scale the video in the media tag?
<p:media value="#{mediaBean.media}" width="250" height="225" player="quicktime"/>
the resolution is bigger thant 250x225 - so I just see parts of the videoscreen - why it's not automatically scaling the video to 250x225 ? any ideas?
regards
You have to send scale attribute as parameter (f:param) to the player.
<p:media value="#{mediaBean.media}" width="250" height="241" player="quicktime"/>
<f:param name="scale" value="tofit" />
</p:media>
Each player specifies what parameters they support.
In your case quicktime supports scale attribute:
scale
SCALE is either TOFIT, ASPECT or a number. By default the value of
SCALE is 1. If set to TOFIT, the movie is scaled to fit the embedded
box as specified by the HEIGHT and WIDTH attributes. If this is set to
ASPECT, the movie will scale to fit the embedded box while maintaining
the aspect ratio. If this is set with a number, the movie will be
scaled by that number (e.g. 1.5). Note: Using the number scale
attribute with a QTVR Panorama movie can degrade the performance of
the movie even on high-end systems.
Useful links here:
Quicktime
Flash
Windows Media Player

Resources