-
1. Re: I really need your help with Javascript and BitmapData functionality
dmeN Jul 21, 2010 8:12 AM (in response to andrejusc)In Flash you would use the ExternalInterface class to allow JS buttons to call Flash AS methods. You use theaddCallback method of ExternalInterface to allow calling from JS. Just check out the help.
-
2. Re: I really need your help with Javascript and BitmapData functionality
andrejusc Jul 21, 2010 8:26 AM (in response to dmeN)Hey, yes, I'm using that ExternalIInterface approach already. But my problem is not with Javascript itself but with BitmapData I obtain while going to Flash via Javascript.
I.e. when I obtain BitmapData via Javascript calling Flash function - those data are wrong and when I obtain BitmapData via Flash own button - it's correct. Flash button in that case calls exactly the same function as my Javascript button via ExternalInterface.
What could be wrong with that???
-
3. Re: I really need your help with Javascript and BitmapData functionality
dmeN Jul 21, 2010 11:04 AM (in response to andrejusc)Sorry, I don't really know the answer to that - never tried passing a bitmapData from JS to Flash... if it works from Flash though, you could just hav
e your button call a method in Flash, that then calls the JS to get the bitmap.
-
4. Re: I really need your help with Javascript and BitmapData functionality
andrejusc Jul 21, 2010 11:26 AM (in response to dmeN)No, I'm not passing a bitmapData from JS to Flash. Everything is done inside Flash itself and with ActionScript.
Here is the sequence of actions:
1. Flash has function, let say calculateBitmap()
2. Flash defines another function to be called by JS, let say cbCalculateBitmap(), which then calls calculateBitmap()
3. Now HTML button has onclick() specified as cbCalculateBitmap().
Could you understand that flow?
What I'm saying is that this sequence doesn't produce correct result, while if calculateBitmap() called directly by Flash button - it works correctly.
-
5. Re: I really need your help with Javascript and BitmapData functionality
Andrei1 Jul 22, 2010 5:33 AM (in response to andrejusc)You need to show some code on both sides (AS and JS).
-
6. Re: I really need your help with Javascript and BitmapData functionality
Andrei1 Jul 22, 2010 5:41 AM (in response to andrejusc)Just saw your code in the previous post.
It is confusing. Is the problem ExternalInterface communication or BtimapData processing?
-
7. Re: I really need your help with Javascript and BitmapData functionality
andrejusc Jul 22, 2010 6:30 AM (in response to Andrei1)What is confusing? It's not a problem in ExternalInterface availability or call of it from Javascript. It's a problem with obtained later jpgStream.
What code do you need else?
I have Canvas bindable object and ActionScript code:
public function processButton(canvas:Canvas) :void
{
var bitmapData:BitmapData = new BitmapData(canvas.width, canvas.height, false, 0xFFFFFF);
bitmapData.draw(canvas);
var jpgEncoder:JPEGEncoder = new JPEGEncoder(85);
var jpgStream:ByteArray = jpgEncoder.encode(bitmapData);}
In another part of my flash application I have this ActionScript:
ExternalInterface.addCallback("cbProcessButton", processButtonJS);
And processButtonJS is defined as this ActionScript:
public function processButtonJS() :void
{
processButton(canvas);
}
Now HTML button has this:
<input id="bSave" name="button" type="submit" value="Save" onclick="getSWF('${application}').cbProcessButton();" />
Is it more clear now?

