Feeding Text content in HTML5

i am new to Haxe, when i try to convert .swf to html5, text content is missing in HTML5. how to add text content in the html5 after converting from .swf to HTML5.

What do you mean with ‘convert’?
Do you already have an openfl project working in flash and you want to also publish it in html5?
Or do you have a Flash/Animate CC swf that you want to use in a openfl/html5 project?

already i have flash(.swf) file, i want to use in a openfl/html5 project.

main.hx

package;


import openfl.display.Sprite;
import openfl.Assets;
import openfl.media.Sound;

class Main extends Sprite {
	
	
	public function new () {
		
		super ();
		
		Assets.loadLibrary ("myswf", function (_) {
            
            var clip = Assets.getMovieClip ("myswf:");
	    addChild (clip);
	});	
	}
	
	
}

project.xml

<?xml version="1.0" encoding="utf-8"?>
<meta title="SampleSWFwithsound" package="com.sample.sampleswfwithsound" version="1.0.0" company="Company Name" />
<app main="Main" path="Export" file="SampleSWFwithsound" />

<source path="Source" />

<haxelib name="openfl" />
<haxelib name="howlerjs"/>
<library path="Assets/sample.swf" id = "myswf" preload="true"/>
<assets path="Assets" rename="assets" />
```haxe your code goes here ``` when i use above code, final html5 video is not have audio and text contents in the .swf video. I heared currently it is not supporting audio. but it is removing the text content. For eg: if i have text "indtroduction" in the .swf video. final HTML video doesn't have that text contents

If you have access to the source .fla you could break apart the text elements (ctrl+b twice) so that they are vector elements. It’ll increase the file size and you won’t have a nice TextField to interact with, but if you just need the visual text it works

There’s also the “Export as Bitmap” checkbox in Adobe Animate that’s very helpful if an element isn’t coming through as expected, for some reason

I just commented on the other thread, though. Text should work in general. I can open the “NyanCat” sample and add a TextField in the FLA and re-publish the SWF, for example, and it works

i am new to this. i am unable to understand what you are trying to say. Just i am using editplus, for writting the above code. i have one sample .swf file. using the above code , i run the project with instruction “openfl test html5” in command prompt. After that it is opening in default browser, i can see .swf file video in browser , but it is missing audio and text contents. I don’t know about “NyanCat” and other details.

If anything i need to add, please let me know

Thirumani, you’re supposed to modify the flash animation before exporting it in Adobe Animate.
For future reference, I thought I’d post a link to the other thread mentioned above.


In my reply, I linked to two videos that show how to modify the flash animation.

That shouldn’t be true, some features (such as the newer, or “non-Classic” motion tweens) are not yet supported, but text is definitely supported, static, dynamic and input text. These are at least three of the projects I know are using SWF-based text in production:

http://www.openfl.org/showcase/title/pickm-stickm/
http://www.openfl.org/showcase/title/what-in-the-world/
http://www.openfl.org/showcase/title/mino-monsters-2/

My requirements is very simple, my client will give some flash file .swf , i have to play that in browser without flash player i.e., using html5. I will not do any changes in .Swf

Just to be clear: I ment that in the context of following the above advice to convert text to vectors or to a bitmap, not as a general remark of using swf in OpenFL.

Can you share an example SWF to test (perhaps privately if not publicly)? Thank you

can you give me your mail Id, i will forward my sample project

I just sent a direct message :slight_smile:

Thanks for sharing your code. When I target openfl test flash, I get only a grey screen. Perhaps this SWF has ActionScript code that stops the timeline, and follows some logic for setting the contents of the textfields later?

The following changes is showing “Hello World” for me on all targets

package;

import openfl.display.Sprite;
import openfl.display.MovieClip;
import openfl.Lib;
import openfl.media.SoundTransform;
import openfl.media.SoundChannel;
import openfl.media.Sound;
import openfl.text.TextField;
import openfl.text.TextFormat;
import openfl.text.TextFormatAlign;
import openfl.Assets;
/**
 * ...
 * @author Thirumani
 */
class Main extends Sprite 
{

	public function new() 
	{
		super();
		//this.parent.removeChildren();
		var test_frmt = new TextFormat(Assets.getFont("font/sample.ttf").fontName,null, null, null, null, null, null, null, null);
		var txt = new TextField();
		txt.defaultTextFormat = test_frmt;
		txt.text = "Hello World";
		Assets.loadLibrary ("myswf", function (_) {
			//var sound	=	Assets.getMusic("audio/streamsound 0.mp3");
			//sound.play();
			//var channel:SoundChannel = sound.play();
			//channel.soundTransform = new SoundTransform(0.50);
			var clip = Assets.getMovieClip ("myswf:");
			addChild (clip);
			addChild(txt);
		});
	}

}

(the audio did not extract from the 7z file properly, so I had to disable it for this test)

is it possible to do same using haxe programming. currently i am using openfl

When I open the SWF asset you are using directly in Flash Player (open the folder and double-click the SWF) I see only a grey screen, with no text.

In your sample project, openfl test flash also works the same way. The OpenFL “flash” target uses Adobe Flash Player, still, so if it does not work as expected there, it very likely won’t work on other platforms, since we are ultimately implementing the Flash API elsewhere. The “Main.hx” file you have is Haxe programming, ActionScript can work only for Flash, but Haxe can go to JavaScript. That is part of how OpenFL works

please share if you have any sample project with haxe and javascript