Adobe Dreamweaver Forums



Last 10 THreads :         Problem with Subversion (Last Post : tmortime - Replies : 0 - Views : 1 )           »          bad luck (Last Post : newwaveboats - Replies : 2 - Views : 3 )           »          Flash CS4 Crashes (Last Post : san_flash - Replies : 10 - Views : 11 )           »          Problem initialising quicktime (Last Post : Sean Wilson - Replies : 3 - Views : 4 )           »          Changing Menu Bar (Last Post : Walt F. Schaefer - Replies : 1 - Views : 2 )           »          Re: Photoshop won't launch (Last Post : Ann_Shelbourne@adobeforums.com - Replies : 0 - Views : 1 )           »          Eventlistener for exiting frame (Last Post : Andrei1 - Replies : 1 - Views : 2 )           »          CS4 Motion Editor issues (Last Post : jdehaan - Replies : 3 - Views : 9 )           »          Flash file won't display (Last Post : Murray *ACE* - Replies : 18 - Views : 19 )           »          How do I centre Tables ? (Last Post : Murray *ACE* - Replies : 3 - Views : 4 )           »         


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



Reply
  #1 (permalink)  
Old 11-04-2008, 03:24 PM
alice_data
 
Posts: n/a
Diggs:
Default Form Layout Issues

Hi,

I don't know if there is anyone on the list tried to keep all the form
labels aligned all the way on the left. I could assign it to aligning on the
left, but what I really want is have every single label, start from the
horizontal coordinate from x="0" instead of having the last character of each
form item aligned to the left. Now it looks like some letter head address, and
I don't want it that way.

Attached is my code, and I would appreciate it if anyone can give me tips on
what I have overlooked.

Alice



<mx:Form y="20">
<mx:FormItem label="Your Name:" fontWeight="bold" textAlign="left">
<mx:TextInput id="your_name"/>
</mx:FormItem>
<mx:FormItem label="Your Birth Date:" fontWeight="bold"
textAlign="left">
<mx:TextInput id="birth_date"/>
</mx:FormItem>
<mx:FormItem label="One Line to Describe Yourself:"
fontWeight="bold" textAlign="left">
<mx:TextInput id="yourself_intro"/>
</mx:FormItem>
</mx:Form>



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-04-2008, 08:32 PM
Masamune
 
Posts: n/a
Diggs:
Default Re: Combine Two Arrays Using Actionscript in FlexApplications Errors

It looks like you are declaring both local and global variables with the same
names. In this case, the local declarations within the functions are overriding
the global variables. Instead of using var selArr;Array = [] in your
checkBox_change function, remove the 'var' keyword and just use:
selArr = [];

I think you can also delete the global selArr2 and selArr3 variables since
they only appear within the checkbox_change2 function and don't need global
scope. If this is not the case, then you will need to also remove the 'var'
keyword within the function as above.

I think this should help with your error messages, but post back if you still
encounter errors.

Vygo

Reply With Quote
  #3 (permalink)  
Old 11-04-2008, 09:03 PM
alice_data
 
Posts: n/a
Diggs:
Default Re: Combine Two Arrays Using Actionscript in FlexApplications Errors

Hi,

Thanks for the reply, but the answer here now gives me errors. To make sure
that I have understood what you were saying here, I have attached the revised
version of the code below.

I see the errors on the page right away after I made these changes, and
the most obvious one is here: Severity and
Description Path Resource Location Creation Time Id
1067: Implicit coercion of a value of type Array to an unrelated type Class
and 1188: Illegal assignment to class Array. at the line where selArr:Array= []
is declared.

Have I not added something I should be adding here?

Thanks for your help.

Alice

[Bindable]private var selArr:Array;
[Bindable]private var len:int;

private function checkBox_change(evt:Event,x:Array):void {
selArr:Array = [];
var idx:int;
var len:int =
my_book.lastResult.collection.store_id.author.leng th;
for (idx=0; idx<len; idx++) {
if (x[idx].selected) {
selArr.push(x[idx].label);
}
}
}
private function checkBox_change2(evt:Event,y:Array):void {
selArr2:Array = [];
var idx:int;
var len2:int =
my_book.lastResult.collection.region_id.publisher. length;
for (idx=0; idx<len2; idx++) {
if (y[idx].selected) {
selArr2.push(y[idx].label);
}
}
var len3:int= len + len2;
var selArr3:Array= selArr2.concat(selArr);
var title:String = selArr2.length + " of " + len2 + " item(s)
selected.";
var title2:String = selArr3.length + " of " + len3 + " item(s)
selected.";
var message:String = selArr2.join("\n");
var message2:String = selArr3.join("\n");
Alert.show(message, title);
Alert.show(message2,title2);
}

Reply With Quote


  #4 (permalink)  
Old 11-05-2008, 01:23 AM
wingobaxter
 
Posts: n/a
Diggs:
Default Re: Combine Two Arrays Using Actionscript in FlexApplications Errors

You are still not declaring your selArr correctly.
The declaration [Bindable]private var selArr:Array; is an instance variable.
It is defined outside of any function and is visible to anything in your object.

In your function
private function checkBox_change(evt:Event,x:Array):void {
selArr:Array = [];

selArr is defined as a local variable visible only within the function
checkBox_change. Since the names are the same you are overriding the instance
variable. (In reality this should not have compiled properly ... your first
try of var selArr:Array = [] was the valid syntax for overriding the variable)

To fix it you just need to change
selArr:Array = [] into selArr = [];




Reply With Quote
  #5 (permalink)  
Old 11-05-2008, 01:44 PM
alice_data
 
Posts: n/a
Diggs:
Default Re: Combine Two Arrays Using Actionscript in FlexApplications Errors

Hi,

I did what you mentioned here, and selArr did the trick.
However, it still does not give me what I was hoping to see, which I think I
have done something wrong here with the concat().

I was hoping that the Alert box would say something like 3/5 items selected,
and list the results of both what the client has generated in selArr2 and
selArr, which was concatenated and combined into selArr3. Currently, I would
get a message that say 4/3 items selected, even though it does return me with
the items I have selected from both selArr and selArr2.

To give things a better picture, below is the complete code I have:

Thanks very much for your help.

Alice

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="center" verticalAlign="top" layout="absolute"
width="100%" height="100%" creationComplete="my_book.send()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
import flash.display.Sprite;
import mx.controls.Alert;
import flash.events.*;
import flash.net.*;
import mx.controls.CheckBox;
[Bindable]private var selArr:Array;
[Bindable]private var len:int;

private function checkBox_change(evt:Event,x:Array):void {
selArr = [];
var idx:int;
var len:int =
my_book.lastResult.collection.store_id.author.leng th;
for (idx=0; idx<len; idx++) {
if (x[idx].selected) {
selArr.push(x[idx].label);
}
}
}
private function checkBox_change2(evt:Event,y:Array):void {

var selArr2:Array = [];
var idx:int;
var len2:int =
my_book.lastResult.collection.region_id.publisher. length;
for (idx=0; idx<len2; idx++) {
if (y[idx].selected) {
selArr2.push(y[idx].label);
}
}

var len3:int= len + len2;
var selArr3:Array= selArr2.concat(selArr);
var title2:String = selArr3.length + " of " + len3 + " item(s)
selected.";
var message2:String = selArr3.join("\n");
Alert.show(message2,title2);

}

]]>
</mx:Script>

<mx:HTTPService id="my_book" url="http://localhost/my_book.php"
useProxy="false"/>

<mx:TabNavigator id="tn2" width="271" height="50%" x="973" y="0">
<mx:Canvas id="panel" width="50%" x="973" y="34.95" label="Author
Information">
<mx:VBox>

<mx:Repeater id="checkBoxRepeater5"
dataProvider="{my_book.lastResult.collection.store _id.author}">
<mx:CheckBox id="checkBox"
label="{checkBoxRepeater5.currentItem.name}"
data="{checkBoxRepeater5.currentItem.name}"
change="checkBox_change(event,checkBox)" />
</mx:Repeater>
</mx:VBox>
</mx:Canvas>
<mx:Canvas id="panel2" width="50%" x="973" y="34.95" label="Publication
Info">
<mx:VBox>

<mx:Repeater id="checkBoxRepeater2"
dataProvider="{my_book.lastResult.collection.regio n_id.publisher}">
<mx:CheckBox id="checkBox2"
label="{checkBoxRepeater2.currentItem.name}"
data="{checkBoxRepeater2.currentItem.name}"
change="checkBox_change2(event,checkBox2)" />
</mx:Repeater>
</mx:VBox>
</mx:Canvas>

</mx:TabNavigator>
</mx:Application>

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 01:31 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