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
Related
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.
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"/>
I am adding a flex image component to a mx:canvas component with a fairly large image. I have the horizontal and vertical scroll policies set to "on", but when I add the image to the canvas, it doesn't expand to show the whole image (the scrollbars aren't activated).
Anybody else have this issue.
The code is pretty straightforward:
<mx:Canvas id="myCanvas" minWidth="0" minHeight="0" horizontalScrollPolicy="on" verticalScrollPolicy="on">
</mx:Canvas>
and the script adding the image
var newImg:Image = new Image();
newImg.source = $value.sourceImg;
newImg.x = $value.positionX;
newImg.y = $value.positionY;
newImg.scaleX = $value.scaleX * _scaleRatio ;
newImg.scaleY = $value.scaleY * _scaleRatio;
newImg.rotation = $value.rotation;
myCanvas.addChild(newImg);
Ok, So I had to use clipCOntent = true. I had clipContent="false", I thought the meant that it would clip the image and anything outside the bounds could just be scrolled, buut it actually just clips it and doesn't offer a scroll.
It would be helpful if you posted your code, but without seeing it I would recommend setting minWidth="0" on the canvas. This is an old trick to force a re-measure of the canvas so it shows the scroll bars properly. Hope that helps.
Try using canvas.rawChildren.addChild(img) instead of canvas.addChild(img). That's worked for me before, otherwise you'll need to hook into the Flex component measuring system - but this is very seldomly necessary.
Cheers
Create a first canvas (viewCanvas) and place another canvas inside it (imageCanvas).
Set the scroll policies on the imageCanvas to 'off'. This should work, and the viewCanvas should have scrollbars. Note that no width/height are specified on the imageCanvas or image in code below
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Canvas id="viewCanvas" x="95" y="65" width="169" height="159">
<mx:Canvas id="imageCanvas" x="0" y="0" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Image x="0" y="0">
<mx:source>http://www.beach-holiday.cn/beach-holiday/pics/2009/09/florida-fort-lauderdale.jpg</mx:source>
</mx:Image>
</mx:Canvas>
</mx:Canvas>
</mx:Application>
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.
I have 2 questions about flex datagrids:
How can I scroll it automatically to the bottom when new portion of data arrived to it (e.g. I added new items)
Strange, but seems it doesn't scroll when I use scrolling wheel, is there any trick about it (especially for mac Users)
Thanks in advance
Some changes:
public function scroll():void
{
trace(chatboard.maxVerticalScrollPosition);
chatboard.verticalScrollPosition = chatboard.maxVerticalScrollPosition;
}
<mx:TextArea id="chatboard" x="10" y="10" width="310" height="181" text="{chatMessages}" editable="false" verticalScrollPolicy="on" resize="scroll()"/>
But actually it don't help. The text area is not autoscrolled :(
Seems that 1) scroll is not called after new string is added to chatMessages
I find here that the mouse wheel scrolls the text area by default. Are you looking for a different behavior?
As far as skipping to the end goes:
in your TextArea wire up to the updateComplete and it seems to work as you would like:
<mx:TextArea id="textArea1" liveScrolling="true" updateComplete="textArea1_Changed(event);" />
then
private function textArea1_Changed(event:Event):void {textArea1.verticalScrollPosition = textArea1.maxVerticalScrollPosition;}
finally, you can test with something like:
private function btnClick(e:Event):void{textArea1.text += new Date().getTime().toString() + "\n";}
1) dataGrid.verticalScrollPosition=dataGrid.maxVerticalScrollPosition