For that use the function valueOf() and it will return the timestamp in milliseconds
Ex: var now:Date = new Date();
var timestamp:int = now.valueOf() / 1000; // Divide by 1000 to convert it into seconds
Flex action scripting, Zend AMF , Audio/Video Player, IBM ILOG Calendar, Cairngorm Framework
Could not resolve s:Group to component implementation
It may be the issue with Flex SDK version. Please try using the latest version.
Change view using ViewStack container with selectedChild property
1. In the main.mxml file add the following
mx:ViewStack id="mainViewStack"
view:bookSearch id="bookSearch" /
view:bookData id="bookData" /
/mx:ViewStack
In the script assign the viewstack object id to the model instance in init() function
mainModel.mainView = mainViewStack; //mainModel => Binded model to change the view
2. Create canvas using the above view names and add these into cairngorm view folder
Refer the below link for creating canvas in Flex Builder
http://flextutorial4you.blogspot.com/2011/03/create-canvas-from-flex-builder.html
3. In the model add the following scripts
import mx.containers.ViewStack;
In the class file create static variable of the class name then create and instance of the class
public static function getInstance() : MainModelLocator
{
if ( modelLocator == null )
{
modelLocator = new MainModelLocator();
}
return modelLocator;
}
public function init():void
{
mainView = new ViewStack();
}
public function changeView(viewName:String):void
{
if(mainView.selectedChild.name != viewName)
{
this.mainView.selectedChild.dispatchEvent(new Event("INTERRUPT", false, false));
mainView.selectedChild = Container(mainView.getChildByName(viewName));
}
}
4. Then use the mainModel class and call the function changeView() for changing the view
Ex: mainModel.changeView("bookData");
mx:ViewStack id="mainViewStack"
view:bookSearch id="bookSearch" /
view:bookData id="bookData" /
/mx:ViewStack
In the script assign the viewstack object id to the model instance in init() function
mainModel.mainView = mainViewStack; //mainModel => Binded model to change the view
2. Create canvas using the above view names and add these into cairngorm view folder
Refer the below link for creating canvas in Flex Builder
http://flextutorial4you.blogspot.com/2011/03/create-canvas-from-flex-builder.html
3. In the model add the following scripts
import mx.containers.ViewStack;
In the class file create static variable of the class name then create and instance of the class
public static function getInstance() : MainModelLocator
{
if ( modelLocator == null )
{
modelLocator = new MainModelLocator();
}
return modelLocator;
}
public function init():void
{
mainView = new ViewStack();
}
public function changeView(viewName:String):void
{
if(mainView.selectedChild.name != viewName)
{
this.mainView.selectedChild.dispatchEvent(new Event("INTERRUPT", false, false));
mainView.selectedChild = Container(mainView.getChildByName(viewName));
}
}
4. Then use the mainModel class and call the function changeView() for changing the view
Ex: mainModel.changeView("bookData");
Create canvas from Flex Builder
1. Select File => New => MXML Component
2. Enter canvas name
3. In the "Based On", click Browse then enter mx.containers.Canvas on the top text-box
4. Then Select the Canvas listed
5. Click Finish
2. Enter canvas name
3. In the "Based On", click Browse then enter mx.containers.Canvas on the top text-box
4. Then Select the Canvas listed
5. Click Finish
How to use resource file in Flex Application
1. You have to add "MetaData" tag in the view file
open mx:Metadata
[ResourceBundle("ResourceFile")]
close mx:Metadata
2. Create a folder structure locate/local/en_US/ and file ResourceFile.properties
And in the file
# locale/en_US/ResourceFile.properties
main_server_url=localhost
3. In the Project=>Properties=>Flex Compiler
Add the following
-allow-source-path-overlap=true -source-path=locale/local/{locale}
4. To use it in Model
var serverName:String = ResourceManager.getInstance().getString("ResourceFile","main_server_url");
open mx:Metadata
[ResourceBundle("ResourceFile")]
close mx:Metadata
2. Create a folder structure locate/local/en_US/ and file ResourceFile.properties
And in the file
# locale/en_US/ResourceFile.properties
main_server_url=localhost
3. In the Project=>Properties=>Flex Compiler
Add the following
-allow-source-path-overlap=true -source-path=locale/local/{locale}
4. To use it in Model
var serverName:String = ResourceManager.getInstance().getString("ResourceFile","main_server_url");
Control NetStream Volume/Sound using soundTransform
public function changeVolume(tranValue:Number):void
{
var audioSound:SoundTransfom = new SoundTransfom();
audioSound.volume = tranValue;
NetStream.soundTransform = audioSound;
}
{
var audioSound:SoundTransfom = new SoundTransfom();
audioSound.volume = tranValue;
NetStream.soundTransform = audioSound;
}
Move Forward or Backward the Audio/Video Streams
For that we can use the NetStream.seek() function
Ex; NetStream.seek(NetStream.time + 10); //for forward
NetStream.seek(NetStream.time - 10);//for backward
Ex; NetStream.seek(NetStream.time + 10); //for forward
NetStream.seek(NetStream.time - 10);//for backward
Change Image source dynamically using Action Script
[Embed(source="./images/play.jpg")]
private var playBtn:Class;
private function init():void
{
var asset:BitmapAsset = new playBtn() as BitmapAsset;
play_button.source = asset; //play_button => image id attribute
}
private var playBtn:Class;
private function init():void
{
var asset:BitmapAsset = new playBtn() as BitmapAsset;
play_button.source = asset; //play_button => image id attribute
}
NetStream onMetaData function call
var ns = new NetStrea();
var metaObj:Object = new Object();
ans.client = metaObj
var _playDuration:Number;
metaObj.onMetaData = function(obj:Object)
{
_playDuration = obj.duration;
trace(_playDuration);
}
var metaObj:Object = new Object();
ans.client = metaObj
var _playDuration:Number;
metaObj.onMetaData = function(obj:Object)
{
_playDuration = obj.duration;
trace(_playDuration);
}
Buffering Audio/Video Streams
Buffering a video stream helps ensure that the video plays smoothly, without interruption.
To create the best experience for users, monitor the progress of a video and manage buffering as the video downloads. You may need to set different buffer sizes for different users, to ensure the best playback experience. One choice is to detect a user's bandwidth (http://livedocs.adobe.com/flashmediaserver/3.0/hpdocs/help.html?content=00000070.html#1046682) and set an initial buffer size based on it.
While the stream is playing, you can also detect and handle netStatus events. For example, when the buffer is full, the netStatus event returns an info.code value of NetStream.Buffer.Full. When the buffer is empty, another event fires with a code value of NetStream.Buffer.Empty. When the data is finished streaming, the NetStream.Buffer.Flush event is dispatched. You can listen for these events and set the buffer size smaller when empty and larger when full.
To create the best experience for users, monitor the progress of a video and manage buffering as the video downloads. You may need to set different buffer sizes for different users, to ensure the best playback experience. One choice is to detect a user's bandwidth (http://livedocs.adobe.com/flashmediaserver/3.0/hpdocs/help.html?content=00000070.html#1046682) and set an initial buffer size based on it.
While the stream is playing, you can also detect and handle netStatus events. For example, when the buffer is full, the netStatus event returns an info.code value of NetStream.Buffer.Full. When the buffer is empty, another event fires with a code value of NetStream.Buffer.Empty. When the data is finished streaming, the NetStream.Buffer.Flush event is dispatched. You can listen for these events and set the buffer size smaller when empty and larger when full.
Subscribe to:
Posts (Atom)