it is not so easy as you think!
to set it 60 call:
Object(FlexGlobals.topLevelApplication).stage.frameRate=60;
or... create this setter
public static function set frameRate(framerate:int):void{
Object(FlexGlobals.topLevelApplication).stage.frameRate=framerate;
}
and call
frameRate=60;
you may also define it in mxml
frameRate="60"
The default value of the player is 25; increasing the frame rates you consume more cpu! don't forget that you application will run in a slower computer than yours!
Flexache, is the pain you feel in your brain when you coding on Adobe’s Flex Builder, Flash builder with Flex SDK and Actionscript in general. The pain is starting from the eyes, as you can’t believe what you see and is getting deep in your head as you can’t fix. In this blog I‘ll give you painkiller to get out of a lot strange troubles showing solutions and techniques in Flex.
Wednesday, 29 June 2011
Tuesday, 21 June 2011
how to bringToFront an object on a container?
situation | |
How to bring to front an object of the same container front of someone else (of the same container)? The easiest wait it to change the “depth” property of to object. WRONG! In the meanwhile it should work! | |
problem | |
adobe flex AS3.0, how to bringToFront an object on a container? The depth… doesn't matter! --- > dn |
difficulty level | |
3/10 :| | |
compatibility | |
flex 4.0 | |
solution |
public static function bringToFrontWithApplicationHost(container:Application,displayObjectToBringToFront:IVisualElement):void{
container.swapElements(container.getElementAt(container.numElements-1),displayObjectToBringToFront);
}
public static function bringToFrontHostWithContainerHost(container:Container,displayObjectToBringToFront:IVisualElement):void{
container.swapElements(container.getElementAt(container.numElements-1),displayObjectToBringToFront);
}
or use what ever you want... they do the same
public static function bringToFrontWithApplicationHost2(container:Application,displayObjectToBringToFront:IVisualElement):void{
container.removeElement(displayObjectToBringToFront);container.addElement(displayObjectToBringToFront);
}
public static function bringToFrontHostWithContainerHost2(container:Container,displayObjectToBringToFront:IVisualElement):void{
container.removeElement(displayObjectToBringToFront);container.addElement(displayObjectToBringToFront);
}
Wednesday, 15 June 2011
How to delete Temporary files, from internet and from other applications manually?
situation | |
Internet browsers are keeping a lot of files as cache. As you may clear this cache for their options, doesn’t do the entire job always. Also, if the system crashed and you want to transfer your data to another disk, these files are too many and completely rubbish. Here is a way to delete these files manually. | |
problem | |
How to delete Temporary files, from internet and from other applications manually? You may delete them safely! | |
difficulty level | |
0/10 :))) | |
compatibility | |
win xp, win vista, win7 | |
solution | |
In xp systems C:\Documents and Settings\<user name>\Local Settings\Temp C:\Documents and Settings\<user name>\Local Settings\Temporary Internet files C:\Documents and Settings\<user name>\Local Settings\Temp\Cookies (here are the cookies) In Vista and win7 systems C:\Users\<user name>\AppData\Local\Temp\ C:\Users\<user name>\AppData\Local\Microsoft\Windows\Temporary Internet Files To delete these files permanently without moving them to recycle bin and waste a lot of time, hold the shift key down during the right click and delete. By this way the system will not transfer the files to recycle bin but will notifies you also that deletion will be permanently. |
Sunday, 12 June 2011
Flex4, how to wait object to be completely initialized; how to give time to objects to be completely initialized
Suppose that you have an Object called Circus. This object is too complex (like a real circus). The follow init() function creates the circus it but in real programming world the Circus object is not prepared because the Circus must be render its components, update several graphics objects .
internal function init():void{
//create my.. circus…
myCircus=new Circus(“My X-circus");
//initialize
myCircus.x=10; myCircus.y=40;
//play
myCircus.play();
myCircus.cashier.addMoney(100.50); //this might be wrong, as the circus in not ready yet!
}
This problem occurred on simpler objects also… like the Flex’s Label. If on “applicationComplete” you apply a value to “text” property of a Label a text (i.e. “hellow world”) and right after you try to get the “width” of the Label object, you might be get WRONG value, a not real width; this because the Label object is not yet prepared.
Well, how to get that an object is completed? With Flex’s Label, the event you must Listen is the “FlexEvent.UPDATE_COMPLETE” and not other “UPDATE_COMPLETE” because Flex offers and other from other Eventxxx classes. Note that this is working in Flex 4.0.
So… the Circus object must supports and dispatch once upon a time the “FlexEvent.UPDATE_COMPLETE” to continue in safe way the calculations with its properties.
But, what happen if the Circus doesn’t supports this event? Unfortunately this is happening in real world with several 3rd party components / object.
Bellow there is a solution that is not so professional but it is the only chance to make it work! ;) What I do here is that I am working for a while with Event.ENTER_FRAME, with this way I give some time to then whole application and its running objects to complete uncompleted calculations.
//this is my own counter to count the passed time.
internal var myWaitCounter:int;
internal function init():void{
//create my.. circus…
myCircus=new Circus(“My X-circus");
//initialize
myCircus.x=10; myCircus.y=40;
//prepare and activate my listener pf ENTER_FRAME event
myWaitCounter=0;
addEventListener(Event.ENTER_FRAME,Handler_WaitForCompletion);
}
internal function Handler_WaitForCompletion (e:Event):void{
//add to my counter the time
myWaitCounter+=1000/ Object(FlexGlobals.topLevelApplication).stage.frameRate;
//if, 500ms (0,5sec) passed, then call the start() after remove then listener
//in general it is very important to remove the listeners where you don’t need any more
if (myWaitCounter >=500) {
removeEventListener(Event.ENTER_FRAME,Handler_WaitForCompletion);
start();
}
}
protected function start():void{
//now you are ready to play with you circus safely!
myCircus.play();
}
Saturday, 4 June 2011
Flex, Determining which server/domain a SWF is hosted on
situation | |
Here’s a handy tip which can help you when deploying Flex applications on mulitple servers (such as a staging/production server). Basically you can listen for the Application tag to dispatch the applicationComplete event, grab the URL of the SWF using the loaderInfo.url property, and then use the URLUtil.getServerName() method to parse out the server name. | |
problem | |
adobe flex4 flex 4.0 AS3.0 Determining which server/domain a SWF is hosted on | How to get the domain where the swf is hosted ---- > page: dn | |
difficulty level | |
0/10 :))) | |
compatibility | |
flex4, as3 | |
solution | |
In prior version of Flex 4.0 use this: URLUtil.getServerName(Application.application.loaderInfo.url); In 4.0 use this: because Application is no longer available in 4.0 URLUtil.getServerName(FlexGlobals.topLevelApplication.url) |
Subscribe to:
Posts (Atom)