독도 광고 모금 캠페인


StreamingAMF를 이용하여 Data Push 하는 예제입니다.

--> 여기 <-- 를 클릭하세요.
Posted by 이현호
,

BlazeDS에서는 RMTP프로토콜이 지원이 안됩니다.

대신 Polling과 Pushing 을 위해서 PollingAMF 와 StreamingAMF가 존재 합니다.

이에 대한 차이점에 대한 글 포스트입니다.

자세한건 -> 여기 <- 를 클릭하면됩니다.
Posted by 이현호
,

우리 회사에서는 아예 페이징에 대한 컴포넌트를 만들어서 값을 던질수 있게 했는데 이것도 역시 방법이 되겠네요..

ADN FLEX COOKBOOK에 올라온 내용입니다.

COOKBOOK 가보실려면 여기 로 가보세요.

Paged ArrayCollection

by PeterMolgaard on October 6, 2008 Avg Rating 2.5 (2)   |   Log in to rate post.

Tagged with ActionScript

Problem Summary

ArrayCollection does not support paging

Solution Summary

Adding properties such as "pageSize", "numberOfPages" and "lengthTotal" to the existing ArrayCollection and implementing a filterfunction supporting paging gives a simple pagination addition to the existing ArrayCollection class.

Explanation

Yesterday one of the developers in my company had the need for a PagedArrayCollection. A quick search on Google revealed only this implementation, which turned out to be buggy so I decided to implement one myself.

I designed an interface called IPagedCollection which in combination with an extension of the existing mx.collections.ArrayCollection implementation would do the job.

Only hurdle was the need to override addItemAt and removeItemAt as the autoUpdate doesn’t seem to work when a filterFunction is employed. I will look in to this phenomena, but as for now a call to refresh after inserting or removing does the job nicely.

The code itself is quite simple, I have also created a small demo-application which illustrates the use of the collection.

Live Demo

Download of Sources

**
* Copyright(c) 2008 HelloGroup A/S, some rights reserved.
* Your reuse is governed by the Creative Commons Attribution 3.0 Denmark License
**/
package com.hello.collections
{
    public interface IPagedArrayCollection
    {
        function get currentPage() : Number;
        function set currentPage( value:Number ) : void;
        function get numberOfPages() : Number;
        function get pageSize() : Number;
        function set pageSize( value:Number ) : void;
        function get lengthTotal() : Number;
    }
}

/**
* Copyright(c) 2008 HelloGroup A/S, some rights reserved.
* Your reuse is governed by the Creative Commons Attribution 3.0 Denmark License
*
* Known Issues:
* - When the collection changes in size or pagesize, the currentPage is not updated.
*   This is a problem if currentPage is set to a higher value than in the new collection.
**/
package com.hello.collections
{
    import mx.collections.ArrayCollection;
    import mx.events.CollectionEvent;

    public class PagedArrayCollection extends ArrayCollection implements IPagedArrayCollection
    {
        private var _currentPage:Number = 1;
        private var _numberOfPages:Number = 1;
        private var _pageSize:Number = 10;
        
        public function PagedArrayCollection( source:Array=null )
        {
            super( source );
            filterFunction = filterData;
            addEventListener( CollectionEvent.COLLECTION_CHANGE, onChange );
        }  

        /**
        * Adds an item to the collection at the specified index.
        *
        * @param item Item to be added
        * @param index Index of the item to be added
        *
        * Note: Needs to be overridden in order to trigger refresh.
        *        AddItem eventually calls this function so its not needed to override addItem
        **/
        override public function addItemAt( item:Object, index:int ) : void
        {
            super.addItemAt( item, index );
            refresh();
        }

        /**
        * Removes the item from the collection at the specified index
        *
        * @param index Index of the item to be removed
        * @return The item removed
        *
        * Note: Needs to be overridden in order to trigger refresh
        **/
        override public function removeItemAt( index:int ) : Object
        {
            var removedItem:Object = super.removeItemAt( index );
            refresh();
            return removedItem;
        }

        protected function onChange( event:CollectionEvent ) : void
        {
            if( _numberOfPages != numberOfPages )
            {
                _numberOfPages = numberOfPages;
                onPagingChange( PagedCollectionEventKind.NUMBEROFPAGES_CHANGE );
            }
        }
        
        protected function onPagingChange( kind:String ) : void
        {
            dispatchEvent( new CollectionEvent( CollectionEvent.COLLECTION_CHANGE, false, false, kind ) );
        }  

        [ChangeEvent("collectionChange")]
        public function get currentPage() : Number
        {
            return _currentPage;
        }
        
        public function set currentPage( value:Number ) : void
        {
            _currentPage = value;
            refresh();
            onPagingChange( PagedCollectionEventKind.CURRENTPAGE_CHANGE );
        }

        [ChangeEvent("collectionChange")]
        public function get numberOfPages() : Number
        {
            var result:Number = source.length / pageSize;
            result = Math.ceil( result );
            return result;
        }
        
        [ChangeEvent("collectionChange")]
        public function get pageSize() : Number
        {
            return _pageSize;
        }
        
        public function set pageSize( value:Number ) : void
        {
            _pageSize = value;
            refresh();
            onPagingChange( PagedCollectionEventKind.PAGESIZE_CHANGE );
        }

        [ChangeEvent("collectionChange")]
        public function get lengthTotal() : Number
        {
            return source.length;
        }

        private function filterData( item:Object ) : Boolean
        {
            var dataWindowCeiling:Number = pageSize * currentPage;
            var dataWindowFloor:Number = dataWindowCeiling - pageSize;
            
            var itemIndex:Number = getItemIndex( item );
            var result:Boolean = dataWindowFloor <= itemIndex && itemIndex < dataWindowCeiling;
            
            return result;
        }
    }
}

/**
* Copyright(c) 2008 HelloGroup A/S, some rights reserved.
* Your reuse is governed by the Creative Commons Attribution 3.0 Denmark License
**/
package com.hello.collections
{
    public class PagedCollectionEventKind
    {
        public static const CURRENTPAGE_CHANGE:String = "currentPageChange";
        public static const PAGESIZE_CHANGE:String = "pageSizeChange";
        public static const NUMBEROFPAGES_CHANGE:String = "numberOfPagesChange";
    }
}


This is the small demo-application which illustrates and validates that the collection works.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical"
    initialize="onInitialize(event)"
    creationComplete="onCreationComplete(event)">

    <mx:HBox width="100%">
        <mx:Label text="Key:" />
        <mx:TextInput id="keyInput" text="NEW KEY" />
        <mx:Label text="Value:" />
        <mx:TextInput id="valueInput" text="NEW VALUE" />
        <mx:Button id="addButton" label="Add Item" />
        <mx:Button id="removeButton" label="Remove Item" enabled="{ grid.selectedItem != null }" />
        <mx:Label text="Set PageSize:" />
        <mx:ComboBox id="pageSizeSelector" dataProvider="{ [ 5, 10, 25] }" selectedIndex="1" change="{ collection.pageSize = Number( pageSizeSelector.value ) }" />
    </mx:HBox>
    
    <mx:DataGrid id="grid" dataProvider="{ collection }" width="100%" height="100%" />
    
    <mx:HBox>
        <mx:Label text="Count: { collection.length } ({ collection.lengthTotal })" />
        <mx:Label text="( { collection.currentPage }/{ collection.numberOfPages } )" />
        <mx:Label text="PageSize: { collection.pageSize }" />
        <mx:Button label="Previous" enabled="{ collection.currentPage > 1 }" click="{ collection.currentPage-- }" />
        <mx:Button label="Next" enabled="{ collection.numberOfPages > collection.currentPage }" click="{ collection.currentPage++ }" />
    </mx:HBox>  

    <mx:Script>
    <![CDATA[
    
    import mx.events.CollectionEvent;
    import mx.events.FlexEvent;
    import com.hello.collections.PagedArrayCollection;

    [Bindable]
    private var collection:PagedArrayCollection;
    
    private function onInitialize( event:FlexEvent ) : void
    {
        var collection:Array = new Array();
        for( var i:Number = 1; i <= 20; i++ )
        {
            collection.push( { key:"Item_Key_"+ i, value:"Item_Value_"+ i } );
        }
        this.collection = new PagedArrayCollection( collection );
        this.collection.addEventListener( CollectionEvent.COLLECTION_CHANGE, onItemsChange );
        this.collection.refresh();
    }
        
    private function onCreationComplete( event:FlexEvent ) : void
    {
        addButton.addEventListener( MouseEvent.CLICK, addButton_Click );
        removeButton.addEventListener( MouseEvent.CLICK, removeButton_Click );
    }

    private function addButton_Click( event:MouseEvent ) : void
    {
        collection.addItem( { key:keyInput.text, value:valueInput.text } );
    }

    private function removeButton_Click( event:MouseEvent ) : void
    {
        collection.removeItemAt( collection.getItemIndex( grid.selectedItem ) );
    }

    private function onItemsChange( event:CollectionEvent ) : void
    {
        trace( event.kind +" collectionchanged" );
    }

    ]]>
    </mx:Script>
    
</mx:Application>

Posted by 이현호
,
Flash & Flex Free Components and Source Files

여기 클릭하세요.

말그대로임....

트랙백이나 위에 클릭해서 가시면됩니다.
Posted by 이현호
,

이것도 역시 Flash enabled Blog에서 퍼왔습니다.

시간순서상으로는 이게 먼저 포스트 된거지만 제가 읽은게 지금이라서.. ^^;;

PS : Trackback이 자꾸 실패나서 홈페이지 Link겁니다.

--> Blog 가기 <--



One cool thing you can do in Flash and Flex, is to create custom classes in order to help you to repeat certain tasks in a easily manner. Today i show you a collection of some cool custom classes, which can help you to develop more and faster.

SoundManager

The SoundManager is a Singleton that does exactly what it says. It has a host of methods to choose from that should make adding sounds to your projects super simple. It has a dependency to TweenLite for the sound fading

Active Window Blur

Blurs a background (MovieClip or Sprite) behind a transparent window (MovieClip or Sprite).

TweenMax

TweenMax builds on top of the TweenLite core class and its big brother, TweenFilterLite, to round out the tweening family with popular (though not essential) features like bezier tweening, pause/resume capabilities, easier sequencing, hex color tweening, and more.

YouTube

A simple light class to connect to the YouTube gdata API and source playlists and featured videos.

Pulse Particles

Pulse Particles is a general purpose AS3 particle system.

Animated Bitmap

The AnimatedBitmap class provides functionality for Bitmap objects that are animated by using a series of still images. When creating a new AnimatedBitmap you provide a BitmapData object that contains an image that consists of the ’single-frame’ images for the animation.

QueueLoader

The QueueLoader is an actionscript library for sequential asset loading and monitoring. QueueLoader is designed to be used with Actionscript 3.0 and has become an open source project. If you are interested in contributing please contact the project leader.

Prioritization

The url prioritization class, it works with Loader, URLLoader, and Sound Objects (and maybe NetStream objects one day). This will let you set a priority for requests so they execute in the right order, take a look at currently executing requests or loading requests.

DistortImage

An updated version of the original DistortImage class for AS2, which allows you to programmatically distort images.

Layout class

This class - rather, a collection of 3: Layout, LayoutConstraint, and LayoutManager - provide that functionality to objects in Flash CS3 through ActionScript 3 using a somewhat similar API (though ActionScript only, no authoring interface). Using these classes you can constrain objects to the top, right, bottom, left, or center them horizontally or vertically within a layout. There are also controls for height and width as well as a property for maintaining aspect ratio.

Color Sampler Class

Color sampling engine for DisplayObjects. Takes a defined sample area (width, height, x, y) of a BitmapData object and computes the average color within the area. The RGB, red channel, green channel, blue channel, hue, saturation, and brightness values are stored from the sample.

2D Character Rigging Classes

The AS 3 rigging classes are used for skelton rigging and skinning of 2D characters. The rigging class library is organized around the development of highly specific articulated rigs. The current focus is on humaniod bipedal characters.

XML Loader Class

AS3 XML loader

StyleCollection

The StyleCollection class lets you create groups of styles that are applied to and automatically updated on subscribing components. It supports both instance and renderer styles (setStyle and setRendererStyle respectively), and uses component introspection to apply only relevant styles to each component. StyleCollection exposes a robust interface, including a static interface that provides global access to named styles.

Easing

Easing is a Singleton that lets you do dynamic point-to-point property tweening. It is able to manipulate virtually any property of any object on or off the stage.

CSSLoader

The class enables you to load CSS files into your flex application during runtime, a functionality Actionscript3.0 lacks.

Autocomplete Text Field

Create an automcplete text field in an AS 3 project.

fZIP

A little Actionscript 3 class that enables you to load standard ZIP archives and extract contained files while the archive is still loading.

Reflection Class

Generate reflections from images


Posted by 이현호
,
에... 맘에 드는 컴포넌트들입니다만... 사실 몇몇개는 회사에서도 유용성에서 생각해본적이
있습니다만.. 코드가 워낙 크다보니 적용에 대하여 보류한적이 있네요..

퍼왔습니다. 밑에 있습니다만 Flash Enabled Blog 에서요..

One of the most searched entries at Flash Enabled Blog is the Flex Calendar. Therefore i decided today to present you a collection of cool Calendars with source available so you can research and customize for your own needs. Feel free to drop a line with your own Flex Calendars and i will make sure to feature them here.

Download source

Download Source

Download Source

Download Source

Download Source


Posted by 이현호
,
flex.org 에서 DZone의 최근글들을 보면 잼있는게 가끔 얻어걸립니다.

영어는 짧지만 대강 보면 재미있다는 생각이 드는 것들이 생깁니다.

이번에는 말그대로 트리구조를 화면에 그릴때 Recursion으로 그리는 겁니다.

안타깝게도 소스가 fla 인지라... 제가 뭐라더 설명하기는 어렵네요..

뭐 코드는 대강 이렇다라고 설명이 되어도 그리는 부분이 섞여있거나하면 쥐약인지라.. ㅡ.ㅡ;

Recursion은 재귀호출 정도로 해석되던가요.. 뭐하여간 그런겁니다. 어떤 끝나는 시점의
조건을 만날때까지 자기스스로를 호출하는 것이라고 합니다만....

나머진 구글링 하세요. ^^;;

PS. Recursion Function에 대해서는  n! 을 구하는 예제나 다른 예제 보시기 바랍니다.

--> Programatically Drawing Trees With Recursion <--
Posted by 이현호
,
이번 내용은 AIR로 만들어진 기업용(?) 프로그램들에 대한 소개글입니다.

뭐 AIR를 이용하면 C/S 환경을 좀더 RICH하게 한다.. 뭐 그런 요지입니다만

소개 되는 애들은 군침이 흐릅니다. ㅋㅋ

--> Adobe AIR Goes to Work: 6 Apps for the Corporate Desktop <--
Posted by 이현호
,