Tag Archives: flash

Flash doesn’t load in div with display:none style

Where’s the problem?

As it appears if you have flash embed / object tags in a div which is initaly hidden (style=”display:none”) cannot be loaded. It means the .swf file is loaded via HTTP but when the div become visible then starts the loading process and the flash starts from the begining.

Is there a workaround?

I’m looking for a workaround which I’ll share as soon as I find it. If you have a solution please share it with us.

Flex 3 import swf symbols

If you’d like to embed a .swf file into your Flex 3 application you’ll probably get into several little problems. The simple task of embedding is clear and well documented in the web. Let’s assume we’ve to MovieClip symbols into a single .swf file. What we like to do is to access this two separate symbols within the Flex applications as MovieClip.

make a movie clip in your flash
Make a new MovieClip symbol in your Flash

Make the .swf sample file with both symbols inside. In general it’s not that hard, just put this into your Flex application code:

[Embed(source="embed.swf", symbol="blue")]
private var blue:Class;

[Embed(source=”embed.swf, symbol=”red”)]
private var red:Class

Note that you’ve embed.swf file, which has to be in the same folder as the main .swf of the Flex app, and two symbols named red and blue for the sample. Be very careful when exporting the symbols from the .swf file. Do not forget to export them for actionscript.

Don't forget to export the .swf MovieClip for actionscript
Don't forget to export the .swf MovieClip for actionscript

If not exported like that, you’ll have trouble accessing them from the Flex app, and that’s the first problem you can have here.

Set the name of the MovieClip exactly as you wish to appear in your Flex application
Set the name of the MovieClip exactly as you wish to appear in your Flex application

The rest you have to do is to add this two lines of code in Flex:

var mc:MovieClip = new blue();
this.addChild(mc);

Note that the last line can have something else than ‘this’ if there’s other element to become parent of the imported MovieClip symbol. Here comes the first major problem. As www.airtightinteractive.com describes this technique does not work every time:

Sometimes when you do this you will get the following error:

TypeError: Error #1034: Type Coercion failed: cannot convert app_red@12510d1 to flash.display.MovieClip.

And the author shares his solution which is to add at least 2 keyframes for both movie clips, so that they can be visible as movie clips, if not they will remain visible only as Sprites.

I’m not as conviced this is the right answer of the question and the right solution. I’ve experimented with 1 or 2 keyframes and still have the same problem in Flex even if i cast the symbols as Sprite, not MovieClip:

var mc:MovieClip = new blue();
var mc:Sprite = new blue();

The solution from Adobes for me is not suficient, cause the movie clips we import (embed) does not serve as images but more like movie clips, which was the task from the beggining. And that’s what Adobe says:

Flex fully supports embedding Flash SWF files. You can embed different types of SWF files.

To reference a symbol, you specify the symbol parameter:
[Embed(source=’SWFFileName.swf’, symbol=’symbolName’)]

And again read carefully the note in the Adobe’s site:

Note: Flash defines three types of
symbols: Button, MovieClip, and Graphic. You can embed Button and
MovieClip symbols in a Flex application, but you cannot embed a Graphic symbol because it cannot be exported for ActionScript.

Here you can be sure that lack of exported for actionscript symbol is not accessible in Flex.

One of the main solutions is to embed the .swf as octet-stream:

[Embed(source="embed.swf", mimeType="application/octet-stream")]
private var blue:Class;

followed by:

var loader:Loader = new Loader()
loader.loadBytes(new blue());

And the key point of this will be the lines:

var red:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("blue");
var mc:MovieClip = new red() as MovieClip;

I hope this can help

Flex 3 Custom DateChooser

I searched so much about a custom DateChooser component in Flex 3, that I decided to make one by myself. My criteria is to have ComboBoxes for both months and years. I simply merged the ComboBox component with DateChooser and there is the beta release. Please fill free to comment and report any bugs or feature requests.

Demo is here:

Free download: here

Html object & embed tags

Maybe almost 90 % of the web developers world wide are using widely the <embed> and <object> HTML tags, but in the most cases do not understand the semantics and syntax of them.

Very well known is that these tags help to put a flash movie into the HTML, but why they are two, and can they be used in other cases remains unanswered.

These tags, in general, are really most used to put flash movie into the web site, and as anyone can guess they are two cause of the differences in the web, specially between the web browsers. The <object> tag helps for the browser who use ActiveX controls to display properly the flash movie. In fact the newest Internet Explorer browsers like 7 version and 8 beta, display the movie correctly even without the <object> tag, but not always those flash movies work in the expected manner. Somethimes there are problems with autoplay or something like that. Especially this can be problematic when using some kind of .flv player. In that case (depending from the player) the movie initialize but the required .flv does not load and play. This was the problem I wrote for in my previous post about Opera and JW FLV Player.

As you may guess the <object> tag can handle much more the flash movie, but as many other entities as there are ActiveX controls.

To be more exact the <object> tag is for Internet Explorer, while the <embed> tag is for Netscape and related to it browsers using Netscape plugin to display a flash movie. More detailed information can be found on Adobe site:

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_4150

All the specification can be found online but more important is to mention the semantics of some of the attributes.

For both of the tags valid attributes are width and height. They can be either pixels or percentage, which are relative from the element containing the object/embed pair, i.e. if the flash is in a div with fixed width of 800px and the object/embed pair is 100% width the movie will became 800px wide.

Notice: some browsers do not calculate the height correctly when the height is set in percentage.

For the <object> tag only there should be classid, codebase, movie attributes, while for the <embed> tag only is src and pluginspage.

see which attributes are mandatory and which one are not at: object and embed tags revealed