Adobe Dreamweaver Forums



Last 10 THreads :         Re: I can´t start photoshop cs4 error:Photoshop CS4 stopped working. (Last Post : roft@adobeforums.com - Replies : 0 - Views : 1 )           »          Networked Webcams (Last Post : VirginiaBeachCity - Replies : 0 - Views : 1 )           »          Preloading a game (Last Post : trigger2160 - Replies : 0 - Views : 1 )           »          FAO: Murray RE: Mailchimp (Last Post : joeq - Replies : 5 - Views : 6 )           »          PS CS4 "Save As ..." format choices appear in duplicate (Last Post : Dan_Dill@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: Colour differences on the web (Last Post : g_ballard@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: SFW and date created (Last Post : Ann_Shelbourne@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: sRGB vs. Adobe (1998) RGB (Last Post : Neil_Keller@adobeforums.com - Replies : 0 - Views : 1 )           »          help my flash site opens pop ups? (Last Post : Awebus - Replies : 2 - Views : 3 )           »          Flash IDE randomly creating Symbols (Last Post : MediaMackenzie.com - Replies : 0 - Views : 1 )           »         


User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-03-2008, 04:38 AM
dugjohnson
 
Posts: n/a
Diggs:
Default Multiple moving custom HBoxes

** Noob to Flex, Old to programming **
for http://mymiddlenameshussein.com I created a form to capture names. I
would ALSO like to read those names from the website (randomly) and combine
them with the middle name Hussein (ala Barak Obama) and have them appear
individually at the bottom, scroll to the top and then disappear, ala the
opening in Star Wars.
I created a custom HBox that has a text box for each of firstname, the middle
name constant "Hussein" and lastname. I have gotten an individual Hbox to do
the needed behavior.
I have tried several different methods (instantiate on the fly, array) and
except for instantiating 1 Hbox which does what it is "supposed to" by having
the effect occur on creation, I have been unsuccessful.
In attempting to call the instantiation code based on the timer, I saw nothing
and in the attempt to have individual components stored in an array made
visible (attaching the effect to showEffect) I saw nothing. (see attached code)
Am I not doing Timer correctly? Am I handling the multiple objects
incorrectly? Any direction (link to example? ideas?) would be greatly
appreciated. I have read a lot, but most array information is in re: to data
binding. Perchance this could be better done in Flash, but I am more of a
developer than a designer so am, in general, more comfortable with the idea of
Flex and would prefer to do it there.
Learning a lot!



<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
color="#FFFFFF"
applicationComplete="currentState='addname';getCou nt();TimerExample();"
borderColor="#000101"
xmlns:ncmb="*">

<mx:HTTPService id="sendData"
url="http://mymiddlenameshussein.com/repos/hdataad d.php"
resultFormat="text" useProxy="false"
result="handlePlain(event);" fault="handleFault(event);">
<mx:request xmlns="">
<firstname>
{myfirstname.text}
</firstname>
<lastname>
{mylastname.text}
</lastname>
</mx:request>
</mx:HTTPService>

<mx:StringValidator
id="firstnameValidator"
source="{myfirstname}"
property="text"
minLength="2"
/>
<mx:StringValidator
id="lastnameValidator"
source="{mylastname}"
property="text"
minLength="2"
/>
<mx:Model id="recordCount">
<root>
<totalRecords>
0
</totalRecords>
</root>
</mx:Model>
<mx:Script>
<![CDATA[
import mx.effects.Fade;
import mx.effects.Move;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
import mx.events.ValidationResultEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;

private var vResult:ValidationResultEvent;
public function handlePlain(event:ResultEvent):void
{
recordCount.totalRecords = event.result.toString();
}

public function handleFault(event:FaultEvent):void
{
Alert.show(event.fault.faultString, "Error");
}
private function allValid():Boolean {
var IsGood: Boolean;
IsGood = true;
vResult =firstnameValidator.validate();
if (vResult.type==ValidationResultEvent.INVALID)
IsGood = false;
vResult =lastnameValidator.validate();
if (vResult.type==ValidationResultEvent.INVALID)
IsGood = false;
return IsGood;
}
private function getCount(): void {
myfirstname.text = 'GETCOUNT';
sendData.send();
// recordCount.totalRecords = sendData.lastResult.recordcount.record;
myfirstname.text = '';
}
private function addDataClick(): void {
var DialogMessage: String;
if (! allValid()) return;
sendData.send();
recordCount.totalRecords = sendData.lastResult.toString();
DialogMessage = myfirstname.text + ' Hussein '+ mylastname.text +
' has been added!';
showDialog(DialogMessage);
mylastname.text='';
myfirstname.text='';
currentState='addname';
}
private function showDialog(MyDialog: String) : void {
Alert.show(MyDialog, 'You have been added'); // popup modal dialog
}
public function TimerExample():void {
var myTimer:Timer = new Timer(1000, 2);
myTimer.addEventListener("timer", timerHandler);
myTimer.start();
}
private var I:int = 0;
public function timerHandler(event:TimerEvent):void {
if ( currentState=="addname"){
(namesArray[i]as nameCombiner).firstName="Doug";
(namesArray[i]as nameCombiner).lastName="Johnson"+I;
(namesArray[i]as nameCombiner).y=200;
(namesArray[i]as nameCombiner).visible=true;
I=I+1;
if (I==5){I=0;}
}
}
]]>
</mx:Script>
<mx:states>
<mx:State name="addname">
<mx:AddChild position="lastChild">
<mx:Form x="10" y="68" width="428" height="129" id="addform"
horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:FormHeading label="My Middle Name's Hussein"
color="#0A0B0A" textAlign="left" width="387"/>
<mx:FormItem label="My First Name" color="#0D0C0C">
<mx:TextInput id="myfirstname" width="290"/>
</mx:FormItem>
<mx:FormItem label="My Last Name" color="#0D0C0C">
<mx:TextInput id="mylastname" width="290"/>
</mx:FormItem>
<mx:Button id="gotomain" label="Add My Name to the List"
width="239"
color="#0E0F0D" click="addDataClick()"/>
</mx:Form>
</mx:AddChild>
<mx:RemoveChild target="{gotoadd}"/>
</mx:State>
</mx:states>
<mx:Button x="178.5" y="348" label="Add me to the list"
click="currentState='addname'" id="gotoadd"/>
<mx:Text x="22" y="10" text="{recordCount.totalRecords} have the middle name
Hussein" width="412" textAlign="center" id="howManyText" fontSize="18"/>
<mx:Array id="namesArray">
<ncmb:nameCombiner visible="false"/>
<ncmb:nameCombiner visible="false"/>
<ncmb:nameCombiner visible="false"/>
<ncmb:nameCombiner visible="false"/>
<ncmb:nameCombiner visible="false"/>
<ncmb:nameCombiner visible="false"/>
</mx:Array>
</mx:Application>

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%"
height="50" horizontalGap="140"
horizontalAlign="center" verticalAlign="middle"
alpha="0.0" themeColor="#009DFF"
fontFamily="Verdana" fontSize="16" color="#000000"
showEffect="driftUp" >

<mx:Script>
<![CDATA[

override protected function commitProperties():void{
super.commitProperties();
var resize:Boolean = false;
if (this.firstName != this.firstName) {resize = true;}
if (this.lastName != this.lastName) {resize = true;}
if (this.width != this.width) {resize = true;}
// if (resize) {this.horizontalgap =
// "{((this.width -
(firstNameText.width+lastNameText.width))/2)}";}
}

]]>
</mx:Script>
<mx:String id="firstName">First</mx:String>
<mx:String id="lastName">Last</mx:String>
<mx:Sequence id="driftUp">
<mx:Fade/>
<mx:Move yTo="0" duration="10000"/>
<mx:Fade alphaFrom="1" alphaTo="0"/>
</mx:Sequence>

<mx:Text id="firstNameText" text="{firstName}"/>
<mx:Text text="Hussein"/>
<mx:Text id="lastNameText" text="{lastName}"/>

</mx:HBox>



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-03-2008, 04:38 AM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Multiple moving custom HBoxes


"dugjohnson" <webforumsuser@macromedia.com> wrote in message
news:ge4d2p$aqq$1@forums.macromedia.com...
> ** Noob to Flex, Old to programming **
> for http://mymiddlenameshussein.com I created a form to capture names. I
> would ALSO like to read those names from the website (randomly) and
> combine
> them with the middle name Hussein (ala Barak Obama) and have them appear
> individually at the bottom, scroll to the top and then disappear, ala the
> opening in Star Wars.


http://ntt.cc/2008/04/14/simple-tips...urce-code.html


Reply With Quote
  #3 (permalink)  
Old 11-03-2008, 04:38 AM
dugjohnson
 
Posts: n/a
Diggs:
Default Re: Multiple moving custom HBoxes

I like it as a potential solution, but...
I was hoping to animate the custom component also, so I really need multiples
of the component and to have them move, individually.
If nothing else occurs, I will rewrite to make it moving text on a canvas.
Thanks.

Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:28 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk