PDA

View Full Version : [Solved] Scaleform CLIK UILoader Autosize Flicker problem



Doublezer0
08-26-2010, 11:42 AM
In the Scaleform UILoader.as class in the onLoadComplete function we have this comment

private function onLoadComplete():Void {
onEnterFrame = null;
_loadOK = true;
draw(); // Use draw instead of invalidate to avoid flicker
dispatchEvent({type:"complete"});
}


However I found I was still left with the flicker problem with autosize enabled and sought to rectify the problem.

The fix was shuffling around the position of where visible was set and adding a couple of new places. If you want to get rid of the flicker just create a new UILoader class with a draw() function over-ride like so..


class com.f00n.xUILoader extends gfx.controls.UILoader {

public function xUILoader() {
super();
}

private function draw():Void {
if (!_loadOK) { return; }
contentHolder._xscale = contentHolder._yscale = 100;
//visibility was set here. Now moved below
if (!_autoSize) {
visible = _visiblilityBeforeLoad;
return;
}
if (contentHolder._width <= 0) {
if (_sizeRetries < 10) {
_sizeRetries++;
invalidate();
}
else { trace("Error: " + targetPath(this) + " cannot be autoSized because content _width is <= 0!"); }
return;
}
if (_maintainAspectRatio) {
contentHolder._xscale = contentHolder._yscale = Math.min(height/contentHolder._height,width/contentHolder._width) * 100;
contentHolder._x = (__width-contentHolder._width>>1);
contentHolder._y = (__height-contentHolder._height>>1);
visible = _visiblilityBeforeLoad; //added by 00
} else {
contentHolder._width = __width;
contentHolder._height = __height;
visible = _visiblilityBeforeLoad; //added by 00
}
}

}

Hope that helps avoid your flicking problems ;)

Matt Doyle
08-26-2010, 11:55 AM
Hey there,

I have been informed by our CLIK lead that this issue was fixed internally, and will be available in the next qa. He also wanted me to extend his thanks to you.

Matt Doyle
08-26-2010, 11:58 AM
BTW - fantastic site you have there. I was just talking to our CLIK lead yesterday about adding a CLIK mouse cursor component. Great to see you are really diving into CLIK and coming up with some cool extensions.

Nate Mitchell
08-26-2010, 12:02 PM
This bug has been fixed for the Sept. QA release. There's no need to create a new subclass, you can simply replace UILoader::draw() with this updated function (very similar to to above):


private function draw():Void {
if (!_loadOK) { return; }
contentHolder._xscale = contentHolder._yscale = 100;
if (!_autoSize) {
visible = _visiblilityBeforeLoad;
return;
}
if (contentHolder._width <= 0) {
if (_sizeRetries < 10) {
_sizeRetries++;
invalidate();
}
else { trace("Error: " + targetPath(this) + " cannot be autoSized because content _width is <= 0!"); }
return;
}
if (_maintainAspectRatio) {
contentHolder._xscale = contentHolder._yscale = Math.min(height/contentHolder._height,width/contentHolder._width) * 100;
contentHolder._x = (__width-contentHolder._width>>1);
contentHolder._y = (__height-contentHolder._height>>1);
} else {
contentHolder._width = __width;
contentHolder._height = __height;
}
visible = _visiblilityBeforeLoad;
}

Another minor UILoader bug was fixed for Sept QA where _source was not being reset when unload() was called. Here's the fix:

/**
* Unload the currently loaded content, or stop any pending or active load.
*/
public function unload():Void {
onEnterFrame = null;
if (contentHolder != null) {
visible = _visiblilityBeforeLoad;
loader.unloadClip(contentHolder);
contentHolder.removeMovieClip();
contentHolder = null;
}
_source = undefined;
_loadOK = false;
_sizeRetries = 0;
}

Hope this helps!


Nate

Doublezer0
08-27-2010, 03:29 AM
thanks guys. Now you mention the Cursor class I didnt add a CLIK LoadCallback so I cant wait for a fully state enabled Cursor. I was going to get around to it but im on a deadline so I will leave it in your capable hands. :)

Doublezer0
09-27-2010, 02:35 PM
Hi again

Now that the sept build is released i replaced my extended UILoader class with the Scaleform version and the flicker problem is still there. I cannot understand this as my fix was a little hacky and was optimised by the scaleform devs for good reason. I cant really understand it but can only presume its related to my specific system setup.

If this is the case and the problem occurs for other people it might be worth noting my class example as a fix for the people who still get the flicker problem occuring.

If you have a better explanation for this problem I would appreicate it as its stumped me o.O

thanks