Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

'FileReference' is undefined + HTML5canvas

Engaged ,
Apr 12, 2021 Apr 12, 2021

2021-04-12_18-08-13.jpgexpand image

 

2021-04-12_18-09-02.jpgexpand image

 

var root = this;
var file1 = new FileReference;
var fileLoader1 = new Loader;


function start1(evt) {
	loadImageBtn1.addEventListener("click", showDialog1.bind(this));
}
start1();

function showDialog1(evt) {
	this.file1 = new FileReference;
	var imageFileTypes1 = new FileFilter("Images (*.jpg, *.png, *.gif)", "*.jpg;*.png;*.gif");
	this.file1.browse([imageFileTypes1]);
	file1.addEventListener("select", selectFile1);
}
function selectFile1(evt) {
	file1.addEventListener("complete", loadFile1);
	file1.load();
}
function loadFile1(evt) {

	this.fileLoader1.loadBytes("file1");
	displayImage1();
}
function displayImage1(evt) {
	fileLoader1.height = 156;
	fileLoader1.width = 156;
	fileLoader1.x = 360.25;
	fileLoader1.y = 245.9;
	this.addChild(fileLoader1);
}
TOPICS
Code , Error , How to , Import and export , Missing feature , Other , Performance , Timeline
568
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 12, 2021 Apr 12, 2021

Yes, ActionScript 3 code isn't going to work in Canvas documents.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 12, 2021 Apr 12, 2021

@ClayUUID But I turned it to html5canvas

https://helpx.adobe.com/ca/animate/kb/as-to-html5.html

Since you are an expert, how do you implement it?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 13, 2021 Apr 13, 2021

No, you did not turn it into Canvas code. There's no such things as FileReference or FileFilter in Canvas documents. Those are AS3 APIs.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 18, 2021 Apr 18, 2021

@ClayUUID 

Is there a list of commands that it does not support ?

What are the commands that help me with this code ?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2021 Apr 18, 2021

AS3 APIs supported in Canvas documents: None of them.

Javascript APIs supported in Canvas documents: All of them.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 18, 2021 Apr 18, 2021
LATEST

 

this.upload_button.addEventListener("click", fl_MouseClickHandler_3.bind(this));

function fl_MouseClickHandler_3() {
var reader = new FileReader();
reader.onload = function (event) {
var dataUri = event.target.result,
context = document.getElementById("mycanvas").getContext("2d"),
img = new Image();

img.onload = function () {
context.drawImage(img, 100, 100);
};
img.src=dataUri;
reader.readAsDataURL('file');
}
}

//////////////

Still not working?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2021 Apr 13, 2021

an important question?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines