AS3 replace string/text with image characters - actionscript-3

i am developing the code for a simple game in AS3 and i have all the graphic assets made by a designer.
He wants all the textual messages (i.e. win, lose, lives, etc.) to be done exactly as in the original photoshop drawing, they have lots of visual fx on them.
Since these messages inside the game are dynamic, I tried to use normal textfields and replicate the visual fx with Flash filters, but the result is not even comparable.
I think i could try to export from photoshop a spritesheet with the all the image characters, or the single image characters one by one, and replace my old textfields with sprites/movieclips in which i would load the specific image characters based on the string i need to show to the enduser, but i don't know precisely how to do it.
Does anyone have some hints on how to achieve this result? Better to use a separate class and image library? I googled online hoping to find some class or method alike to customize a little for my needs, but unfortunately i haven't found anything!

You could add all the graphics to the library exporting them with each name.
Than call them when needed creating a MC. If useful, you could store the names in an array and use it to simplify your script (it depends on usage)

Ok, after some more research, i found out my main problem in not finding answers to my problem was the terms of research i was using.
I was erroneously looking for "AS3 string replace with images" or "text replace with images in Flash", while the correct question was: "how to use a BITMAP FONT in AS3".
I was sure someone else had to do what i'm trying to do (like in old games where texts were all image sprites) but i didn't know how to find it!
So, this is the solution i found, i still have to refine the workflow but it's a good starting point:
Create a custom Bitmamp font using the SHOEBOX tool in conjunction with photoshop, where you will be able to apply all the raster fx you want (here's the tutorial: http://renderhjs.net/shoebox/bitmapFont.htm)
You will obtain a .fnt file (descriptor) and a .png image (font characters atlas)
You will need to flip the png image vertically: apparently, a lot of bitmap text engines work with flipped characters, and i found this one to be working like this as well
Once you have these files, use the BMFontRenderer AS3 class to embed your bitmap font into an AS3 project of your choice (tutorial here: http://blog.bengarney.com/2011/12/07/fast-bitmap-fonts-in-flash/)
I hope it will be useful for others who may need to replace standard text in Flash with font images.

Related

Is there any work around for Sikuli IDE image replacement?

I am using Sikulix for UI testing, the problem is that when ever there are changes in UI I need to replace all the images which got changed using the IDE and I need to again describe the actions ( accuracy, click position) which is becoming a sort of overhead in my case. Is there any work around by which I can simply replace the new UI images in the project folder with the same old name ( It wont work directly as the new coordinates might be different + the new image should be of same resolution that of older one)
PS: I have completely understood that sikuli works at pixel level, but still curious to find out if any one has found a work around.
Unfortunately, you will need to recreate the images. What could make it a bit easier, is if you had more descriptive names than the ones generated by Sikuli IDE automatically. Keep in mind these are just image files stored on your PC. If you have names like button1.png, button1.png, etc.., it will make your life easier.
This may or may not work for you depending on your project development:
In my case, the changes that occur at times reduces the image similarity from say 0.9 defined to ~0.7. Now, rather than going ahead to replace the image with a totally new image where i would have to manipulate the offsets as well now, I capture the same region image at 0.7 similarity and replace it. You can easily create a script for this and even integrate it into your project. Use find to figure out the matching region and capture to take the screenshot of the area. The image caught using this way will now again match at 100% for you also, you have rid yourself from the headache of adjusting the targetoffset. Hope this helps.

coloring multiple frames in Flash Professional CC

I'm brand new to Flash Professional and wanted to make a short 10 second clip. Instead of looking into using tweens and symbols (I wish I did) I used Flash Professional as a flip book, illustrating sketches for each keyframe.
I'm now in the colouring process and want to know if there is a way to colour an object (I've drawn with the brush tool) throughout multiple frames. is this even possible?
I understand there are some short cuts to repetitive tasks using ActionScript. But, once again I am brand new to Flash Professional and haven't tried anything in the ActionScript. I do however have a very basic knowledge of HTML coding and some javaScript if it helps at all…
If there is an alternate solution like exporting the file to another Adobe program that has a "colouring multiple frames" feature, that would be great too.
Sorry to say, to do that, you WILL have to work with symbols. However, this is an easy fix.
Select the object you want to color, click Modify--> Convert to Symbol. Give it a good name, and set it to MovieClip. Click OK.
Now, in the Library panel, double-click the icon next to your symbol name. Color as you wish.
There are multiple ways to put this on your timeline. You could replace each instance of that drawing with the symbol. Or, better, you could create a new layer with only one keyframe (and regular frames after that to the end of your animation. Place your object on that layer, and then remove all the old versions of that drawing.
NOTE: You will need to be mindful of where in the stack you put layers, as that sets the z-index of everything on that layer.

Drawing shapes versus rendering images?

I am using Pygame 1.9.2a with Python 2.7 for designing an experiment and have been so far using Pygame only on a need basis and am not familiar with all Pygame classes or concepts (Sprites, for instance, I have no idea about).
I am required to draw many (45 - 50 at one time) shapes on the screen at different locations to create a crowded display. The shapes vary from displaced Ts , displaced Ls to line intersections. [ Like _| or † or ‡ etc.]! I'm sorry that I am not able to post an image of this because I apparently do not have a reputation of 10, which is necessary to post images.
I also need these shapes in 8 different orientations. I was initially contemplating generating point lists and using these to draw lines. But, for a single shape, I will need four points and I need 50 of these shapes. Again, I'm not sure how to rotate these once drawn. Can I use the Pygame Transform or something? I think they can be used, say on Rects. Or will I have to generate points for the different orientations too, so that when drawn, they come out looking rotated, that is, in the desired orientation?
The alternative I was thinking of was to generate images for the shapes in GIMP or some software like that. But, for any screen, I will have to load around 50 images. Will I have to use Pygame Image and make 50 calls for something like this? Or is there an easier way to handle multiple images?
Also, which method would be a bigger hit to performance? Since, it is an experiment, I am worried about timing precision too. I don't know if there is a different way to generate shapes in Pygame. Please help me decide which of these two (or a different method) is better to use for my purposes.
Thank you!
It is easer to use pygame.draw.rect() or pygame.draw.polygon() (because you don't need to know how to use GIMP or InkScape :) ) but you have to draw it on another pygame.Surface() (to get bitmap) and than you can rotate it, add alpha (to make transparet) and than you can put it on screen.
You can create function to generate images (using Surface()) with all shapes in different orientations at program start. If you will need better looking images you can change function to load images created in GIMP.
Try every method on your own - this is the best method to check which one is good for you.
By the way: you can save generated images pygame.image.save() and then load it. You can have all elements on one image and use part of image Surface.get_clip()

How was this HTML5 screencast animation created?

I visited http://www.sublimetext.com today and was intrigued by the screencast animation the website has on its opening page. It looks like a mashup between video and slideshow. I've seen them at other modern websites as well, but I assumed it was some HTML5 video tag trickery. But when I looked at the source of sublimetext webpage, I was confused.
The animation on this page is created on a HTML5 2D canvas with plain javascript using base PNG images. Each slide is loaded from a PNG file. The animation is achieved by modifying only handful of pixels from the image. The animation javascript applied these changes on the original PNGs at regular intervals. You will find these deltas stored in *_timeline variables in the script.
My question is what tool can generate such deltas? How can one record one's desktop screen and create such base PNG + animation deltas?
I like this approach because it seems most efficient format for screencasts, where changes in consecutive frames are minimal.
Update 1 I know there are techniques to achieve this using GIF (Check https://askubuntu.com/q/107726), but what cool tool can generate this javascript code that can convert PNG deltas to animation. Googling hasn't helped me find it out.
Update 2 The author of the screencast (and sublimetext) replied to my question on sublimetext forum. He did it using a custom python script and plans to write a blog post about it sometime http://www.sublimetext.com/forum/viewtopic.php?p=34252#p34252
Jon Skinner, the creator of Sublime Text wrote about the process on his website
He also published the encoder he wrote on GitHub
look at one of their images and you'll understand how it works:
http://www.sublimetext.com/anim/command_palette_packed.png
they just cutting and inserting appropriate portions of image into the appropriate positions of canvas element, but if your question is how to make such image, I don't have an idea.
I guess with some software, not by hand, but I don't know such soft...

Image manipulation in ActionScript 3.0 : realistically editing faces

I am a flash developer who has worked mostly on small ActionScript projects, in particular websites, but I am dipping my toes into image manipulation with AS3. I have a project I'm working on to develop an application which would allow a user to upload their own picture into a swf, and then, using a slider, they can alter the image to make themselves look thinner or fatter. The condition is that it should require minimal user input - so ideally the most I could expect from the user would be a couple of control points identifying certain areas of the face in response to prompts e.g. 'click on the centre of the chin' and when the user clicks, the position would be stored, but this would need to be used sparingly, if at all.
So far, I have been able to use the FileReference class to handle the upload, and I am experimenting with using the DisplacementMap filter to edit certain parts of the uploaded image, but I am having serious trouble implementing this in a manner that would allow realistic deformation of the facial features in the image uploaded.
Is there anything that exists that might run along the same lines and that provides an explanation/source code I could look at to get a better idea of how to go around doing this? Or if there are any other ideas on how to manipulate and distort the image that doesn't use the DisplacementMap Filter?
Any feedback and help is greatly appreciated. Thank you for your time.
see http://sakri.net/technology/flash/flex/convolution_filter/ConvolutionFilterExplorer.html
(source code available)