SlideShare une entreprise Scribd logo
1  sur  78
Custom Formatter,  Validator,  and Effect Components ,[object Object]
About Me ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Scenarios ,[object Object],[object Object],[object Object]
Scenario #1 ,[object Object],[object Object]
Formatters ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example of Number Formatter ,[object Object]
NumberFormatter import  mx.formatters.NumberFormatter; private   var  myString:String =  "1234567" ; private   function  format():String{ var  numFormatter:NumberFormatter =  new  NumberFormatter(); return  numFormatter.format(myString); } Demo
Example of Number Formatter ,[object Object],[object Object]
Possible Solutions ,[object Object],private   var  myString:String =  "1234567" ; private   function  format():String{ var  sub1:String = myString.substr(0,2); var  sub2:String = myString.substr(2,5); return  sub1 +  "-"  + sub2; } Demo
Feeling Proud ,[object Object],[object Object]
Scope Creep  ,[object Object],[object Object],[object Object]
Solutions ,[object Object]
Solutions ,[object Object],[object Object]
How Many? ,[object Object]
What is it? ,[object Object]
What is it? ,[object Object]
Custom Format String import  mx.formatters.SwitchSymbolFormatter; private   var  myString:String =  "1234567" ; private   function  format():String{ var  ssFormatter:SwitchSymbolFormatter =  new   SwitchSymbolFormatter(); return  ssFormatter.formatValue( "##-###-##" ,myString); } Demo
Scope Creep #2 ,[object Object]
Solution? ,[object Object]
Solution? ,[object Object],[object Object]
Solution? ,[object Object],[object Object],[object Object],[object Object]
Solution That will work ,[object Object]
Solution That will work ,[object Object],[object Object]
Custom Format Characters import  mx.formatters.SwitchSymbolFormatter; private   var  myString:String =  "1234567" ; private   function  format():String{ var  ssFormatter:SwitchSymbolFormatter =  new  SwitchSymbolFormatter( "*" ); return  ssFormatter.formatValue( "#**-**-***" ,myString); } Demo
Scenario #2 ,[object Object],[object Object]
Solution ,[object Object],private   function  format(s:String):String{ var  returnString:String =  "" ; // loop through value and build string in reverse for ( var  i:Number=s.length; i>=0; i--){ returnString = returnString + s.charAt(i); } return  returnString; }
Solution ,[object Object]
Solution ,[object Object],[object Object]
How? ,[object Object]
How? ,[object Object],[object Object]
ReverseFormatter class package  com.everythingflex.flex.formatters { import  mx.formatters.Formatter // Custom formatters must extend mx.formatters.Formatter public   class  ReverseFormatter  extends  Formatter { public   function  ReverseFormatter() { super (); } // Custom formatters must override format(). override   public   function  format(formatObj:Object):String{ // ADD OVERRIDE HERE } } }
ReverseFormatter override format method // Custom formatters must override format(). override   public   function  format(formatObj:Object):String{ if (formatObj.length == 0) {  // return empty string and set error property if string  //has zero length. error= "Can not format an empty String" ; return   "" }  else  { error= null ; var  returnString:String =  "" ; // loop through value and build string in reverse for ( var  i:Number=formatObj.length; i>=0; i--){ returnString = returnString + formatObj.charAt(i); } return  returnString; }
Using ReverseFormatter import  ReverseFormatter; private   var  myString:String =  "Rich Tretola" ; private   function  format():String{ var  reverseFormatter:ReverseFormatter =  new  ReverseFormatter(); return  reverseFormatter.format(myString); } Demo
Scenario #3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Solutions ,[object Object]
Solutions ,[object Object],[object Object]
Custom Validator ,[object Object],[object Object],[object Object]
PasswordValidator class package  com.everythingflex.flex.validators  { import  mx.validators.Validator; import  mx.validators.ValidationResult; public   class  PasswordValidator  extends  Validator { private   var  results:Array; public   function  PasswordValidator() { super (); } // Override the doValidation() method. override   protected   function  doValidation(value:Object):Array { // ADD OVERRIDE HERE } } }
Override doValidation // Override the doValidation() method. override   protected   function  doValidation(value:Object):Array { results = []; // Call super's doValidation(). results =  super .doValidation(value);  // Return if super's doValidation contains // errors (required would be an example). if  (results.length > 0){ return  results; } // *****Add Custom Validation Here***** return  results; }
Now add custom validation // Check for min length if  (dataString.length < 6){ results.push( new  ValidationResult( true ,  null ,  &quot;Short&quot; ,  &quot;Password must be at least 6 characters.&quot; )); return  results; }  var  dataString:String = String(value); // Check for max length (this can be set in the text component's maxChars property). if  (dataString.length > 10){ results.push( new  ValidationResult( true ,  null ,  &quot;Long&quot; ,  &quot;Password must be no larger than 10 characters.&quot; )); return  results; }
More custom validation // Check for at least 1 upper case letter. if  (dataString.search( &quot;[A-Z]&quot; )<0) { results.push( new  ValidationResult( true ,  null ,  &quot;Upper&quot; ,  &quot;Passwords must contain at least one upper case letter.&quot; )); return  results; } // Check for at least 1 lower case letter. if  (dataString.search( &quot;[a-z]&quot; )<0) { results.push( new  ValidationResult( true ,  null ,  &quot;Lower&quot; ,  &quot;Passwords must contain at lease one lower case letter.&quot; )); return  results; } // Check for at least 1 number. if  (dataString.search( &quot;[0-9]&quot; )<0) { results.push( new  ValidationResult( true ,  null ,  &quot;Number&quot; ,  &quot;Passwords must contain at least one number.&quot; )); return  results; }
Results Demo
Scenario #4 ,[object Object]
Solution ,[object Object],private   function  rollOver(event:MouseEvent): void { event.target.scaleX=2; event.target.scaleY=2; } private   function  rollOut(event:MouseEvent): void { event.target.scaleX=1; event.target.scaleY=1; } <mx:Button  mouseOver=&quot;rollOver(event)&quot;  mouseOut=&quot;rollOut(event)&quot;  />
Solution ,[object Object]
Solution ,[object Object],[object Object]
Creating a Custom Effect ,[object Object],[object Object],[object Object]
Effect Class ,[object Object],[object Object],[object Object],[object Object]
ScaleEffect Class package  com.everythingflex.flex.effects { import  mx.effects.Effect; import  mx.effects.EffectInstance; import  mx.effects.IEffectInstance; public   class  ScaleEffect  extends  Effect { // Define scaleTo parameter public   var  scaleTo:Number; public   function  ScaleEffect(targetObj:Object =  null ){ super (targetObj); instanceClass= ScaleEffectInstance;  } // ADD Override getAffectedProperties() // ADD Override initInstance()   } }
ScaleEffect Overrides // override getAffectedProperties() and  // pass the properties effected  override   public   function  getAffectedProperties():Array{ return  [ &quot;scaleX,scaleY&quot; ]; } // Override initInstance() override   protected   function  initInstance(inst:IEffectInstance): void { super .initInstance(inst); ScaleEffectInstance(inst).scaleTo = scaleTo;  }
EffectInstance Class ,[object Object],[object Object]
ScaleEffectInstance Class package  com.everythingflex.flex.effects { import  mx.effects.EffectInstance; public   class  ScaleEffectInstance  extends  EffectInstance { // Custom Parameter public   var  scaleTo:Number; public   function  ScaleEffectInstance(targetObj:Object) { super (targetObj); } // ADD Override play() method. // ADD Override reverse() method. } }
ScaleEffectInstance Overrides // Override play() method. override   public   function  play(): void { super .play(); target.scaleX=scaleTo; target.scaleY=scaleTo; } // Override reverse() method. override   public   function  reverse(): void { target.scaleX=1; target.scaleY=1; }
Results Demo
Scenario #5 ,[object Object],[object Object]
Solution ,[object Object],[object Object]
Custom TweenEffect ,[object Object],[object Object],[object Object]
TweenEffect class ,[object Object],[object Object],[object Object],[object Object]
MoveBounceTweenEffect Class package  com.everythingflex.flex.effects { import  mx.effects.TweenEffect; import  mx.effects.EffectInstance; import  mx.effects.IEffectInstance; public   class  MoveBounceTweenEffect  extends  TweenEffect{ // Define xFrom and xTo parameters public   var  xFrom:Number; public   var  xTo:Number; public   function  MoveBounceTweenEffect(targetObj:Object =  null ){ super (targetObj); instanceClass= MoveBounceTweenEffectInstance;  } // ADD Override getAffectedProperties() // ADD Override initInstance()   }
MoveBounceTweenEffect Overrides // override getAffectedProperties() and  // pass the properties effected  override   public   function  getAffectedProperties():Array{ return  [ &quot;x&quot; ]; } // Override initInstance() override   protected   function  initInstance(inst:IEffectInstance): void { super .initInstance(inst); MoveBounceTweenEffectInstance(inst).xFrom = xFrom; MoveBounceTweenEffectInstance(inst).xTo = xTo; }
TweenEffectInstance ,[object Object],[object Object],[object Object],[object Object]
MoveBounceTweenEffectInstance package { import  mx.effects.effectClasses.TweenEffectInstance; import  mx.effects.Tween; public   class  MoveBounceTweenEffectInstance  extends  TweenEffectInstance { // Move parameters public   var  xFrom:Number; public   var  xTo:Number; public   function  MoveBounceTweenEffectInstance(targetObj:Object){ super (targetObj); } // Override play() method. override   public   function  play(): void { super .play(); // Create the Tween object var  tween:Tween = createTween( this , xFrom, xTo, duration);  } // Override onTweenUpdate() method. override   public   function  onTweenUpdate(val:Object): void { target.x = val; } // Override onTweenEnd() method. override   public   function  onTweenEnd(val:Object): void { // call super.onTweenEnd(). super .onTweenEnd(val); } } }
Results Demo
Forgot Something ,[object Object]
Forgot Something ,[object Object],[object Object]
Easing Function Easing function was borrowed from the Adobe docs private   function  bounceFunction(t:Number, b:Number, c:Number, d:Number):Number { if  ((t /= d) < (1 / 2.75)) { return  c * (7.5625 * t * t) + b; }  else   if  (t < (2 / 2.75)) { return  c * (7.5625 * (t-=(1.5/2.75)) * t + .75) + b; }  else   if  (t < (2.5 / 2.75)) { return  c * (7.5625 * (t-=(2.25/2.75)) * t + .9375) + b; }  else  { return  c * (7.5625 * (t-=(2.625/2.75)) * t + .984375) + b; } } MoveBounceTweenEffectInstance(inst).easingFunction = bounceFunction; Add it to the initInstance method
Results Demo
Benefits of Custom Effect ,[object Object],Demo
Wrap Up Hopefully, if I have done my job correctly you will now see the benefits of using custom classes for formatters, validators, and effects.
Prizes Question #1 ,[object Object]
Prizes Question #1 ,[object Object],[object Object]
Prizes Question #2 ,[object Object]
Prizes Question #2 ,[object Object],[object Object]
Prizes Question #3 ,[object Object]
Prizes Question #3 ,[object Object],[object Object]
Prizes Question #4 ,[object Object]
Prizes Question #4 ,[object Object],[object Object]
Contact and Downloads Rich Tretola [email_address]   or  [email_address] Pre sentation and Sour ce available at: http://blog.everythingflex.com

Contenu connexe

Tendances

Functional Effects - Part 1
Functional Effects - Part 1Functional Effects - Part 1
Functional Effects - Part 1Philip Schwarz
 
iOS best practices
iOS best practicesiOS best practices
iOS best practicesMaxim Vialyx
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象勇浩 赖
 
Activity diagram tutorial
Activity diagram tutorialActivity diagram tutorial
Activity diagram tutorialDeclan Chellar
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascriptguest4d57e6
 
What’s new in .NET
What’s new in .NETWhat’s new in .NET
What’s new in .NETDoommaker
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functionsmussawir20
 
non-strict functions, bottom and scala by-name parameters
non-strict functions, bottom and scala by-name parametersnon-strict functions, bottom and scala by-name parameters
non-strict functions, bottom and scala by-name parametersPhilip Schwarz
 
FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6rohassanie
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3rohassanie
 
Java script – basic auroskills (2)
Java script – basic   auroskills (2)Java script – basic   auroskills (2)
Java script – basic auroskills (2)BoneyGawande
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsPython Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsP3 InfoTech Solutions Pvt. Ltd.
 
Let's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java APILet's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java APIMario Fusco
 

Tendances (20)

Clean code
Clean codeClean code
Clean code
 
Functional Effects - Part 1
Functional Effects - Part 1Functional Effects - Part 1
Functional Effects - Part 1
 
iOS best practices
iOS best practicesiOS best practices
iOS best practices
 
Dsl
DslDsl
Dsl
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象
 
Activity diagram tutorial
Activity diagram tutorialActivity diagram tutorial
Activity diagram tutorial
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascript
 
Python Programming Essentials - M17 - Functions
Python Programming Essentials - M17 - FunctionsPython Programming Essentials - M17 - Functions
Python Programming Essentials - M17 - Functions
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
What’s new in .NET
What’s new in .NETWhat’s new in .NET
What’s new in .NET
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functions
 
non-strict functions, bottom and scala by-name parameters
non-strict functions, bottom and scala by-name parametersnon-strict functions, bottom and scala by-name parameters
non-strict functions, bottom and scala by-name parameters
 
09. Methods
09. Methods09. Methods
09. Methods
 
FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6
 
Vbscript
VbscriptVbscript
Vbscript
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
Java script – basic auroskills (2)
Java script – basic   auroskills (2)Java script – basic   auroskills (2)
Java script – basic auroskills (2)
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsPython Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
 
Let's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java APILet's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java API
 
SQL -PHP Tutorial
SQL -PHP TutorialSQL -PHP Tutorial
SQL -PHP Tutorial
 

En vedette

360 Flex Atlanta
360 Flex Atlanta360 Flex Atlanta
360 Flex Atlantartretola
 
MAX 2007 - Flex to AIR
MAX 2007 - Flex to AIRMAX 2007 - Flex to AIR
MAX 2007 - Flex to AIRrtretola
 
New Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP ConnectorsNew Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP Connectorsrtretola
 
MAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR applicationMAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR applicationrtretola
 
Flash SEO Secrets
Flash SEO SecretsFlash SEO Secrets
Flash SEO Secretsrtretola
 
Must Have Apps for Windows 10
Must Have Apps for Windows 10Must Have Apps for Windows 10
Must Have Apps for Windows 10Wiley
 
Rethinking Website Design: Creating a Peak-Performing Website with Less Risk ...
Rethinking Website Design: Creating a Peak-Performing Website with Less Risk ...Rethinking Website Design: Creating a Peak-Performing Website with Less Risk ...
Rethinking Website Design: Creating a Peak-Performing Website with Less Risk ...HubSpot
 

En vedette (8)

360 Flex Atlanta
360 Flex Atlanta360 Flex Atlanta
360 Flex Atlanta
 
MAX 2007 - Flex to AIR
MAX 2007 - Flex to AIRMAX 2007 - Flex to AIR
MAX 2007 - Flex to AIR
 
New Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP ConnectorsNew Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP Connectors
 
MAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR applicationMAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR application
 
Flash SEO Secrets
Flash SEO SecretsFlash SEO Secrets
Flash SEO Secrets
 
[INFOGRAPHIC] 2015 State of Social Business
[INFOGRAPHIC] 2015 State of Social Business[INFOGRAPHIC] 2015 State of Social Business
[INFOGRAPHIC] 2015 State of Social Business
 
Must Have Apps for Windows 10
Must Have Apps for Windows 10Must Have Apps for Windows 10
Must Have Apps for Windows 10
 
Rethinking Website Design: Creating a Peak-Performing Website with Less Risk ...
Rethinking Website Design: Creating a Peak-Performing Website with Less Risk ...Rethinking Website Design: Creating a Peak-Performing Website with Less Risk ...
Rethinking Website Design: Creating a Peak-Performing Website with Less Risk ...
 

Similaire à Custom Formatter, Validator, and Effect Components

Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java DevelopersYakov Fain
 
Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]srikanthbkm
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003R696
 
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdfNeed help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdffastechsrv
 
functions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptfunctions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptRajasekhar364622
 
Python programming variables and comment
Python programming variables and commentPython programming variables and comment
Python programming variables and commentMalligaarjunanN
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoftch samaram
 
QTP VB Script Trainings
QTP VB Script TrainingsQTP VB Script Trainings
QTP VB Script TrainingsAli Imran
 
Java script basics
Java script basicsJava script basics
Java script basicsJohn Smith
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiRan Mizrahi
 
Python programming - Functions and list and tuples
Python programming - Functions and list and tuplesPython programming - Functions and list and tuples
Python programming - Functions and list and tuplesMalligaarjunanN
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handlingSuite Solutions
 
Checking the Source Code of FlashDevelop with PVS-Studio
Checking the Source Code of FlashDevelop with PVS-StudioChecking the Source Code of FlashDevelop with PVS-Studio
Checking the Source Code of FlashDevelop with PVS-StudioPVS-Studio
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFXTom Mix Petreca
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)James Titcumb
 

Similaire à Custom Formatter, Validator, and Effect Components (20)

Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java Developers
 
Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
 
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdfNeed help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
 
functions modules and exceptions handlings.ppt
functions modules and exceptions handlings.pptfunctions modules and exceptions handlings.ppt
functions modules and exceptions handlings.ppt
 
Python programming variables and comment
Python programming variables and commentPython programming variables and comment
Python programming variables and comment
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
QTP VB Script Trainings
QTP VB Script TrainingsQTP VB Script Trainings
QTP VB Script Trainings
 
Java script basics
Java script basicsJava script basics
Java script basics
 
Javascripting.pptx
Javascripting.pptxJavascripting.pptx
Javascripting.pptx
 
Clean code
Clean codeClean code
Clean code
 
Web programming
Web programmingWeb programming
Web programming
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
Python programming - Functions and list and tuples
Python programming - Functions and list and tuplesPython programming - Functions and list and tuples
Python programming - Functions and list and tuples
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handling
 
Checking the Source Code of FlashDevelop with PVS-Studio
Checking the Source Code of FlashDevelop with PVS-StudioChecking the Source Code of FlashDevelop with PVS-Studio
Checking the Source Code of FlashDevelop with PVS-Studio
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFX
 
Preprocessors
PreprocessorsPreprocessors
Preprocessors
 
Java 17
Java 17Java 17
Java 17
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
 

Dernier

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Dernier (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

Custom Formatter, Validator, and Effect Components

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. NumberFormatter import mx.formatters.NumberFormatter; private var myString:String = &quot;1234567&quot; ; private function format():String{ var numFormatter:NumberFormatter = new NumberFormatter(); return numFormatter.format(myString); } Demo
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. Custom Format String import mx.formatters.SwitchSymbolFormatter; private var myString:String = &quot;1234567&quot; ; private function format():String{ var ssFormatter:SwitchSymbolFormatter = new SwitchSymbolFormatter(); return ssFormatter.formatValue( &quot;##-###-##&quot; ,myString); } Demo
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. Custom Format Characters import mx.formatters.SwitchSymbolFormatter; private var myString:String = &quot;1234567&quot; ; private function format():String{ var ssFormatter:SwitchSymbolFormatter = new SwitchSymbolFormatter( &quot;*&quot; ); return ssFormatter.formatValue( &quot;#**-**-***&quot; ,myString); } Demo
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31. ReverseFormatter class package com.everythingflex.flex.formatters { import mx.formatters.Formatter // Custom formatters must extend mx.formatters.Formatter public class ReverseFormatter extends Formatter { public function ReverseFormatter() { super (); } // Custom formatters must override format(). override public function format(formatObj:Object):String{ // ADD OVERRIDE HERE } } }
  • 32. ReverseFormatter override format method // Custom formatters must override format(). override public function format(formatObj:Object):String{ if (formatObj.length == 0) { // return empty string and set error property if string //has zero length. error= &quot;Can not format an empty String&quot; ; return &quot;&quot; } else { error= null ; var returnString:String = &quot;&quot; ; // loop through value and build string in reverse for ( var i:Number=formatObj.length; i>=0; i--){ returnString = returnString + formatObj.charAt(i); } return returnString; }
  • 33. Using ReverseFormatter import ReverseFormatter; private var myString:String = &quot;Rich Tretola&quot; ; private function format():String{ var reverseFormatter:ReverseFormatter = new ReverseFormatter(); return reverseFormatter.format(myString); } Demo
  • 34.
  • 35.
  • 36.
  • 37.
  • 38. PasswordValidator class package com.everythingflex.flex.validators { import mx.validators.Validator; import mx.validators.ValidationResult; public class PasswordValidator extends Validator { private var results:Array; public function PasswordValidator() { super (); } // Override the doValidation() method. override protected function doValidation(value:Object):Array { // ADD OVERRIDE HERE } } }
  • 39. Override doValidation // Override the doValidation() method. override protected function doValidation(value:Object):Array { results = []; // Call super's doValidation(). results = super .doValidation(value); // Return if super's doValidation contains // errors (required would be an example). if (results.length > 0){ return results; } // *****Add Custom Validation Here***** return results; }
  • 40. Now add custom validation // Check for min length if (dataString.length < 6){ results.push( new ValidationResult( true , null , &quot;Short&quot; , &quot;Password must be at least 6 characters.&quot; )); return results; } var dataString:String = String(value); // Check for max length (this can be set in the text component's maxChars property). if (dataString.length > 10){ results.push( new ValidationResult( true , null , &quot;Long&quot; , &quot;Password must be no larger than 10 characters.&quot; )); return results; }
  • 41. More custom validation // Check for at least 1 upper case letter. if (dataString.search( &quot;[A-Z]&quot; )<0) { results.push( new ValidationResult( true , null , &quot;Upper&quot; , &quot;Passwords must contain at least one upper case letter.&quot; )); return results; } // Check for at least 1 lower case letter. if (dataString.search( &quot;[a-z]&quot; )<0) { results.push( new ValidationResult( true , null , &quot;Lower&quot; , &quot;Passwords must contain at lease one lower case letter.&quot; )); return results; } // Check for at least 1 number. if (dataString.search( &quot;[0-9]&quot; )<0) { results.push( new ValidationResult( true , null , &quot;Number&quot; , &quot;Passwords must contain at least one number.&quot; )); return results; }
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49. ScaleEffect Class package com.everythingflex.flex.effects { import mx.effects.Effect; import mx.effects.EffectInstance; import mx.effects.IEffectInstance; public class ScaleEffect extends Effect { // Define scaleTo parameter public var scaleTo:Number; public function ScaleEffect(targetObj:Object = null ){ super (targetObj); instanceClass= ScaleEffectInstance; } // ADD Override getAffectedProperties() // ADD Override initInstance() } }
  • 50. ScaleEffect Overrides // override getAffectedProperties() and // pass the properties effected override public function getAffectedProperties():Array{ return [ &quot;scaleX,scaleY&quot; ]; } // Override initInstance() override protected function initInstance(inst:IEffectInstance): void { super .initInstance(inst); ScaleEffectInstance(inst).scaleTo = scaleTo; }
  • 51.
  • 52. ScaleEffectInstance Class package com.everythingflex.flex.effects { import mx.effects.EffectInstance; public class ScaleEffectInstance extends EffectInstance { // Custom Parameter public var scaleTo:Number; public function ScaleEffectInstance(targetObj:Object) { super (targetObj); } // ADD Override play() method. // ADD Override reverse() method. } }
  • 53. ScaleEffectInstance Overrides // Override play() method. override public function play(): void { super .play(); target.scaleX=scaleTo; target.scaleY=scaleTo; } // Override reverse() method. override public function reverse(): void { target.scaleX=1; target.scaleY=1; }
  • 55.
  • 56.
  • 57.
  • 58.
  • 59. MoveBounceTweenEffect Class package com.everythingflex.flex.effects { import mx.effects.TweenEffect; import mx.effects.EffectInstance; import mx.effects.IEffectInstance; public class MoveBounceTweenEffect extends TweenEffect{ // Define xFrom and xTo parameters public var xFrom:Number; public var xTo:Number; public function MoveBounceTweenEffect(targetObj:Object = null ){ super (targetObj); instanceClass= MoveBounceTweenEffectInstance; } // ADD Override getAffectedProperties() // ADD Override initInstance() }
  • 60. MoveBounceTweenEffect Overrides // override getAffectedProperties() and // pass the properties effected override public function getAffectedProperties():Array{ return [ &quot;x&quot; ]; } // Override initInstance() override protected function initInstance(inst:IEffectInstance): void { super .initInstance(inst); MoveBounceTweenEffectInstance(inst).xFrom = xFrom; MoveBounceTweenEffectInstance(inst).xTo = xTo; }
  • 61.
  • 62. MoveBounceTweenEffectInstance package { import mx.effects.effectClasses.TweenEffectInstance; import mx.effects.Tween; public class MoveBounceTweenEffectInstance extends TweenEffectInstance { // Move parameters public var xFrom:Number; public var xTo:Number; public function MoveBounceTweenEffectInstance(targetObj:Object){ super (targetObj); } // Override play() method. override public function play(): void { super .play(); // Create the Tween object var tween:Tween = createTween( this , xFrom, xTo, duration); } // Override onTweenUpdate() method. override public function onTweenUpdate(val:Object): void { target.x = val; } // Override onTweenEnd() method. override public function onTweenEnd(val:Object): void { // call super.onTweenEnd(). super .onTweenEnd(val); } } }
  • 64.
  • 65.
  • 66. Easing Function Easing function was borrowed from the Adobe docs private function bounceFunction(t:Number, b:Number, c:Number, d:Number):Number { if ((t /= d) < (1 / 2.75)) { return c * (7.5625 * t * t) + b; } else if (t < (2 / 2.75)) { return c * (7.5625 * (t-=(1.5/2.75)) * t + .75) + b; } else if (t < (2.5 / 2.75)) { return c * (7.5625 * (t-=(2.25/2.75)) * t + .9375) + b; } else { return c * (7.5625 * (t-=(2.625/2.75)) * t + .984375) + b; } } MoveBounceTweenEffectInstance(inst).easingFunction = bounceFunction; Add it to the initInstance method
  • 68.
  • 69. Wrap Up Hopefully, if I have done my job correctly you will now see the benefits of using custom classes for formatters, validators, and effects.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78. Contact and Downloads Rich Tretola [email_address] or [email_address] Pre sentation and Sour ce available at: http://blog.everythingflex.com