Flex 2 – Flex 3 migration issue with style (bottom,right) with minus value.

May 27, 2008 at 5:18 am (Flex) (, )

In flex 2 if the values of bottom and right for any component if given to minus will not extent the width of the container and the component will also be visible out side the container.

Where as if the same mxml is compiled by the flex 3 SDK will result in scroll bars and if you forcefully set off the properties of scroll policy then the components will be hidden.

Solution ::
Set the clipContent property to false which is true by default to make the components visible even outside the container.

ClipContrent ::
Whether to apply a clip mask if the positions and/or sizes of this container’s children extend outside the borders of this container. If false, the children of this container remain visible when they are moved or sized outside the borders of this container. If true, the children of this container are clipped.
If clipContent is false, then scrolling is disabled for this container and scrollbars will not appear. If clipContent is true, then scrollbars will usually appear when the container’s children extend outside the border of the container. For additional control over the appearance of scrollbars, see horizontalScrollPolicy and verticalScrollPolicy.

The default value is true.

More about migration –> :: http://learn.adobe.com/wiki/display/Flex/Backwards+Compatibility+Issues

See the difference by compiling the code below with flex 2 and flex 3 SDK.

<?xml version=”1.0″ encoding=”utf-8″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” width=”400” height=”580>

<mx:TextArea x=”0” y=”200” text=”Canvas container with Clip Content property set to defaut (i.e. true) .So that the button is hidden when set outside the container and scroll visible.” width=”346” height=”55” enabled=”true/>

<mx:Canvas id=”can1 width=”300” height=”100” backgroundColor=”#ff8000” backgroundAlpha=”1.0” y=”256>

<mx:Button id=”btn1” label=”Button width=”80” height=”80” fillAlphas=”[1.0, 1.0, 1.0, 1.0] right=”-40” bottom=”-40/>

</mx:Canvas>

<mx:TextArea x=”0” y=”0” text=”Canvas container with Clip Content property set to false. So that the button is visible even outside the container.” width=”346/>

<mx:Canvas id=”can” clipContent=”false width=”300” height=”100 backgroundColor=”#ff8000” backgroundAlpha=”1.0” y=”45>

<mx:Button id=”btn” label=”Button width=”80” height=”80” fillAlphas=”[1.0, 1.0, 1.0, 1.0] right=”-40” bottom=”-40/>

</mx:Canvas>

<mx:TextArea x=”0” y=”368” text=”Canvas container with Clip Content property set to defaut (i.e. true) .So that the button is hidden when set outside the container and scroll policy set to false.” width=”346” height=”55” enabled=”true/>

<mx:Canvas id=”can0 width=”300” height=”100” backgroundColor=”#ff8000” backgroundAlpha=”1.0” y=”424” verticalScrollPolicy=”off” horizontalScrollPolicy=”off>

<mx:Button id=”btn0” label=”Button width=”80” height=”80” fillAlphas=”[1.0, 1.0, 1.0, 1.0] right=”-40” bottom=”-40/>

</mx:Canvas>

</mx:Application>

Permalink Leave a Comment

Flash Player 10 Beta is out

May 16, 2008 at 8:27 am (news) (, )

Some key features ::
3D Effects
Custom Filters and Effects
Advanced Text Layout
Enhanced Drawing API
Visual Performance Improvements

You can have a insight on the same here:
http://labs.adobe.com/technologies/flashplayer10/demos/

:) have fun with Flash Player 10 Download the same from
http://www.adobe.com/go/astro/

Permalink Leave a Comment

Image Componet to load swf, images and resize

May 6, 2008 at 12:33 pm (Flex) (, )

Image Componet to load swf, images and resize the same to fit in the container width , height.

Just copy paste the following in a notepad and save it as imageComp.mxml.

<?xml version=”1.0″ encoding=”utf-8″?>

<mx:Canvas xmlns:mx=”http://www.adobe.com/2006/mxml” width=”100%” height=”100%”
styleName=”{style_name}” initialize=”onInit();showLoading(true);”
verticalScrollPolicy=”off” horizontalScrollPolicy=”off” creationComplete=”onAppInit();”>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import flash.utils.setInterval;
import flash.utils.clearInterval;
import mx.events.ResizeEvent;
import mx.controls.Text;

import flash.display.*;
import flash.net.URLRequest;

/**
* This property is used to hold style of this Image Component.
*/
[Bindable]
public var style_name:String = null;

/**
* This property is used to hold URL of the Image.
*/
[Bindable]
private var _image_source:String = null;

private var tempTxt:Text;
private var timer:uint = 0;
private var timerSize:uint = 0 ;

[Bindable]
public function set image_source(str:String):void
{
_image_source = str;
}

public function get image_source():String
{
return _image_source;
}
private function onInit():void
{
if(image_source == “”){
Alert.show(“The image URL is empty.”);
}
dispatchEvent(new Event(“onInit”,true));
}

private function onAppInit():void
{
dispatchEvent(new Event(“CREATION_COMPLETE”,true));
}

private var pictLdr:Loader = new Loader();

private function showLoading(val:Boolean):void
{

if(val)
{
tempTxt = new Text();
tempTxt.text=”Loading…”;
this.canv.addChildAt(tempTxt,1);
tempTxt.x = (this.width/2)-(tempTxt.width/2 );
tempTxt.y = 30;
trace(“Image Source :: “+image_source +” :: Image Holder Intialize ::”);
var pictURL:String = image_source;
// Image is loaded in advance to overcome the resizing issue in cae of crossdomain files access
// the same can be removed if not required.

var pictURLReq:URLRequest = new URLRequest(pictURL);
pictLdr.load(pictURLReq);
pictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);

}else
{
if(this.canv.getChildAt(1) == tempTxt)
this.canv.removeChildAt(1);

}

}
private function imgLoaded(e:Event):void
{
imgControl.source = image_source;
}

private function resize():void
{
clearInterval(timer);
imgControl.visible = true;
imgControl.x = (this.width/2)-(imgControl.width/2 );
imgControl.y = (this.height/2)-(imgControl.height/2);
}
private function resized(e:Event):void
{
imgControl.callLater(resized1);
}

private function resized1():void
{

tempTxt.x = (this.width/2) – 25;
tempTxt.y = (this.height/2) – 25;
imgControl.removeEventListener(ResizeEvent.RESIZE,resized);
timerSize = setInterval(getSizes,5000);
}
private function getSizes():void
{

if(imgControl.width == 0 && imgControl.height == 0){
return
}
trace(“Image Source :: “+image_source +” :: called Resized Event Of Image Component after 5 seconds:: “+imgControl.width+”,”+imgControl.height);
var perRatio:Number;
if (imgControl.width > imgControl.height ) {
if((this.width-8) > imgControl.width){
perRatio = ((this.height – 8)/imgControl.height);
}else{
perRatio = ((this.width-8)/imgControl.width);
}
trace(“Width More perRatio :: “+perRatio);
imgControl.scaleX = imgControl.scaleY = perRatio > 1 ? 1: perRatio;
} else {
if((this.height-8) > imgControl.height){
perRatio = ((this.width-8)/imgControl.width);
}else{
perRatio = ((this.height – 8)/imgControl.height);
}
trace(“Height More perRatio :: “+perRatio);
imgControl.scaleY = imgControl.scaleX = perRatio > 1 ? 1: perRatio;
}

clearInterval(timer);

imgControl.visible = true;

timer = setInterval(resize,2);
clearInterval(timerSize);
}
private function ioErrorFnc(eve:Event):void
{
Alert.show(“Missing Image”);
}
private function setXY():void
{
imgControl.x = (this.width/2)-(imgControl.width/2 );
imgControl.y = (this.height/2)-(imgControl.height/2);
trace(imgControl.x +”-X/Y in getSizes1-”+ imgControl.y)

}
private function getSizes1():void
{
if(timer == 0){
getSizes();
}
setXY();
}

]]>
</mx:Script>

<mx:Canvas id=”canv” >
<mx:Image id=”imgControl” resize=”getSizes1()”
complete=”showLoading(false)” visible=”false” ioError=”ioErrorFnc(event)” />
</mx:Canvas>

</mx:Canvas>

Permalink 6 Comments

Air runtime and Air App wrapper

May 6, 2008 at 8:56 am (Air)

Followings are some of the helpful links which helps in deploying and extending air apps.

http://shu-player.com/
http://www.airaveer.com/
http://ifeedme.com/blog/?p=30

Hope this bit of info is helpful to you :)

Permalink Leave a Comment

Coming up revolution in devices (Open Screen Project)

May 6, 2008 at 5:30 am (news)

As long ago flash player brought revolution in web application the same is going to get repeated with other devices (i.e. televisions, personal computers, mobile devices, and consumer electronics). History repeats :)

Have look at link below for more info.
http://www.adobe.com/openscreenproject/developers/

Permalink Leave a Comment