Tuesday, December 22, 2009

component lifecycle. implementation..

http://livedocs.adobe.com/flex/3/html/help.html?content=ascomponents_advanced_3.html

Monday, December 21, 2009

Good Example For CusomComponent and CustomPopup to..

http://blog.flexexamples.com/2007/08/06/creating-custom-pop-up-windows-with-the-popupmanager-class/

Thursday, December 17, 2009

File Upload Component

http://www.flex888.com/296/9-flex-file-upload-examples-visited.html

PrelaodingImages /swf using custom Preloader





import mx.controls.Alert;
import flash.utils.Timer;
import mx.controls.List;
import mx.collections.ArrayCollection;
import mypack.CustomPreloader;


/**
* Example for Loading Images before Laoding.. Here the images are loaded into images_ary once they are completly loaded using Custom Preloader...
*
* */
public var mycollection:ArrayCollection = new ArrayCollection([
{id: 4, filename: 'amalfi-bw.jpg', width:700, height:400,duration:3000,path:"http://www.themxlab.com/images/wallpaper/wallpaper_main_jpg/the_mx_lab-wallpaper16.jpg"},
{id: 4, filename: 'amalfi-bw.jpg', width:700, height:400,duration:3000,path:"http://www.shrani.si/f/2L/oL/2yFebWXf/bliss-600dpi.jpg"},
{id: 4, filename: 'amalfi-bw.jpg', width:700, height:400,duration:3000,path:"http://www.ultrahd.name/ultrahd_wallpapers/chrome38blue-7680x3200.jpg"},
{id: 4, filename: 'amalfi-bw.jpg', width:700, height:400,duration:3000,path:"http://www.proaerialvideo.com/wallpapers/hawaii.jpg"},
{id: 2, filename: 'Hippo.jpg', width:600, height:400,duration:3000,path:"http://lsst.astro.washington.edu/images/ImageSimColorLarge.jpg"},
{id: 3, filename: 'amalfi.jpg', width:600, height:400,duration:3000,path:"http://helpexamples.com/flash/images/image1.jpg"},
{id: 4, filename: 'amalfi-bw.jpg', width:700, height:400,duration:3000,path:"http://wall-efans.com/images/JPEG/wp-6.jpg"}]);


private var images_ary:ArrayCollection= new ArrayCollection();
private var currentImage:Number=0;
[Bindable] private var timer:Timer
function ImageLoader()
{
for(var i:Number=0;i< mycollection.length;i++)
{ var obj:Object = mycollection.getItemAt(i);
loadImage(obj.path);
}
}

function loadImage(url:String)
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
loader.load(new URLRequest(url));
}

function onImageLoaded(e:Event)
{
var image:LoaderInfo = e.target as LoaderInfo;
// var image:Bitmap =new Bitmap(Bitmap(e.target.content).bitmapData.clone());
images_ary.addItem(image);
currentImage++;
if(currentImage < mycollection.length)
loadImage(mycollection.getItemAt(currentImage).path);
}

function getImages():ArrayCollection
{
return images_ary;
}
private function loadimages()
{
timer= new Timer(5000,images_ary.length);
timer.stop();
timer.start();
timer.addEventListener(TimerEvent.TIMER,callmethod);
}

var temp:int=0;
var l:LoaderInfo;
var myimagecollection:ArrayCollection = new ArrayCollection();

private function callmethod(evt:TimerEvent)
{
/*myimage.addItem(images_ary.pop() as Object);
l = myimage.getItemAt(temp) as LoaderInfo;
Alert.show("BytesLoaded"+l.bytesLoaded);
Alert.show("Total Bytes"+l.bytesTotal);
Alert.show("Bytes"+l.bytes);
imageloader.source = l.content;
temp++;*/
l= images_ary.getItemAt(temp) as LoaderInfo;
imageloader.source = l.content;
temp++;
}
]]>















package mypack
{
import flash.display.*;
import flash.utils.*;
import flash.events.*;
import flash.net.*;
import mx.preloaders.*;
import mx.events.*;

public class CustomPreloader extends Sprite
implements IPreloaderDisplay
{
// Define a Loader control to load the SWF file.
private var dpbImageControl:flash.display.Loader;

public function CustomPreloader() {
super();
}

// Specify the event listeners.
public function set preloader(preloader:Sprite):void {
// Listen for the relevant events
preloader.x = (stage.stageWidth-preloader.width)/2;
preloader.y = (stage.stageHeight-preloader.height)/2;
preloader.addEventListener(
ProgressEvent.PROGRESS, handleProgress);
preloader.addEventListener(
Event.COMPLETE, handleComplete);

preloader.addEventListener(
FlexEvent.INIT_PROGRESS, handleInitProgress);
preloader.addEventListener(
FlexEvent.INIT_COMPLETE, handleInitComplete);
}

// Initialize the Loader control in the override
// of IPreloaderDisplay.initialize().
public function initialize():void {
dpbImageControl = new flash.display.Loader();
dpbImageControl.contentLoaderInfo.addEventListener(
Event.COMPLETE, loader_completeHandler);
dpbImageControl.load(new URLRequest("preloader.swf"));
}

// After the SWF file loads, set the size of the Loader control.
private function loader_completeHandler(event:Event):void
{
addChild(dpbImageControl);
dpbImageControl.width = 50;
dpbImageControl.height= 50;
dpbImageControl.x = 100;
dpbImageControl.y = 100;
}

// Define empty event listeners.
private function handleProgress(event:ProgressEvent):void {

}

private function handleComplete(event:Event):void {
}

private function handleInitProgress(event:Event):void {
}

private function handleInitComplete(event:Event):void {
var timer:Timer = new Timer(2000,1);
timer.addEventListener(TimerEvent.TIMER, dispatchComplete);
timer.start();
}

private function dispatchComplete(event:TimerEvent):void {
dispatchEvent(new Event(Event.COMPLETE));
}

// Implement IPreloaderDisplay interface

public function get backgroundColor():uint {
return 0;
}

public function set backgroundColor(value:uint):void {
}

public function get backgroundAlpha():Number {
return 0;
}

public function set backgroundAlpha(value:Number):void {
}

public function get backgroundImage():Object {
return undefined;
}

public function set backgroundImage(value:Object):void {
}

public function get backgroundSize():String {
return "";
}

public function set backgroundSize(value:String):void {
}

public function get stageWidth():Number {
return stage.width/2;
}

public function set stageWidth(value:Number):void {
}

public function get stageHeight():Number {
return stage.height/2;
}

public function set stageHeight(value:Number):void {
}
}
}

Preloader cool Example

http://askmeflash.com/article_m.php?p=article&id=7

Wednesday, December 16, 2009

PreLoading Images and SWF Files





/**
* Example for Loading Images before Laoding.. Here the images are loaded into images_ary once they are completly loaded...
*
* */

import mx.controls.List;
import mx.collections.ArrayCollection;

public var mycollection:ArrayCollection = new ArrayCollection([
{id: 2, filename: 'Hippo.jpg', width:600, height:400,duration:3000,path:"Hippo.jpg"},
{id: 4, filename: 'amalfi-bw.jpg', width:700, height:400,duration:3000,path:"Hippo.jpg"},
{id: 1, filename: 'Car Abonded', width:400, height:400,duration:3000,path:"Hippo.jpg"}
]);


private var images_ary:Array= new Array();
private var currentImage:Number=0;
function ImageLoader()
{
for(var i:Number=0;i< mycollection.length;i++)
{
var obj:Object = mycollection.getItemAt(i);
loadImage(obj.path);
}
}

function loadImage(url:String)
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
loader.load(new URLRequest(url));
}

function onImageLoaded(e:Event)
{
var image:Object = new Object();
image= e.target as Object;
// var image:Bitmap =new Bitmap(Bitmap(e.target.content).bitmapData.clone());
images_ary.push(image);
currentImage++;
if(currentImage < mycollection.length)
loadImage(mycollection.getItemAt(currentImage).path);
}

function getImages():Array
{
return images_ary;
}

private function loadimages()
{
var temp:int=0;
var l:LoaderInfo;
var myimage:ArrayCollection = new ArrayCollection();
for each(var num in images_ary)
{
myimage.addItem(images_ary.pop() as Object);
l = myimage.getItemAt(temp) as LoaderInfo;
imageloader.source = l.content;
temp++;
}
}

]]>










BiSuite Using Flex..

Hi All,


Any one want to wish to develop a BusinessIntelligenceSuite,Custom REporting using Flex and Open Source Technologies..


Then i am here for u..

Slide show with Effects..





[Event(name="beforeeffect", type="event.SlideshowEvent")]
[Event(name="aftereffect", type="event.SlideshowEvent")]




import mx.events.IndexChangedEvent;
import mx.controls.Alert;
import flash.utils.Timer;
import mx.collections.ArrayCollection;
import event.SlideshowEvent;
import mx.effects.easing.*;
public var count :int=0;



[Bindable] public var myobj:Object = new Object();
private function loadData():void
{

}

[Bindable] public var timer:Timer;
[Bindable] public var _automate:Boolean=false;
public var _dataprovider:ArrayCollection = new ArrayCollection();

// Specified as public since the users can perform any sort of operations as they wish before during the loading of the Component..
public function loaddata():void
{

}

public function set datainput(value:ArrayCollection):void
{
this._dataprovider= value;
}
public function dataprovider():ArrayCollection
{
return _dataprovider;
}

/**
* Automatic is Called When we want the slideShow to be Done Automatically.
* */
private function Automatic():void
{
timer= new Timer(1000,_dataprovider.length);
timer.start();
timer.addEventListener(TimerEvent.TIMER,timerhandler);
}


/**
* Timer Handler is for Triggering all the Elements in the Array.
*
**/
private function timerhandler(evt:TimerEvent):void
{
myobj= _dataprovider.getItemAt(count);
var extension:String = myobj.path;
var filetype:int = extension.lastIndexOf(".");
var extens:String=extension.substr(filetype,extension.length);
if(extens == ".flv")
{
myloader.visible=false;
myloader.includeInLayout=false;
myvideoloader.includeInLayout=true;
myvideoloader.visible=true;
myvideoloader.source = myobj.path;

//Dynamic Setting of Heigh and width of the Image from the Array collection....
//myvideoloader.width=myobj.width;
//myvideoloader.height=myobj.height;
myvideoloader.play();
} else{

//Wasted lot of time without keeping this code in else block.. Since after playing video imeediately swfloader is expecting image and its overlapping video..
// Sice the video is taking abit amount of time to load due to which the delay problem cant be identified immediately..
myvideoloader.stop();
myvideoloader.visible=false;
myvideoloader.includeInLayout=false;
myloader.visible= true;
myloader.includeInLayout=true;

//Dynamic Setting of Heigh and width of the Image from the Array collection....

//myloader.width=myobj.width;
//myloader.height=myobj.height;
myloader.source=myobj.path;
}
if(myobj.duration>0)
{
timer.stop();
calculateDuration(myobj.duration);
}
myimage.text=myobj.filename;
dispatchEvent(new SlideshowEvent(SlideshowEvent.BEFOREPLAY,myobj));
animateEffect(count);
dispatchEvent(new SlideshowEvent(SlideshowEvent.AFTERPLAY,myobj));
count++;
if(count == _dataprovider.length){
count=0;
Automatic();
}

}


/**
* Following Method is for executing the images/swfs/ until its interval specified in the Arraycollection.
* */

private function calculateDuration(duration:int):void
{

var calctimer:Timer = new Timer(duration,1);
calctimer.addEventListener(TimerEvent.TIMER_COMPLETE,completeduration);
calctimer.start();
if(calctimer.running == true){
timer.stop();
}
if(calctimer.running == false){
timer.start();
Alert.show("TimerCount"+timer.currentCount);
}
timer.stop();
}

/**
* Following method is Dispatched when the execution of images/swf/ is done sucessfully and to call the next image from the stack.
* */

private function completeduration(event:TimerEvent):void
{
timer.start();

}
/**
* Switch to Any Slide of your Choice..
* */
private function gotoSlide():void
{
var num:Number = new Number(go.text);
var myobj:Object = _dataprovider.getItemAt(num) as Object;
myloader.source=myobj.path;
}
/**
* To Switch to First Slide.
* */
private function firstScreen():void
{
var myobj:Object = _dataprovider.getItemAt(0) as Object;
myloader.source=myobj.path;

}
/**
* To Switch to Next Slide.
* */
private function nextSlide():void
{
var myobj:Object = _dataprovider.getItemAt(count+1) as Object;
myloader.source=myobj.path;
}

/**
* To Switch to Previous Slide
* */
private function previousSlide():void
{
var myobj:Object = _dataprovider.getItemAt(count-1) as Object;
myloader.source=myobj.path;
}
/**
* Switch to Last Slide..
* */

private function lastSlide():void
{
var myobj:Object = _dataprovider.getItemAt(_dataprovider.length-1) as Object;
myloader.source=myobj.path;
}

public function set automateslide(automate:Boolean):void
{
if(automate == true){
this._automate = true;
Automatic();
}
}

public function get automateslide():Boolean{
return _automate;
}

/**
* Define custom Effects as per the Choice.
* */
private function animateEffect(count:Number):void
{
switch(count)
{
case 0: blur.end(); blur.play(); break;
case 1: fade.end(); fade.play(); break;
case 2: elastic.end(); elastic.play(); break;
case 3: iris.end(); iris.play(); break;
case 4: wipeup.end(); wipeup.play(); break;
case 5: wipedown.end(); wipedown.play(); break;
case 6: wipeleft.end(); wipeleft.play(); break;
case 7: wiperight.end();wiperight.play(); break;
case 8: pulse.end(); pulse.play(); break;
case 9: shake.end(); shake.play(); break;
case 10: spin.end(); spin.play(); break;
case 11: bounce.end(); bounce.play(); break;
case 12: glow.end(); glow.play(); break;


}
}
private function entryAnimation()
{
entranceanimate.stop();
entranceanimate.play();
}
]]>

























































































































































Slide Show with Transitions Using Flex..





[Event(name="beforeeffect", type="event.SlideshowEvent")]
[Event(name="aftereffect", type="event.SlideshowEvent")]




import mx.events.IndexChangedEvent;
import mx.controls.Alert;
import flash.utils.Timer;
import mx.collections.ArrayCollection;
import event.SlideshowEvent;
import mx.effects.easing.*;
public var count :int=0;



[Bindable] public var myobj:Object = new Object();
[Bindable] public var timer:Timer;
[Bindable] public var _automate:Boolean=false;
var evencount:int=0;
var oddcount:int=0;
public var _dataprovider:ArrayCollection = new ArrayCollection();
public var evencollection:ArrayCollection = new ArrayCollection();
public var oddcollection:ArrayCollection = new ArrayCollection();
public var mycollection:ArrayCollection = new ArrayCollection([
{id: 10, filename: 'Falling Stars', width:1000, height:400,duration:10000,path:"falling-stars.swf"},
{id: 2, filename: 'Hippo.jpg', width:600, height:400,duration:3000,path:"http://lsst.astro.washington.edu/images/ImageSimColorLarge.jpg"},
{id: 4, filename: 'amalfi-bw.jpg', width:700, height:400,duration:3000,path:"http://bioinformatics.icmb.utexas.edu/lgl/PHN/phn.large.png"},
{id: 3, filename: 'amalfi.jpg', width:600, height:400,duration:3000,path:"http://helpexamples.com/flash/images/image1.jpg"},
{id: 5, filename: 'EiffelTower.jpg', width:800, height:400,duration:3000,path:"hi1.jpg"},
{id: 6, filename: 'Fountain and Edinburgh Castle.jpg', width:900, height:400,duration:3000,path:"hi2.jpg"},
{id: 7, filename: 'ravello.jpg', width:1000, height:400,duration:7000,path:"ravello.jpg"},
{id: 8, filename: 'nepal1.jpg', width:1000, height:400,duration:7000,path:"nepal1.jpg"},
{id: 9, filename: 'nepal.jpg', width:1000, height:400,duration:1000,path:"nepal2.jpg"},
{id: 10, filename: 'Falling Stars', width:1000, height:400,duration:10000,path:"falling-stars.swf"}]);


private function loadimages():void
{



}


// Specified as public since the users can perform any sort of operations as they wish before during the loading of the Component..
public function loaddata():void
{ _dataprovider=mycollection;


for(var i:Number=0;i<_dataprovider.length;i++)
{
if(i%2==0)
{
evencollection.addItem(_dataprovider.getItemAt(i));

} else if( i%2 !=0){
oddcollection.addItem(_dataprovider.getItemAt(i));
}

}
}
/**
* Automatic is Called When we want the slideShow to be Done Automatically.
* */
private function Automatic():void
{
timer= new Timer(1000,_dataprovider.length);
//` currentState="One";
timer.stop();
timer.start();
timer.addEventListener(TimerEvent.TIMER,timerhandler);
}


/**
* Timer Handler is for Triggering all the Elements in the Array.
*
**/
private function timerhandler(evt:TimerEvent):void
{
var x:Loader = new Loader();

if(count < _dataprovider.length){
if(count %2 ==0){

myobj= evencollection.getItemAt(evencount);
var req:URLRequest = new URLRequest(myobj.path);
x.load(req);
if(x.contentLoaderInfo.bytesLoaded == x.contentLoaderInfo.bytesTotal)
{
Alert.show("All Loaded");
}else{
Alert.show("Not Loaded");
}
var extension:String = myobj.path;
var filetype:int = extension.lastIndexOf(".");
var extens:String=extension.substr(filetype,extension.length);
if(extens == ".flv")
{
currentState="One";
panel1video.includeInLayout=true;
panel1video.visible=true;
animateEffect(count);
panel1video.source = myobj.path;
if(panel1image.percentLoaded == 100){

panel1video.play();
p1.visible=true;
p1.includeInLayout=true;
if(myobj.duration>0)
{
timer.stop();
calculateDuration(myobj.duration);
animateEffect(count);
}
}
//panel2video.stop();
} else{

if(panel1image.percentLoaded==100)
{
Alert.show("Loaded");
}
panel1image.source=myobj.path;
panel1image.visible= true;
panel1image.includeInLayout=true;

p1.visible=true;
p1.includeInLayout=true;
currentState="One";
if(myobj.duration>0)
{
timer.stop();
calculateDuration(myobj.duration);
animateEffect(count);
}
}
evencount++;
count++;
}
else if(count %2!=0){

myobj= oddcollection.getItemAt(oddcount);
if(extens == ".flv")
{
currentState="Two";
panel2video.includeInLayout=true;
panel2video.visible=true;
panel2video.source = myobj.path;
panel2video.play();
animateEffect(count);
p2.visible=true;
p2.includeInLayout=true;
if(myobj.duration>0)
{
timer.stop();
calculateDuration(myobj.duration);
animateEffect(count);
}
}
else{

panel2image.source=myobj.path;
if(panel2image.percentLoaded==100)
{
Alert.show("Loaded");
}else{
Alert.show("Not Loaded");
}
panel2image.visible=true;
panel2image.includeInLayout=true;
p2.visible="true";
p2.includeInLayout=true;
currentState="Two";
if(myobj.duration>0)
{
timer.stop();
calculateDuration(myobj.duration);
}
}
oddcount++;
count++;
}
}
}


/**
* Following Method is for executing the images/swfs/ until its interval specified in the Arraycollection.
* */

private function calculateDuration(duration:int):void
{

var calctimer:Timer = new Timer(duration,1);
calctimer.addEventListener(TimerEvent.TIMER_COMPLETE,completeduration);
calctimer.start();
if(calctimer.running == true){
timer.stop();
}
if(calctimer.running == false){
timer.start();
Alert.show("TimerCount"+timer.currentCount);
}
timer.stop();
}

/**
* Following method is Dispatched when the execution of images/swf/ is done sucessfully and to call the next image from the stack.
* */

private function completeduration(event:TimerEvent):void
{
timer.start();

}
/**
* Switch to Any Slide of your Choice..
* */
private function gotoSlide():void
{
var num:Number = new Number(go.text);
var myobj:Object = _dataprovider.getItemAt(num) as Object;
// myloader.source=myobj.path;
}
/**
* To Switch to First Slide.
* */
private function firstScreen():void
{
var myobj:Object = _dataprovider.getItemAt(0) as Object;
// myloader.source=myobj.path;

}
/**
* To Switch to Next Slide.
* */
private function nextSlide():void
{
var myobj:Object = _dataprovider.getItemAt(count+1) as Object;
// myloader.source=myobj.path;
}

/**
* To Switch to Previous Slide
* */
private function previousSlide():void
{
var myobj:Object = _dataprovider.getItemAt(count-1) as Object;
// myloader.source=myobj.path;
}
/**
* Switch to Last Slide..
* */

private function lastSlide():void
{
var myobj:Object = _dataprovider.getItemAt(_dataprovider.length-1) as Object;
// myloader.source=myobj.path;
}

public function set automateslide(automate:Boolean):void
{
if(automate == true){
this._automate = true;
Automatic();
}
}

public function get automateslide():Boolean{
return _automate;
}

/**
* Define custom Effects as per the Choice.
* */
private function animateEffect(count:Number):void
{
switch(count)
{
case 0: blur.end(); blur.play(); break;
case 1: fade.end(); fade.play(); break;
case 2: elastic.end(); elastic.play(); break;
case 3: iris.end(); iris.play(); break;
case 4: wipeup.end(); wipeup.play(); break;
case 5: wipedown.end(); wipedown.play(); break;
case 6: wipeleft.end(); wipeleft.play(); break;
case 7: wiperight.end();wiperight.play(); break;
case 8: pulse.end(); pulse.play(); break;
case 9: shake.end(); shake.play(); break;
case 10: spin.end(); spin.play(); break;
case 11: bounce.end(); bounce.play(); break;
case 12: glow.end(); glow.play(); break;


}
}



]]>












































































































































x="0" y="0" width="5" height="5"
click="currentState='One'" visible="false" >







x="0" y="110" width="5" height="5"
click="currentState='Two'" visible="false">




























Slide Show with Transitions Using Flex..





[Event(name="beforeeffect", type="event.SlideshowEvent")]
[Event(name="aftereffect", type="event.SlideshowEvent")]




import mx.events.IndexChangedEvent;
import mx.controls.Alert;
import flash.utils.Timer;
import mx.collections.ArrayCollection;
import event.SlideshowEvent;
import mx.effects.easing.*;
public var count :int=0;



[Bindable] public var myobj:Object = new Object();
[Bindable] public var timer:Timer;
[Bindable] public var _automate:Boolean=false;
var evencount:int=0;
var oddcount:int=0;
public var _dataprovider:ArrayCollection = new ArrayCollection();
public var evencollection:ArrayCollection = new ArrayCollection();
public var oddcollection:ArrayCollection = new ArrayCollection();
public var mycollection:ArrayCollection = new ArrayCollection([
{id: 10, filename: 'Falling Stars', width:1000, height:400,duration:10000,path:"falling-stars.swf"},
{id: 2, filename: 'Hippo.jpg', width:600, height:400,duration:3000,path:"http://lsst.astro.washington.edu/images/ImageSimColorLarge.jpg"},
{id: 4, filename: 'amalfi-bw.jpg', width:700, height:400,duration:3000,path:"http://bioinformatics.icmb.utexas.edu/lgl/PHN/phn.large.png"},
{id: 3, filename: 'amalfi.jpg', width:600, height:400,duration:3000,path:"http://helpexamples.com/flash/images/image1.jpg"},
{id: 5, filename: 'EiffelTower.jpg', width:800, height:400,duration:3000,path:"hi1.jpg"},
{id: 6, filename: 'Fountain and Edinburgh Castle.jpg', width:900, height:400,duration:3000,path:"hi2.jpg"},
{id: 7, filename: 'ravello.jpg', width:1000, height:400,duration:7000,path:"ravello.jpg"},
{id: 8, filename: 'nepal1.jpg', width:1000, height:400,duration:7000,path:"nepal1.jpg"},
{id: 9, filename: 'nepal.jpg', width:1000, height:400,duration:1000,path:"nepal2.jpg"},
{id: 10, filename: 'Falling Stars', width:1000, height:400,duration:10000,path:"falling-stars.swf"}]);


private function loadimages():void
{



}


// Specified as public since the users can perform any sort of operations as they wish before during the loading of the Component..
public function loaddata():void
{ _dataprovider=mycollection;


for(var i:Number=0;i<_dataprovider.length;i++)
{
if(i%2==0)
{
evencollection.addItem(_dataprovider.getItemAt(i));

} else if( i%2 !=0){
oddcollection.addItem(_dataprovider.getItemAt(i));
}

}
}
/**
* Automatic is Called When we want the slideShow to be Done Automatically.
* */
private function Automatic():void
{
timer= new Timer(1000,_dataprovider.length);
//` currentState="One";
timer.stop();
timer.start();
timer.addEventListener(TimerEvent.TIMER,timerhandler);
}


/**
* Timer Handler is for Triggering all the Elements in the Array.
*
**/
private function timerhandler(evt:TimerEvent):void
{
var x:Loader = new Loader();

if(count < _dataprovider.length){
if(count %2 ==0){

myobj= evencollection.getItemAt(evencount);
var req:URLRequest = new URLRequest(myobj.path);
x.load(req);
if(x.contentLoaderInfo.bytesLoaded == x.contentLoaderInfo.bytesTotal)
{
Alert.show("All Loaded");
}else{
Alert.show("Not Loaded");
}
var extension:String = myobj.path;
var filetype:int = extension.lastIndexOf(".");
var extens:String=extension.substr(filetype,extension.length);
if(extens == ".flv")
{
currentState="One";
panel1video.includeInLayout=true;
panel1video.visible=true;
animateEffect(count);
panel1video.source = myobj.path;
if(panel1image.percentLoaded == 100){

panel1video.play();
p1.visible=true;
p1.includeInLayout=true;
if(myobj.duration>0)
{
timer.stop();
calculateDuration(myobj.duration);
animateEffect(count);
}
}
//panel2video.stop();
} else{

if(panel1image.percentLoaded==100)
{
Alert.show("Loaded");
}
panel1image.source=myobj.path;
panel1image.visible= true;
panel1image.includeInLayout=true;

p1.visible=true;
p1.includeInLayout=true;
currentState="One";
if(myobj.duration>0)
{
timer.stop();
calculateDuration(myobj.duration);
animateEffect(count);
}
}
evencount++;
count++;
}
else if(count %2!=0){

myobj= oddcollection.getItemAt(oddcount);
if(extens == ".flv")
{
currentState="Two";
panel2video.includeInLayout=true;
panel2video.visible=true;
panel2video.source = myobj.path;
panel2video.play();
animateEffect(count);
p2.visible=true;
p2.includeInLayout=true;
if(myobj.duration>0)
{
timer.stop();
calculateDuration(myobj.duration);
animateEffect(count);
}
}
else{

panel2image.source=myobj.path;
if(panel2image.percentLoaded==100)
{
Alert.show("Loaded");
}else{
Alert.show("Not Loaded");
}
panel2image.visible=true;
panel2image.includeInLayout=true;
p2.visible="true";
p2.includeInLayout=true;
currentState="Two";
if(myobj.duration>0)
{
timer.stop();
calculateDuration(myobj.duration);
}
}
oddcount++;
count++;
}
}
}


/**
* Following Method is for executing the images/swfs/ until its interval specified in the Arraycollection.
* */

private function calculateDuration(duration:int):void
{

var calctimer:Timer = new Timer(duration,1);
calctimer.addEventListener(TimerEvent.TIMER_COMPLETE,completeduration);
calctimer.start();
if(calctimer.running == true){
timer.stop();
}
if(calctimer.running == false){
timer.start();
Alert.show("TimerCount"+timer.currentCount);
}
timer.stop();
}

/**
* Following method is Dispatched when the execution of images/swf/ is done sucessfully and to call the next image from the stack.
* */

private function completeduration(event:TimerEvent):void
{
timer.start();

}
/**
* Switch to Any Slide of your Choice..
* */
private function gotoSlide():void
{
var num:Number = new Number(go.text);
var myobj:Object = _dataprovider.getItemAt(num) as Object;
// myloader.source=myobj.path;
}
/**
* To Switch to First Slide.
* */
private function firstScreen():void
{
var myobj:Object = _dataprovider.getItemAt(0) as Object;
// myloader.source=myobj.path;

}
/**
* To Switch to Next Slide.
* */
private function nextSlide():void
{
var myobj:Object = _dataprovider.getItemAt(count+1) as Object;
// myloader.source=myobj.path;
}

/**
* To Switch to Previous Slide
* */
private function previousSlide():void
{
var myobj:Object = _dataprovider.getItemAt(count-1) as Object;
// myloader.source=myobj.path;
}
/**
* Switch to Last Slide..
* */

private function lastSlide():void
{
var myobj:Object = _dataprovider.getItemAt(_dataprovider.length-1) as Object;
// myloader.source=myobj.path;
}

public function set automateslide(automate:Boolean):void
{
if(automate == true){
this._automate = true;
Automatic();
}
}

public function get automateslide():Boolean{
return _automate;
}

/**
* Define custom Effects as per the Choice.
* */
private function animateEffect(count:Number):void
{
switch(count)
{
case 0: blur.end(); blur.play(); break;
case 1: fade.end(); fade.play(); break;
case 2: elastic.end(); elastic.play(); break;
case 3: iris.end(); iris.play(); break;
case 4: wipeup.end(); wipeup.play(); break;
case 5: wipedown.end(); wipedown.play(); break;
case 6: wipeleft.end(); wipeleft.play(); break;
case 7: wiperight.end();wiperight.play(); break;
case 8: pulse.end(); pulse.play(); break;
case 9: shake.end(); shake.play(); break;
case 10: spin.end(); spin.play(); break;
case 11: bounce.end(); bounce.play(); break;
case 12: glow.end(); glow.play(); break;


}
}



]]>












































































































































x="0" y="0" width="5" height="5"
click="currentState='One'" visible="false" >







x="0" y="110" width="5" height="5"
click="currentState='Two'" visible="false">




























Preloading Loading Images using Flex from ArrayCollection.





import mx.controls.List;
import mx.collections.ArrayCollection;

public var mycollection:ArrayCollection = new ArrayCollection([
{id: 2, filename: 'Hippo.jpg', width:600, height:400,duration:3000,path:"http://lsst.astro.washington.edu/images/ImageSimColorLarge.jpg"},
{id: 4, filename: 'amalfi-bw.jpg', width:700, height:400,duration:3000,path:"http://bioinformatics.icmb.utexas.edu/lgl/PHN/phn.large.png"},
{id: 3, filename: 'amalfi.jpg', width:600, height:400,duration:3000,path:"http://helpexamples.com/flash/images/image1.jpg"},
{id: 1, filename: 'Car Abonded', width:400, height:400,duration:3000,path:"abandoned car.jpg"},
{id: 3, filename: 'Hippo.jpg', width:600, height:400,duration:3000,path:"Hippo.jpg"}]);


private var images_ary:Array= new Array();
private var currentImage:Number=0;
function ImageLoader()

{
for(var i:Number=0;i< mycollection.length;i++)
{
var obj:Object = mycollection.getItemAt(i);
loadImage(obj.path);
}

}

function loadImage(url:String)
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
loader.load(new URLRequest(url));
}

function onImageLoaded(e:Event)
{
var image:Bitmap =new Bitmap(Bitmap(e.target.content).bitmapData.clone());
images_ary.push(image);
currentImage++;
if(currentImage < mycollection.length)
loadImage(mycollection.getItemAt(currentImage).path);
}

function getImages():Array
{
return images_ary;
}

private function loadimages()
{

var myimage:ArrayCollection = new ArrayCollection();
for each(var num in images_ary)
{
myimage.addItem(images_ary.pop() as Object);
imageloader.source = myimage.getItemAt(num) ;
}
}


]]>










Tuesday, December 15, 2009

Wednesday, December 9, 2009

simple slideshow using flex




import mx.events.IndexChangedEvent;
import mx.controls.Alert;
import flash.utils.Timer;
import mx.collections.ArrayCollection;
import event.SlideshowEvent;
import mx.effects.easing.*;
public var count :int=0;

public var mycollection:ArrayCollection = new ArrayCollection([
{id: 1, filename: 'Car Abonded', width:400, height:400,duration:3000,path:"abandoned car.jpg"},
{id: 2, filename: 'first.flv', width:500, height:400,duration:10000,path:"first.flv"},
{id: 3, filename: 'amalfi.jpg', width:600, height:400,duration:3000,path:"amalfi.jpg"},
{id: 4, filename: 'amalfi-bw.jpg', width:700, height:400,duration:3000,path:"amalfi-bw.jpg"},
{id: 5, filename: 'EiffelTower.jpg', width:800, height:400,duration:3000,path:"EiffelTower.jpg"},
{id: 6, filename: 'Fountain and Edinburgh Castle.jpg', width:900, height:400,duration:3000,path:"Fountain and Edinburgh Castle.jpg"},
{id: 7, filename: 'Hippo.jpg', width:1000, height:400,duration:3000,path:"Hippo.jpg"},
{id: 8, filename: 'bubbles Animation', width:1000, height:400,duration:3000,path:"bubbles.swf"},
{id: 9, filename: 'Falling Stars', width:1000, height:400,duration:6000,path:"falling-stars.swf"},
{id: 10, filename: 'Falling Stars', width:1000, height:400,duration:10000,path:"falling-stars.swf"}]);

[Bindable] public var myobj:Object = new Object();
private function loadData():void
{

}

[Bindable] public var timer:Timer;
private var _automate:Boolean;

/**
* Automatic is Called When we want the slideShow to be Done Automatically.
* */

private function Automatic():void
{
timer= new Timer(1000,mycollection.length);
timer.start();
timer.addEventListener(TimerEvent.TIMER,timerhandler);
}


/**
* Timer Handler is for Triggering all the Elements in the Array.
*
**/
private function timerhandler(evt:TimerEvent):void
{
myobj= mycollection.getItemAt(count);
var extension:String = myobj.path;
var filetype:int = extension.lastIndexOf(".");
var extens:String=extension.substr(filetype,extension.length);
if(extens == ".flv")
{
myloader.visible=false;
myvideoloader.visible=true;
myvideoloader.source = "http://www.helpexamples.com/flash/video/caption_video.flv";
super.invalidateProperties();
myvideoloader.autoPlay=true;
}
//myvideoloader.stop();
myvideoloader.visible=false;
myloader.visible= true;
//Dynamic Setting of Heigh and width of the Image from the Array collection....
//myloader.width=myobj.width;
//myloader.height=myobj.height;
myloader.source=myobj.path;

if(myobj.duration>0)
{
timer.stop();
calculateDuration(myobj.duration);
}
myimage.text=myobj.filename;
animateEffect(count);
count++;
if(count == mycollection.length){
count=0;
Automatic();
}

}
/**
* Following Method is for executing the images/swfs/ until its interval specified in the Arraycollection.
* */

private function calculateDuration(duration:int):void
{
var calctimer:Timer = new Timer(duration,1);
calctimer.addEventListener(TimerEvent.TIMER_COMPLETE,completeduration);
calctimer.start();
if(calctimer.running == true){
timer.stop();
}
if(calctimer.running == false){
timer.start();
}
timer.stop();
}

/**
* Following method is Dispatched when the execution of images/swf/ is done sucessfully and to call the next image from the stack.
* */

private function completeduration(event:TimerEvent)
{
timer.start();

}
/**
* Switch to Any Slide of your Choice..
* */
private function gotoSlide():void
{
var num:Number = new Number(go.text);
var myobj:Object = mycollection.getItemAt(num) as Object;
myloader.source=myobj.path;
}
/**
* To Switch to First Slide.
* */
private function firstScreen():void
{
var myobj:Object = mycollection.getItemAt(0) as Object;
myloader.source=myobj.path;

}
/**
* To Switch to Next Slide.
* */
private function nextSlide():void
{
var myobj:Object = mycollection.getItemAt(count+1) as Object;
myloader.source=myobj.path;
}

/**
* To Switch to Previous Slide
* */
private function previousSlide():void
{
var myobj:Object = mycollection.getItemAt(count-1) as Object;
myloader.source=myobj.path;
}
/**
* Switch to Last Slide..
* */

private function lastSlide()
{
var myobj:Object = mycollection.getItemAt(mycollection.length-1) as Object;
myloader.source=myobj.path;
}

private function set automate(automate:Boolean)
{
if(automate == true)
{
_automate = true;
Automatic();
}
}

public function get automate():Boolean{
return _automate;
}

/**
* Define custom Effects as per the Choice.
* */
private function animateEffect(count:Number)
{
switch(count)
{
case 0: blur.end(); blur.play(); break;
case 1: fade.end(); fade.play(); break;
case 2: elastic.end(); elastic.play(); break;
case 3: iris.end(); iris.play(); break;
case 4: wipeup.end(); wipeup.play(); break;
case 5: wipedown.end(); wipedown.play(); break;
case 6: wipeleft.end(); wipeleft.play(); break;
case 7: wiperight.end();wiperight.play(); break;
case 8: pulse.end(); pulse.play(); break;
case 9: shake.end(); shake.play(); break;
case 10: spin.end(); spin.play(); break;
case 11: bounce.end(); bounce.play(); break;
case 12: glow.end(); glow.play(); break;


}
}

]]>




















































































































Thursday, December 3, 2009

cool Example for Animation in TileList using Images

http://blog.flexexamples.com/wp-content/uploads/TileList_dataChangeEffect_test/bin/srcview/index.html

Custom Style at Runtime Loading..





import mx.effects.Fade;
import mx.core.Application;
import flash.trace.Trace;
import mx.controls.Alert;
private function colorselectionHandler():void
{
var themecolor:String=themechanger.selectedItem as String;
Application.application.applyRuntimeStyleSheet(themecolor);
}
private function readXML():void
{

}

]]>












Green
Blue




















Loading Flex Styles/swf Dynamically.




import mx.controls.Alert;
import mx.styles.StyleManager;

public function applyRuntimeStyleSheet(stylecolor:String):void {
StyleManager.loadStyleDeclarations(stylecolor+".swf",true)
}
]]>




















------------------------------------




import mx.effects.Fade;
import mx.core.Application;
import flash.trace.Trace;
import mx.controls.Alert;
private function colorselectionHandler():void
{
var themecolor:String=themechanger.selectedItem as String;
Application.application.applyRuntimeStyleSheet(themecolor);
}
private function readXML():void
{

}

]]>












Green
Blue

































-----------------------------------
Green.css
Panel {
borderColor: #6666ff;
borderAlpha: 0.21;
roundedBottomCorners: false;
cornerRadius: 9;
headerHeight: 21;
backgroundAlpha: 1;
headerColors: #6666ff, #ff66ff;
footerColors: #6666ff, #ff33cc;
backgroundColor: #ffffff;
shadowDistance: 4;
shadowDirection: left;
dropShadowColor: #33000d;
}

Tuesday, July 21, 2009

Mondrian Flex OlapReport

Hai

Every Body The most awaiting Task mondrian with flex is completed i will post you shortly..