Spark VideoDisplay with long wait high CPU usage in Google Chrome (and Opera) - apache-flex

I've created a Flex website that plays a video using the Spark VideoDisplay component.
When selected, the VideoDisplay loads in the PopUpManager.
This works fine in all the browsers, except Google Chrome take significantly longer to start playing, during which the CPU usage peaks, then goes back down once video starts playing.
I've traced the player states it goes through and they are as follows:
Loading
ready (hangs for ages with high cpu)
buffering
playing (immediately after buffering, CPU usage goes down, video plays smoothly)
What could be causing this to temporarily hang for so much longer in Chrome? I thought I could expect the same functionality and behaviour throughout all the browsers, as Flash is simply a plugin that runs as a separate process?
Thanks!
Edit: It seems that it's the same in Opera too. Is there any commonality between the two that would explain this behaviour?
Edit 2: Thanks for your reply, here's the relevant code:
MXML:
<s:Group id="videoPopup"
click="closePopupHandler(event)">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="#2a2a2a"/>
</s:fill>
</s:Rect>
<spinner:Spinner id="spinner"
tickColor="#ffffff"
horizontalCenter="0" verticalCenter="0"/>
<s:VideoDisplay id="videoDisplay" width="100%" height="100%"
updateComplete="videoDisplay_updateCompleteHandler(event)"
mediaPlayerStateChange="videoDisplay_mediaPlayerStateChangeHandler(event)"
complete="videoCompleteHandler(event)"/>
<graphics:CloseButton id="closeVideoButton" visible="false" width="60" height="60" top="10" right="10"/>
<s:Label id="videoCredit" text="Filmed & produced by Engine Creative"
bottom="25" right="10" alpha="0"
fontFamily="HelveticaEmbedded" fontSize="11" color="#cccccc"/>
</s:Group>
Initiating actionscript:
PopUpManager.addPopUp(this.videoPopup, FlexGlobals.topLevelApplication as DisplayObject, true);
videoPopup.width = Math.min(1280, stage.stageWidth * 0.9);
videoPopup.height = Math.min(720, stage.stageHeight * 0.9);
PopUpManager.centerPopUp(this.videoPopup);
hidePlayOverlay.play();
showVideoCredit.end();
spinner.play();
showCreditTimer.addEventListener(TimerEvent.TIMER_COMPLETE, showCredit);
showCreditTimer.reset();
showCreditTimer.stop();
if(!videoDisplay.source || videoDisplay.source != _asset.source)
videoDisplay.source = _asset.source;
videoDisplay.seek(0);
videoDisplay.play();
And relevant event handlers:
protected function videoDisplay_updateCompleteHandler(event:FlexEvent):void
{
Debug.log("video update complete");
if (videoDisplay.videoObject)
videoDisplay.videoObject.smoothing = true;
}
protected function videoDisplay_mediaPlayerStateChangeHandler(event:MediaPlayerStateChangeEvent):void
{
Debug.log("player state: " + event.state);
showCreditTimer.reset();
if (event.state == MediaPlayerState.PLAYING)
{
showCreditTimer.start();
showCloseButton();
spinner.stop();
}
}
Thanks again!

Hardware acceleration is partially supported by default if you have a supported GPU. If you want full 3d support, you need to use StageVideo and need to set the 'wmode' param in html to 'direct'. You should read up more on it.

Related

addChildAt function in flex seems to be not working

i am working on a flash player and in that i am adding functionality of going to full screen and then coming back to normal screen for that i am displaying a button for going to full screen and then a button to come back to normal screen and toggling between normal and full screen i change the buttons for full screen and normal screen it works fine if i toggle b pressing that icons/buttons but when i come back to normal screen from full screen the addChildAt function doesn't seems to be working as my code for that event is
public function replaceIconFs():void
{
var indexReplace:Number = partTwo.getChildIndex(exit_fullScreen);
partTwo.removeChild(exit_fullScreen);
partTwo.addChildAt(view_fullScreen,indexReplace);
fs=false;
}
and the elements are defined as
<mx:Image id="sepFscreen" width="0" source="{sep}"/>
<mx:Button id="view_fullScreen" width="28" height="31"
click="view_fullScreen_clickHandler(event)" paddingLeft="0"
paddingRight="0" paddingTop="2" skin="{FullScreenButtonSkin}"
toolTip="View Fullscreen"/>
<mx:Button id="exit_fullScreen" width="28" height="31"
click="view_fullScreen_clickHandler(event)" paddingLeft="0"
paddingRight="0" paddingTop="2" skin="{ExitFullScreenButtonSkin}"
toolTip="Exit Fullscreen"/>
now i need to know that why thatpartTwo.addChildAt(view_fullScreen,indexReplace); is not seemed to be working
also i want to mention the same code works for other player but not for this
thanks in advance

Flex image mouse over

I have the next code that show a image and when mouse is over change it.
<mx:Image source="{ConfigApp.getResourcesPath()}/img.jpg" id="imgOne"
mouseOver="imgOne.source=ConfigApp.getResourcesPath()+'/img_over.jpg'"
mouseOut="imgOne.source=ConfigApp.getResourcesPath()+'/img.jpg'"/>
I have 2 problems:
1st: If I pass fast with the mouse over the image, some times the image state with mouseOver image (don't detect the mouseOut event).
2nd: In the moment that mouse is over there are a few miliseconds when the aren't any image, so its looks like a white flash every time that mouse is over.
2nd issue:
Its loading the image each time, this flash will get worse when on a remote connection. instead, cahce the image in a class and switch the class reference.
[Embed(source="/assets/imageOver.png")]
public static const overImage:Class;
[Embed(source="/assets/img.png")]
public static const image:Class;
Then switch them like this...
<mx:Image source="{image}" id="imgOne"
mouseOver="imgOne.source=overImage"
mouseOut="imgOne.source=image"/>
I'd rather make something like this, it solves all the problems:
[Bindable] public var isOurMouse:Boolean = false;
<mx:Canvas>
<mx:Image source="{ConfigApp.getResourcesPath()}/img.jpg"
mouseOver="isOurMouse = true"
mouseOut="isOurMouse = false"/>
<mx:Image source="{ConfigApp.getResourcesPath()}/img_over.jpg"
mouseEnabled="false" mouseChildren="false"
visible="{isOurMouse}"/>
</mx:Canvas>
To the point, if you want your image not to blick on reload, you should have two images, one on another, where background one reloads only after the foreground one has completed loading. Actually, your image blicks, but you don't see it:
<mx:Canvas>
<mx:Image id="imgBkg"/>
<mx:Image id="imgFrg"
source="{something}"
complete="imgBkg.source = imgFrg.source"/>
</mx:Canvas>

Is it possible to stop my labels disappearing on my flex pie chart between segment selections whilst interpolating?

I have a flex pie chart:
<mx:PieChart alpha="0.9" fontSize="{QPieSeries_font}" width="100%" top="20" height="320" id="QPieChart"
dataProvider="{dataObj}" horizontalCenter="0" color="0xFFFFFF" fontFamily="MyriadWebPro"
showDataTips="true" dataTipFunction="QdataTipFunction"
dataTipItemsSet="true" itemClick="QPieChart_itemClickHandler(event)">
<mx:series>
<mx:PieSeries id="QPieSeries" labelField="Answer" field="Value" labelPosition="callout"
showDataEffect="QSeriesInterpolate" alpha="1"
reserveExplodeRadius="0.05"/>
</mx:series>
</mx:PieChart>
where the QSeriesInterpolate is a simple interpolation given in the declaration:
<fx:Declarations>
<mx:SeriesInterpolate id="QSeriesInterpolate" duration="500" />
</fx:Declarations>
and the item click event looks like:
protected function QPieChart_itemClickHandler(event:ChartItemEvent):void
{
var ExAr:Array = [];
ExAr[event.hitData.chartItem.index] = 0.05;
QPieSeries.perWedgeExplodeRadius = ExAr;
}
Basically, what annoys me is that when I click a segment to activate the interpolated event, the datatips disappear for it's duration. Whilst this is only half a second, it still detracts from user experience. Is there anything I can do to avoid it??
ALSO! Another thing: Is it obvious to anyone why my dataTipFunction doesnt work? It looks as follows:
public function QdataTipFunction(hitData:HitData):String
{
var a:String = "abc"
return a;
}
Yes it's simple but I was just trying to persuade it to work... to no avail. I think it might be some sort of font issue?
Thanks!
Josh
You might consider looking into Axiis. It is a flex data visualization framework, and has some awesome example charts. The main deal though is you have full control over EVERTHING! Probably overkill for what you are doing, but it really is awesome.
http://www.axiis.org/examples.html

Scrolling an editable spark TextArea from Flex Hero Mobile on a touch device

I am having a hard time figuring this out...
How do you scroll an editable TextArea (Flex Hero) on a touch device?
I am referring to the situation where the text does not fit in the TextArea height.
When I try to tap and drag the text gets selected and not scrolled... Am I missing a something here? I am using verticalScrollPolicy = on (also tried auto).
I am testing the code in the Blackberry Playbook simulator (my targeted device for my app).
If you have any hints or suggestions please let me know.
Thanks,
A TextArea is an editable component. You should try using RichText instead if you don't want to edit the text.
Put it in a s:Scroller:
<s:Scroller id="prayerSc" width="100%" height="100%">
<s:RichEditableText id="prayerText" width="100%" height="100%" clipAndEnableScrolling="true" selectable="true" editable="true" textFlow="{PTFL}" />
</s:Scroller>
RichEditableText is not optimized for mobile
Use this instead Orig source
import spark.components.supportClasses.MobileTextField;
private var cnt:int = 0;
protected function addText():void
{
ta.appendText('More text... ' + cnt++ + '\n');
MobileTextField(ta.textDisplay).scrollV++;
}
<s:TextArea id="ta" width="95%" height="200" editable="false"/>

sequencing through several images

I'm using flex and have a few images that I need to sequence through. I may add some text under each image. What I'm trying to do is automatically sequence through these images such that a black fading effect appears briefly between each image and the next - sure you've seen that sort of thing before.
My questions are this:
should these images be considered as states of a component or what? I was going to go that way, but corrections are welcome
how to get that black fading effect between the images and the next. Any clues please
Update: found an example of it. This example has more elements, but the idea is the same, an images fades and another images loads.
http://www.lifeblue.com/flash/lb_banner.swf
You can try using a ViewStack and a Timer to iterate through its children. Just add a fade in/fade out effect on them and you'll get what you're looking for.
Something like that :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="black" creationComplete="creationCompleteHandler">
<mx:Script>
<![CDATA[
private var timer:Timer;
private function creationCompleteHandler():void
{
timer = new Timer( 2000 );
timer.addEventListener( TimerEvent.TIMER, timerHandler );
timer.start();
}
private function timerHandler( e:TimerEvent ):void
{
if( vs.selectedIndex == vs.getChildren().length - 1 )
vs.selectedIndex = 0;
else
vs.selectedIndex++;
}
]]>
</mx:Script>
<mx:Fade id="fadeIn" alphaFrom="0" alphaTo="1" duration="500" effectEnd="timer.start();"/>
<mx:Fade id="fadeOut" alphaFrom="1" alphaTo="0" duration="500" effectEnd="timer.stop();"/>
<mx:ViewStack id="vs">
<mx:Canvas showEffect="fadeIn" hideEffect="fadeOut">
<mx:Image source="picture1.jpg"/>
</mx:Canvas>
<mx:Canvas showEffect="fadeIn" hideEffect="fadeOut">
<mx:Image source="picture2.jpg"/>
</mx:Canvas>
<mx:Canvas showEffect="fadeIn" hideEffect="fadeOut">
<mx:Image source="picture3.jpg"/>
</mx:Canvas>
</mx:ViewStack>
</mx:Application>
Note that this code isn't the most optimized one. The best would be to create a custom component with a black background and 2 Image components.
Set the alpha property of both of
them to 0
Load a picture in the first one, then
play your fade in effect
Begin to load the following picture
in the second Image component
Fade out the first one, fade in the
second, and load the following
picture in the first Image, etc.
This way you only got one Container (instead of one per picture plus the ViewStack) and 2 Images.
It will also be easier to clean them from memory if you need to.

Resources