Todd Rothe : Adobe Flex / AS3 Developer

it's pronounced rowth-ee

ASMock QuickStart

Mocking objects for tests is standard practice. Recently I had the chance to suport a jr. dev in using FlexUnit 4 and ASMock. Here are the errors she ran into while getting started.

1. ArgumentError: A proxy for com.client.product.models::MyModel has not been prepared yet

At the start of the class you will need the Mock metadata tag with a reference to the class MyModel
[Mock("com.models.MyModel")]
public class PreviewBookViewTest
{ …

2. ArgumentError: A proxy for com.client.product.models::MyModel has not been prepared yet

The [Before] metadata tag was in place

[Before]
public function setUp():void
{
_mockRepo = new MockRepository();
_myModel = _mockRepo.createDynamic(MyModel) as MyModel;
}

but the [RunWith] metadata tag was missing from the start of the class

[Mock("com.models.MyModel")]
[RunWith("asmock.integration.flexunit.ASMockClassRunner")]
public class PreviewViewTest
{ …

more posts at www.toddrothe.com/blog

 

Using UIImpersonator with FlexUnit 4

While testing Spark based custom components I discovered UIImpersonator in FlexUnit 4. Then I nearly strangled UIImpersonator. Here are the issues I ran into, my initial code, and how to resolve the issues.

Issues:
1. Error: Required skin part myRequiredSkinPart cannot be found.
2. Skin for FlexVisualTestEnvironment47.MyView38.MyViewSkin49.contentGroup.myStream._MyStreamSkin_MyRenderer1 cannot be found.

Initial Code:
[Before(async)]
public function setUp():void
{
_target = new MyView();
Async.proceedOnEvent( this, _target, FlexEvent.CREATION_COMPLETE );
UIImpersonator.addChild( _target );
}
[Test(async)]
public function getSetProp():void
{
var _prop:Prop = new Prop();
_target.prop = _prop;
assertThat( _target.prop, sameInstance( _prop ) );
}

Resolutions:
The first error I ran into was this :
1. Error: Required skin part myRequiredSkinPart cannot be found.

Issue : The power of UIImpersonator is that it instantiates your component in isolation, outside of the scope of your application. Therefore css based styles are NOT applied. In my case this meant that my component skin was not applied to my component. When testing using UIImpersonator you need to manually add the skin for your UIComponent.

Fix : Manually set the skinClass style on you component.
_targetSkin = new MyViewSkin();
_target.setStyle( “skinClass”, Class(MyViewSkin) );

The second error I hit was :
2. Error: Skin for FlexVisualTestEnvironment47.MyView38.MyViewSkin49.contentGroup.myStream._MyStreamSkin_MyRenderer1 cannot be found.

Issue : Same issue as before only now the skin that is missing is many components deep.

Fix : Don’t use IUImpersonator for complex composite custom components.

UIImpersonator ensures your test environment is completely separate from the FlexUnit application environment. While this can be useful at times it is often more trouble than it’s worth.

more posts at www.toddrothe.com/blog

 

ItemRendererFunction : Two Styles in One List

Using the ItemRendererFunction on a DataGroup or SkinnableDataContainer allows you to select the appropriate item renderer for different types of data on the fly.

Here is an example using one dataProvider to display two different types of data in two different styles in one list.

 

Download the project to see the full source.
See the same two item renderers near the top of the script tag that were mentioned in the previous post.
import com.toddrothe.renderers.ContactsItemRenderer; // TR: item renderer
import com.toddrothe.renderers.GroupsItemRenderer; // TR: item renderer

Note the objects in the array collection used as dataProviders for the DataGroup contain different ‘type’ values – contact and group.
[Bindable]
protected var mixedData:ArrayCollection = new ArrayCollection([{'type':'contact','id':64, 'name':'Josh Tynjala', 'image':'images/jt.png'},{'type':'group','id':0,'name':'My First Group','content':'various media'},{'type':'contact','id':140, 'name':'Peter C.', 'image':'images/pc.png'},{'type':'group','id':12,'name':'Another Group','content':'video'},{'type':'contact','id':64, 'name':'Brendan', 'image':'images/bl.png'}]);

Below that you will see the same item renderer function used in the previous post which changes the item renderer depending on the item.type value – contact and group..
protected function getItemRenderer(item:Object):IFactory // TR: item renderer func decides which item renderer to use
{
var myRendererClass:Class;
switch( item.type )
{
case "group":
myRendererClass = GroupsItemRenderer;
break;
case "contact":
myRendererClass = ContactsItemRenderer;
break;
}
return new ClassFactory( myRendererClass );
}

And finally the DataGroup with the itemRendererFunction and initial dataProvider value defined.
<s:DataGroup id="myDataGroup" itemRendererFunction="getItemRenderer"
dataProvider="{mixedData}" >

more posts at www.toddrothe.com/blog

 

ItemRendererFunction : One List, Two DataProviders

Using the ItemRendererFunction on a DataGroup or SkinnableDataContainer allows you to reuse said group, selecting the appropriate item renderer for different types of data.

Here is an ItemRendererFunction example using one list to display two separate data sets in two different styles.

 

Download the project to see the full source.
See the two item renderers near the top of the script tag.
import com.toddrothe.renderers.ContactsItemRenderer; // TR: item renderer
import com.toddrothe.renderers.GroupsItemRenderer; // TR: item renderer

Note the two array collections used as dataProviders for the DataGroup.
[Bindable]
protected var contactsData:ArrayCollection = new ArrayCollection([{'type':'contact','id':64, 'name':'Josh Tynjala', 'image':'images/jt.png'},{'type':'contact','id':140, 'name':'Peter C.', 'image':'images/pc.png'},{'type':'contact','id':64, 'name':'Brendan', 'image':'images/bl.png'}]);

[Bindable]
protected var groupsData:ArrayCollection = new ArrayCollection([{'type':'group','id':0,'name':'My First Group','content':'various media'},{'type':'group','id':12,'name':'Another Group','content':'video'},{'type':'group','id':42,'name':'Nature Group','content':'nature photos'}]);

Below that you will see the actual item renderer function which changes the item renderer depending on the item.type value.
protected function getItemRenderer(item:Object):IFactory // TR: item renderer func decides which item renderer to use
{
var myRendererClass:Class;
switch( item.type )
{
case "group":
myRendererClass = GroupsItemRenderer;
break;
case "contact":
myRendererClass = ContactsItemRenderer;
break;
}
return new ClassFactory( myRendererClass );
}

And finally the DataGroup with the itemRendererFunction and initial dataProvider value defined.
<s:DataGroup id="myDataGroup" itemRendererFunction="getItemRenderer"
dataProvider="{contactsData}" >

more posts at www.toddrothe.com/blog

 

AMFPHP Quick Start

AMFPHP is handy when creating a Flex app which interfaces with a php backend.
“AMFPHP allows thin client applications built in languages such as Flash, Flex, and AIR to communicate directly with PHP class objects on the server.” http://amfphp.sourceforge.net/
And here is a short guide to getting AMFPHP working with Flex without the Zend Framework.

1. Download and extract the latest AMFPHP.

2. Copy core dir, gateway.php, globals.php, and services dir from the extracted contents and paste them into your php app root. This guide assumes that you are running your php from a server such as Mamp/Xamp.

2.A. Visit gateway.php in your browser to ensure that everything is in place.

http://localhost:8888/MyFlexApp/gateway.php

3. Place your php class in the services dir that you pasted into your php app root. Here is my php class. ReturnString.php. Ensure that your php class contains only standard characters (bad = ReturnString.class.php). * If your project has php services defined and they are in a dir other than the ‘services’ dir, then modify the $servicePath var in the globals.php file.

4. In your actionscript you will need to create a remote object, populate some of its props and then add some listeners and call your php method.

protected var ro:RemoteObject = new RemoteObject();

init():void
{
ro.endpoint = ‘http://localhost:8888/MyFlexApp/gateway.php’;
ro.destination = ‘ReturnString’;
ro.source = ‘ReturnString’;

ro.addEventListener(ResultEvent.RESULT, returnStringHandler);
ro.addEventListener(FaultEvent.FAULT, returnStringFaultHandler);
ro.getString();
}

protected function returnStringHandler( event:ResultEvent ):void
{
trace(“returnStringHandler result : “+ event.result);
}

protected function returnStringFaultHandler( event:FaultEvent ):void
{
trace(“returnStringFaultHandler result : “+ event.result);
}

No real insights or brand new information contained in this post. Just a straight forward guide to implementing AMFPHP.

 

.apply() – Your Friend in Creating Dynamic Calls

A client asked me to create a layer in their SOA app which would allow them to do the following;
1. Log calls to a service with their analytics software
2. Measure the response time of a service
3. Track service call timeouts and repeat the call as needed

Creating a ServiceProxy seemed like a natural choice.

For those in a hurry – my big lesson was: when assembling a dynamic call and passing params you must use ‘.apply’.
Works: ‘service[serviceCall].apply( null, params );’
Broke: ‘service[serviceCall]( params );’

On with the progam…
The existing ‘service’ files make calls to backend services, via Proxy’s, and process the response received from the server. For example, LoginService contains a login( username, password ) function- – which passes the params as part of a call to FlickrProxy.login( username, password ) .
LoginService listens for a success/failure from FlickrProxy and processes the response accordingly.

Entere the ServiceProxy… who sits between the LoginService and the FlickrProxy.

LoginService.login(username, password) now calls ServiceProxy.makeCall( params ) which ultimately calls FlickrProxy.login(username, password). ServiceProxy.makeCall() is the perfect place to submit data to analytics and start timers immediately before or after making the call to FlickrProxy.
When a response is received from the FlickrProxy, the ServiceProxy stops timers and can submits more analytics data before/after passing the response back to LoginService.handleLogin().

In your LoginService you will now listen for events from ServiceProxy instead of FlickrProxy.

That’s the gist. Not rocket science, I know, but I had fun considering the architectural options and assembling the dynamic calls to service proxies.
Here is a hacked together (non-client specific) version of a ServiceProxy filled with comments.
If I have time I will put together a sample app using the ServiceProxy.

more posts at http://toddrothe.com

 

Flex 3 to Flex 4 Migration Chronicles: III

Error #1053: Illegal override of SolidFill in com.degrafa.paint.SolidFill.

Flex 3 code:



Attempt 1: Get a Flex 4 compatible Degrafa swc from Degrafa.org.

Result 1: There isn’t one… yet. Greg Drove of the Degrafa dev team has said that a Flex 4 swc is coming, but no word as to when.

Attempt 2: Create a mx.graphics.SolidColor in AS3 to use in place of the com.degrafa.paint.SolidFill.


import mx.graphics.SolidColor;
var blue:SolidColor = new SolidColor( 0x62ABCD, 3);
]]>

Result 2: Fail. SolidColor and IGraphicsFill are not interchangeable. You get ‘Error #1053: Illegal override of SolidFill in com.degrafa.paint.SolidFill.’

Attempt 3: Recreate the entire Degrafa surface in using Spark.










Result 3: Success! This was the fail safe: the most work, guaranteed results, and kinda boring.

 

Flex 3 to Flex 4 Migration Chronicles: II

Error: Cannot resolve attribute ‘horizontalScrollPolicy’ for component type spark.components.BorderContainer.

Goal: Match the existing Flex 3 implementation (and design comps) which displays an image inside a scrollable container.

Flex 3 code:


Attempt 1: Add the image inside a Group and set the clipAndEnableScrolling=’true’


Resut 1: No love. The Image gets clipped but no scrollbars appear.

Attempt 2: Add a parent Scroller to the existing Group and remove clipAndEnableScrolling




Result 2: Success! The Flex 4 separation of form from function, logic from layout, allows us to add scrolling functionality when we need it through the Scroller component/tag. In Flex 3 we were always setting horizontalScrollPolicy=’off’ and verticalScrollPolicy=’off’, 99 times out of 100 anyway. Well no more!
*note: Scroller automatically sets clipAndEnableScrolling to true for its children.

For more comprehensive coverage of Scroller check out the Scroller Funtional and Design Spec or Adobe’s Introduction to viewports and scrolling in Flex 4 by Hans Muller.

 

Flex 3 to Flex 4 Migration Chronicles: I

This is the first in a series of posts which chronicle the issues I ran into while migrating a client’s app from the Flex 3.5 SDK to the Flex 4.0 SDK

Error: “The style ‘borderThickness’ is only supported by type ‘mx.containers.Canvas’ with the theme(s) ‘halo’.”

Goal: Match the existing Flex 3 implementation (and design comps) which displays a container with a border stroke 4 px wide.

Flex 3 code :

Attempt 1: Tried adding compiler arg ‘-theme {FlexLibs}/flex_sdk_3.5/frameworks/themes/HaloClassic/haloclassic.swc’.

Result 1: This only created more errors : The style __________ is only supported by type ‘mx.containers.Canvas’ with the theme(s) ‘halo, spark’. Turns out that the ‘haloclassic’ theme from SDK 3.5 doesn’t qualify as ‘halo’ in this case.

Attempt 2: Tried adding compiling arg ‘-theme {FlexLibs}/flex_sdk_4.0/frameworks/themes/Halo/halo.swc’.

Result 2: Qualified success. The error is gone, but when a Spark component is added to the stage the same error appears only it references the new spark component and indicates the lack of ” the theme(s) ‘spark’. ”

Attempt 3: Changed the into

Result 3: Success! No more error and the BorderContainer satisfies the design requirements of a container with a border stroke 4 px wide.

* The errors chronicled in this series can be recreated by copying working code from within Flex 3 Application tags

here

and pasting it between Flex 4 Application tags
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
here

 

Refund for FlashBuilder 4 Upgrade

Having multiple versions of FlashBuilder 4 Standard installed on my machine (beta, educational, plug-in, stand alone) I figured that one of them would be eligible for an upgrade to Premium. I found this not to be the case when I purchased an upgrade from the Adobe Store and attempted to use the resulting serial number.

Initially I filed a help ticket through the Support Portal link provided in the ‘receipt’ email. No love.
Ultimately, a refund was issued by a LivePerson chat representative and the whole process took less than 3 minutes.

The link to ‘Chat’ was near the top of the ‘Check out our list of Frequently Asked Questions’ page whose url was provided in the ‘receipt’ email.

Adobe appears to have made a good choice in using LivePerson for their chat support.
If I ever need chat support I will have to consider LivePerson.

 
 
  • unico air duct parts
  • house moves to monday
  • oakbrook spartanburg
  • laserjet reset menu
  • hand crafted ideas
  • wendy whiteman fire
  • typhoon lagoon logo
  • mileage
  • savers
  • maximo
  • fillmore herald
  • grafton ma horse riding
  • umax webcam drivers
  • cheer laundry detergent history
  • 1928 detroit michigan
  • marksman
  • oster clipper blade sharpening
  • nas and kelis dicvorce
  • sanford ayers mission
  • dalles definition
  • genealogy fulton kentucky
  • bubbly colbie callie
  • mama
  • freeware no watermark nero
  • math easier now
  • alterations tailors elmhurst il
  • proforma newburyport massachusetts
  • sarty st ignatius bedford
  • geforce 6100 chipset troubleshooting
  • gemstone offering bottle
  • huisarts gent krevitz
  • coyotes in lambing
  • harlequin romances 1960s
  • malice mizer piano music
  • stiller
  • rihanna cry remix
  • breda hirsute
  • groves texas phone directry
  • clan
  • calvary temple irving tx
  • firewall
  • tim tebow orange jersey
  • boudreaux hearing preacher joke
  • retreat
  • izmir and ferroni francesco
  • maryanne thorpe killeen tx
  • cutest animal colorado
  • bed wetting resources
  • overcoming students at-risk
  • watch amityville horror online
  • beaumont
  • mcalester oklahoma call girls
  • chelsey queen bedroom set
  • hispanic st jude statue
  • fully mechanical submarine
  • mail moves america
  • 1995 ingersoll 3014 pictures
  • flowers ftd saskatoon saskatchewan
  • mike garret illinois attorney
  • poodles pictures
  • vetrans presentation korean uk
  • watcher
  • candian credit repair
  • provision for taxes
  • judith moilanen
  • iowa governer branstad
  • zombie rmx cranberries mp3
  • norwegian libraries
  • rare ebooks resell rights
  • takes
  • rick derringer bass tab
  • haarp giza pyramid
  • channel 10 stockton news
  • dora mink blanket
  • fraction notes
  • timken aerospace az
  • veteran job cite
  • nextar gps maps
  • flamingo beach hote l
  • girl takes many cocks
  • malaysia commisioner of oaths
  • hong kong dawn
  • pubic area pains
  • breeder octodon degus
  • traverse city oldest houses
  • majestic carriages fortville in
  • alimony
  • 24112 nearby attractions
  • webster
  • apple resellers uk
  • pex tubing weil mclain
  • fixed elevator
  • vinny v tikko
  • ordered from cabinetry direct
  • arnold roy architect llc
  • mountains and basins landforms
  • separating mixture
  • ge hotpoint stove parts
  • stove
  • venice florida visitor guide
  • el caballero blanco
  • gimp glass letters
  • hunt
  • harness
  • classmates dot records
  • starrett
  • weichert realty woodbury nj
  • yahtzee wild game
  • horoscope
  • fortuna shotgun from suhl
  • wishing sugarland tabs
  • demon hunter thorns lyrics
  • vickers part number 771-096
  • ballistic chronograph sensor
  • detectors
  • suvs
  • niece is brother's daughter
  • clad cookware discount
  • belgique
  • yukon
  • vignette qualitative resesarch
  • trojan explorer crashes
  • flashpoint movie actor
  • parsippany
  • calling mumbai india
  • name margret krenz
  • proximity
  • theology of psalms 1
  • medicinal uses of cloves
  • centry
  • drank purple drink
  • cowan zellers
  • remus powerizer
  • hellenic rug imports masters
  • hillary hawke saxophone
  • flags
  • giclee
  • nunavut hpv vaccine program
  • ganz shoe
  • trimmer
  • hottest cathyscraving rare
  • p90x success videos
  • encore
  • polypropylene door mat
  • strongest bike lock
  • pints
  • debut
  • kaspersky cnet
  • pili ceramica quartu
  • organ
  • biscotti with figs
  • toucan imformation
  • dominique
  • dana
  • creater of the telephone
  • kind off magic
  • killian v j
  • wenn rss feed
  • neil hammersmith 2008 artwork
  • petty
  • patent
  • wild mustangs being cot
  • sunland village mesa az
  • william shakespear julius caesar
  • override
  • wesley snipes scar
  • essence
  • standard measurements for weight
  • spiritual warfare ravi
  • vodoo desde 2002
  • mass selective detector system
  • wheelchair accident in charlottesville
  • nsu libraries technical services
  • mite bites human
  • peek
  • alberta grid datum 2.2
  • bloomfield
  • pumkin
  • biotic baking brigade
  • edwards
  • merino thermal
  • pc anywhere and router
  • fauna
  • weak hip muscles
  • jeweled heart fur clip
  • constant itchy fingers
  • calvary
  • great plaines manufacturing
  • fleming
  • antiques the statesville line
  • guzzi
  • seabrook texas hotels
  • wings unlimited models
  • don wasserman international
  • trunk
  • property in buckingham iowa
  • wholesale spool thread
  • rouge the bat sites