Filters on DisplayObject Not working - html

I'm trying to add DropShadowFilter / BlurFilter / GlowFilter to a simple Sprite on stage.
If i target flash, it looks and behaves fine. When i target HTML5, i see nothing.
The wiki says "Available on all platforms" (link).
Am i doing something wrong?
I'm importing
import openfl.filters.BlurFilter;
import openfl.display.Sprite;
Here is the code im using:
var s:Sprite = new Sprite();
s.graphics.beginFill(0xff0000, 1);
s.graphics.drawCircle(50, 50, 50);
s.graphics.endFill();
var blur:BlurFilter = new BlurFilter(40, 40, 1);
s.filters = [blur];
addChild(s);
HTML5 PRINTSCREEN:
FLASH PRINTSCREEN:

Right now there is little to no support for filters on any target but Flash.
The good news is that we are working on implementing custom shaders and filters for OpenFL next on every target that uses OpenGL. Here is the PR and discussion https://github.com/openfl/openfl/pull/697
I would guess that some filters could be implemented via software for HTML5 canvas, but I'm not focusing on that in that PR.

As far as im aware filters are not supported in legacy or next. Ive never seen them working anyway. I presume eventually they will be supported in next.

Related

How can I fix touch lag in Flash?

I've encountered strange behavior when using AS3's TouchEvents to handle multi-touch. The touch lags considerably in certain situations, but Flash's frame rate isn't affected. It's as though the touches are getting buffered and the events just aren't dispatched until several seconds after the touch.
I've uploaded a demonstration here: https://youtu.be/omkCDqljfio
I've only managed to reproduce this touch lag in the ActiveX version of Flash Player, but I've reproduced it in both Windows 10 and Windows 7. So what I have here is a C# application that's hosting my AS3 test suite, but it can also be observed if the swf is viewed in Internet Explorer.
Since my application already involves hosting the SWF in a WPF window, I've been attempting to create a solution where touch is received in C# and then communicated to the AS3. It would work perfectly but it seems my WPF window isn't receiving touch frames when the touch is on a WindowsFormsHost. So there's another problem that I have to solve.
FlashDevelop project: https://drive.google.com/file/d/0BxC2eCzurT9rd0gzSGc4TUdQLTQ/view
Visual Studio solution: https://drive.google.com/file/d/0BxC2eCzurT9rUThmRHBKWHZmbzA/view
AS3 touch events:
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
stage.addEventListener(TouchEvent.TOUCH_BEGIN, stage_touchBegin);
stage.addEventListener(TouchEvent.TOUCH_MOVE, stage_touchMove);
stage.addEventListener(TouchEvent.TOUCH_END, stage_touchEnd);
Creating the display objects that contribute to the lag, presumably because of the touch event capture phases:
for (var i:int = 0; i < 500; i++)
{
Dotter.createBGDot(_bgLayer, _shapesOn ? Shape : Sprite);
}
...
static public function createBGDot(bgLayer:Sprite, dotClass:Class):void
{
var dot:* = new dotClass();
var color:Color = new Color();
color.brightness = Math.random();
dot.graphics.beginFill(color.color);
dot.graphics.drawCircle(0, 0, Math.random() * 400 + 40);
dot.x = Math.random() * bgLayer.stage.stageWidth;
dot.y = Math.random() * bgLayer.stage.stageHeight;
bgLayer.addChild(dot);
}
I know this is sort of an unusual situation, but I appreciate any advice about how to resolve these issues.
Now that I've used Adobe Scout I think it is a rendering issue after all. The frame rate still shows 30fps because the processing time just barely manages to hit the 30fps mark. Lowering the frame rate fixes the problem.
It is still strange that the touch events would have such a long delay when the frame rate is just barely falling short, though.

StageWebView Flash's White when Displayed

StageWebView Flash's White when Displayed
So I've been working on a project using Adobe Animate to create a universal Air application that can be ported to multiple platforms i.e. Mac, Windows, and iOS.
It uses StageWebView to display videos embedded on HTML pages that have their own custom html5 video player and everything works well except for one simple but annoying thing.
Whenever I display a Stage Web View you'll see a flash of white before the page displays.
Now I originally thought this was an issue with checking for a URL load completion or a poorly formatted HTML document but that doesn't seem to be the case.
What I did notice after several attempts of trying to remove the issue is that it did go away if I used the embedded Air WebKit opposed to using the native WebKit from the desktop device.
(Code Below) Causes white flash on load:
var webView:StageWebView = new StageWebView(true);
(Code Below) This gets rid of the issue but my HTML tags like video and progress are not supported by the embedded WebKit and no longer function properly.
var webView:StageWebView = new StageWebView();
Information from about the setting from Adobe:
useNative:Boolean (default = false) — When useNative is false, a version of WebKit embedded within AIR is used as the source of the
StageWebView created. When useNative is true, then AIR will use the
the system's default web engine. Mobile platforms only support using
the system web engine, so useNative is ignored on mobile platforms.
The frustrating thing is that I've set a listener to check for load completion and that doesn't get rid of the issue. So as a workaround I've hidden the displayed StageWebView off the screen and then moved it's location to where I want it to be after a delay which is not great.
Other attempts to display it small as a pixel resize it in place cause the issue still.
/* Check for Stage Web View Errors */
webView.addEventListener(ErrorEvent.ERROR, onError);
function onError(e:ErrorEvent):void {
trace("Stage Web View error: " + e);
}
/* Function to not show Stage Web View until loaded. */
function onCompleteHandler(e:Event):void {
webView.assignFocus();
// Delay the Stage Web View to fix white flash issue.
setTimeout(callWebView,500);
webView.removeEventListener(Event.COMPLETE,onCompleteHandler);
}
/* Multi-Function Stage Web View Loader, Just add file path string to call */
function webviewFilePath(path:String):void {
webView.stage = this.stage;
// Prep filepath
filePath = new File(new File(path).nativePath).url;
// Load file path
webView.loadURL(filePath);
// Add listener for Complete URL Load then Show
webView.addEventListener(Event.COMPLETE,onCompleteHandler);
}
/* Function to call Stage Web View independantly so it can be delayed with a timer */
function callWebView() {
webView.viewPort = new Rectangle(posX(viewX), posY(viewY), viewWidth, viewHeight);
}
Any hints or tips on how I can alleviate or fix the issue would be great.
Of course if Adobe just actually updated the embedded Air WebKit that would probably fix the whole issue in the first place but I doubt that's happening anytime soon.
Partial Fix
So the issue still exists when I initially load up the Stage Web View but I've managed to minimize its appearance during app use.
One major part of the issue was how I reset the StageWebView in preparation for a new page I wanted to load or when I wanted to close the view.
I went a little overboard on resetting StageWebView because audio in StageWebView has been known to continue playing even when it's hidden.
/* Function to Reset Stage Web View */
function resetWebView():void {
webView.loadString("<!DOCTYPE HTML><html><body></body></html>");
//webView.viewPort = new Rectangle(0, 0, 0, 0);
webView.stage = null;
//webView.viewPort = null;
}
I realized I could just simply hide the StageWebView and load up a blank page while it was hidden from view to stop any audio playing. That was easy enough to accomplish with a simple string loaded into it.
Although from time to time I'll still see that white flash it's occurrence is minimal.
private var webView : StageWebView;
webView = new StageWebView( true );
webView.stage = this.stage;
webView.viewPort = new Rectangle( 0, 0, 1024, 768 );

StageText multiline problems

So I am pretty new to this whole AIR for iOS development thing and am just dipping my toe into the StageText object for a project I am working on. I am having trouble getting my StageText to be restricted to a single line. (such as for username input)
The documentation is terrible from Adobe but blog posts I have found have said to pass "false" to the StageTextInitOptions which seems to sorta work, but not really. When I do this the read-only multiline property on the stageText option traces as "false" which is good but when I actually type in the field it still breaks and goes to the next line when it is full.
here is my code:
var stageTextInitOptions = new StageTextInitOptions(false);
stageText = new StageText(stageTextInitOptions);
stageText.stage = stage;
stageText.viewPort = new Rectangle(0, 0, w, h);
trace(stageText.multiline); //traces out as false
EDIT: The problem seems to be in desktop only, when the app is placed on an ipad the multiline limitation functions as expected. (The problem is it NEEDS to work on both desktop and ios)
Any ideas? thanks so much!
StageText uses native mobile keyboards only on iOs and Android. You will need to work with the TextField and wordwrapping on the Desktop.
Why would you not use a regular hardware keyboard on a Desktop though? It's as native for Desktops as it gets.
use :
var stageTextInitOptions = new StageTextInitOptions(true);

Using HTML 5 into Html Web Resource in Crm 2011

Hy everyone, how are you?.
Well. The case is that I need to develop a web resource that will be embeded on Form's header.
This Web Resource should draw a rectanble with a label for each value of a pick list that is being showed on the form.
I tryed to use HTML 5 in order to draw the rectangles but I can't make it work properly once is included on the web resource.
I'll paste here an excample that, if it's opened normally using IE, runs normally, but opened through a Web resource embeded into the form's header down't work and throws me an exception like : ' getContext(() functions is not defined'
Here is the code
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var xpos = -50;
debugger;
for (var ii = 0; ii < 3; ii++) {
xpos += 50;
ctx.fillStyle = "#FF0000";
ctx.fillRect(xpos, 1, 50, 50);
ctx.fillStyle = "#000000";
ctx.font = "10px Arial";
ctx.fillText("Stage ", xpos+5, 25);
}
Question: Can I draw in crm using HTML 5 into a web resource????
Thanks in advance!
I'm sorry to say that but the answer marked as the correct one it's not actually correct cause doesn't answer the question and also got me into confusion because of an assumption.
Nobody's fault, however lets say things straight for the other who will need the right answer to this question.
The error you received sounds like this: "Object doesn't support property or method 'getContext'" and referrs to HTML5 canvas.getContext() object.You got this error because the built-in object for the canvas element, the getContext() one, works only in IE9 (first IE browser version compatible with HTML5) and you runed your CRM 2011 instance in an older version of IE.
Seeing this message on my computer I thought this is an error cause I was running my CRM 2011 instance in IE9 browser version but when I runned the F12 developer tools in I saw that the Browser Mode was IE9 but the Document Mode was IE8 standards wich is set as the default one for the CRM 2011 instance. So, I tried to change it to IE9 standards but surprise - CRM 2011 has now javascript errors and crushes. Looks like CRM 2011 doesn't actualy runs in IE9 standards but in IE8 standards even if the browser version is IE9 (bropably this was your case too).
So, for the moment, using HTML 5 elements into Html Web Resource in Crm 2011 is not yet possible.
The only ideea I have in mind is that for the moment we can only create stand alone appplications that can contain HTML5 elements and connects to our CRM data till MS figures out a way for running CRM 2011 in IE9 standards.
If somebody knows more than those informations, please let us know.
Sry for the possible typos!
Looks like you are accessing related records and have to add ClientGlobalContext.js in your web resource. This dynamic JS file gives reference to the global context (a connection to CRM objects) to let you query data.
For a project that I work on, I refer to the js like the following.
<script type="text/javascript" src="http://{SERVERNAME}[:PORT]/{ORGNAME}/WebResources/ClientGlobalContext.js.aspx"></script>
Also, on a second thought, if you are accessing values from the form itself, you are not querying any other records, you should not need this.
Regarding HTML5 (I love it!), it's just a browser thing, if it works outside of CRM, pretty good chances, it will work within CRM too!

how do you find error in a SWF?

i feel stupid asking that question, but it seems like i'm unable to find out.
i have a SWF that works perfectly inside flash. once i export as SWF, it doesn't work anymore.
i can't use "trace"
i have tryed that function but it doesn't trigger it for some reason. :
function quikTrace(string:String){
//INIT VARIABLES
var tmpTxtField:TextField;
//TEXTFIELD PROPERTIES
tmpTxtField = new TextField();
tmpTxtField.text = string;
tmpTxtField.x = stage.width / 2;
tmpTxtField.textColor = 0xFFFFFF; //white (black background)
tmpTxtField.y = stage.height / 2;
addChild(tmpTxtField);
}
is there any "outside the box" way to find errors in a SWF?
You can view trace statements in the browser by doing a few quick steps:
Get a debug flash player for your browser. link
Set up mm.cfg to enable flash logging to a file. link
Get a text editor / "tail" viewer and read the flashlog.txt file that is generated. This is where FireBug & Flashbug come in handy, if you're in firefox. You can also try baretail for PC, or regular old "tail -f" on a mac/linux machine.
Good luck.
It's not a stupid question at all! You're just learning how to debug Flash for the first time. You can use "trace" with an exported SWF by doing a debug/test build from Flash IDE or Flash Develop. You can then read these traces with Firefox by using the extentions Firebug combined with the Flashbug extension. Now you're all set for getting feedback using traces.
For this particular problem, it's hard to say. Is this function inside of a class or timeline code? If it's a class, it probably because Stage is not ready yet. You can use the event Event.ADDED_TO_STAGE to know when the Stage reference is ready to be used.
Hope this helps!
Install a debug version of flash player for your browser. It will tell you exactly which line of code is throwing error.
http://www.adobe.com/support/flashplayer/downloads.html