Is there a way to send a jpg image as a ByteArray
from ActionScript 3 to JavaScript? Additionally, how can one convert a ByteArray
back into an image using JavaScript?
Is there a way to send a jpg image as a ByteArray
from ActionScript 3 to JavaScript? Additionally, how can one convert a ByteArray
back into an image using JavaScript?
To convert your DisplayObject
(such as a Sprite
or MovieClip
) into a BitmapData, follow these steps:
myBitmapData.draw(mySprite);
Next, use Adobe's tool called AS3CoreLib to convert the BitmapData into a PNG file:
myByteArray = PNGEncoder.encode(myBitmapData);
After that, you can convert the PNG file to Base64 format by utilizing Flex's Base64Encoder:
myBase64Encoder.encodeBytes(myByteArray);
Finally, export your actionscript variables to Javascript with the help of ExternalInterface in Flex.
Web browsers' JavaScript and DOM implementations currently lack effective mechanisms for performing this type of task.
One solution is to have your AS3 code generate a DATA protocol URI containing a base64-encoded version of the image. Most modern browsers (such as IE8+, FF2+, etc) can interpret a DATA URI as the source of an IMG tag and display the image embedded within it.
http://en.wikipedia.org/wiki/Data_URI_scheme
You may need assistance from an AS3 expert to convert a byte-array into a base64-encoded string, but this process should not be overly complex.
One solution can be found within this particular class:
Simply execute the following code snippet:
var imageData:String = DisplayObjectUtils.getBase64ImageDataString();
This will yield a result like so:
data:image/png;base64,...
Afterwards, assign this value to the src attribute of an img tag in your HTML document.
Having an issue with checkbox array This is the code snippet <?php include('config.php'); if(isset($_POST['submit'])) { for($x = 0;$x <= 5;$x++) { if(isset($_POST['check'][$x])) { ...
I'm looking to transmit a JSON string using JavaScript and later convert it into an array using a PHP encoding function. After successfully converting the string in JavaScript and transmitting it via Ajax to a PHP page, I am encountering difficulties ...
I've done some digging on SO but haven't found exactly what I need. So, here's the situation - I've got a sorting function in progress. I have an array of date ranges (PayPeriods) that I want to render into a select with option compone ...
I'm currently working on my website, which can be found at . After testing it on mobile devices, I came across an issue that I just can't seem to fix. For instance, when viewing the site on a device with 768px width, you can scroll to the righ ...
let speed = '{ "speed": 0.2 }'; <div className="section jarallax h-100vh" data-jarallax={speed} style={{backgroundImage: "url('/images/header-bg.jpg')"}} id="home"> </div> <Script src="./js/parallax.js" strate ...
Currently, I am using a JQuery plugin to style a form input with type 'file'. The plugin adds a new span over the input element to create a mask effect and encloses everything in a div. However, there is an issue where the standard HTML input box ...
I am managing a few input fields and storing their information in an object. My goal is to click on an input field to focus on it, and if the field is empty or has a length greater than or equal to 0, I want it to display a red border. If I type somethin ...
When using AngularJS to read a specific JSON value, I encountered the following issue: $http({method: 'GET', url: urlVersion}). success(function(data, status, headers, config) { console.log("success data " + status); $scope.ext = data.ve ...
Trying to incorporate both a phong material and a shader area light onto my .obj model has proven to be problematic. I attempted using an array within Meshface material to load both materials, but the model vanishes completely when both are applied simulta ...
Having some trouble with the if statement in my filter list function. Can't seem to figure out why it's not working properly. Here is the code snippet: filterList (event) { var updatedList = this.props.array; var filterText = this.stat ...
I have set up a jsfiddle that explains itself quite well: http://jsfiddle.net/nt7xzxur/ with the following smooth scrolling code: function smoothScroll(hash) { $('html, body').animate({ scrollTop: $(hash).offset().top }, 750); By clicking o ...
I am currently utilizing the Datatables jQuery plugin to manage my table rows. While it comes with a tabletools plugin that allows for a checkall function, I am wondering how I can add a custom delete button and retrieve the selected row. Fortunately, I a ...
How can I retrieve values from an array in the child component and display that data in the parent component? Initially, I was only displaying data from the array when the 'save' button was clicked. Now, I need to display the array by default. ...
I am currently working on traversing through the object above in order to determine if a contact is a member of a specific list. For instance, if the user is a member of the list with an ID of 2022, I want to display their first name (which is also includ ...
Even though the inline onmouseover="verdadero()" function is properly set up Upon further inspection, it appears that while the event listener is added to the box element, the function is not being triggered when hovering over it, and console.lo ...
Currently, I have implemented a double click function that allows the user to double click on a car model, displaying which objects have been intersected such as wipers, grille, and tires. These intersections are listed along with the number of items the d ...
When incorporating user input for phone numbers, I have opted to utilize a package titled material-ui-phone-number. However, the challenge arises when attempting to retrieve the country code to verify if the user has included a 0 after the code. This infor ...
I am currently developing a basic counter app to monitor my progress in a digital card game that I enjoy playing. While attempting to pass props from the parent component to the child component, I encountered an issue where the props were not being success ...
I am looking to implement a way to download a text file (e.g. 'something.txt') using an AJAX call rather than just an anchor tag in HTML. Here is the HTML code: <body> <a href="#" id="exportViewRule">Export</a> </body&g ...
In my ThreeJS project, I have planes (Object3D) flying inside a sphere (Mesh). My goal is to detect when a plane collides with the border of the sphere so that I can remove it and respawn it in a different location within the sphere. I am wondering how I ...