[flexcoders] Re: getting the total of values of an array collection that is updated manually

2011-12-09 Thread ZIONIST
Hi Guys, i have finally got the total to update when new items are added to the 
cart. One thing that i have failed to do is to get the total to update when 
quantity is changed and when a product is removed from the cart(list 
component). Any help on this? Here is the latest code that only gets the total 
to update when a new product is added.

App


?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
layout=horizontal
xmlns:ns1=*
xmlns:ns2=as_logic.*
mx:states
mx:State name=dark
mx:SetProperty target={product}
name=text
value=Dark Chocolate/
mx:SetProperty target={price}
name=text
value=50/
/mx:State
mx:State name=spread
mx:SetProperty target={product}
name=text
value=Drinking 
Chocolate/
mx:SetProperty target={price}
name=text
value=100/
/mx:State
/mx:states

mx:Script
![CDATA[
import mx.controls.listClasses.ListData;
import mx.collections.ArrayCollection;

[Bindable]
private var orderColl:ArrayCollection=new 
ArrayCollection();

private function addProduct():void
{

//Create an object to hold the data
var obj:Object=new Object();
//Assign the variables to it
obj.Product=product.text;
obj.Price=price.text;
//Add the object to the list
orderColl.addItemAt(obj, 0);

}

public function deleteOrder():void
{

//Remove the item from the array collection
orderColl.removeItemAt(products.selectedIndex);

}   

public function init():void
{
var total:Number=0;
for (var i:String in orderColl)
{
total+=Number(orderColl[i].Price);
}
sum.text=usdFormatter.format(total.toString());
}
]]
/mx:Script

mx:DefaultTileListEffect id=dtle0
  fadeOutDuration=300
  fadeInDuration=300
  moveDuration=650
  color=0xff/

mx:CurrencyFormatter id=usdFormatter
  precision=0
  currencySymbol=$
  alignSymbol=left/


mx:Canvas width=500
   height=300
mx:Label x=10
  y=10
  text=Milk Chocolate
  id=product/
mx:Label x=10
  y=36
  text=10
  id=price/
mx:Button x=10
   y=62
   label=submit
   click=addProduct();init()/
mx:Button x=10
   y=92
   label=Change State
   click=currentState='dark'/
mx:Button x=10
   y=122
   label=Drinking Chocolate
   click=currentState='spread'/
/mx:Canvas

mx:VBox width=340
 height=340
 horizontalAlign=center
 verticalAlign=middle

ns2:transparentList id=products
 width=300
 

Re: [flexcoders] Re: getting the total of values of an array collection that is updated manually

2011-12-09 Thread Csomák Gábor
public function *deleteOrder*():void{
orderColl.removeItemAt(products.selectedIndex);
*init()*
}

private function *addProduct*():void
{

//Create an object to hold the data
var obj:Object=new Object();
//Assign the variables to it
obj.Product=product.text;
obj.Price=price.text;
//Add the object to the list
orderColl.addItemAt(obj, 0);
*init()*
}
On Fri, Dec 9, 2011 at 4:52 PM, ZIONIST stinas...@yahoo.com wrote:



 Hi Guys, i have finally got the total to update when new items are added
 to the cart. One thing that i have failed to do is to get the total to
 update when quantity is changed and when a product is removed from the
 cart(list component). Any help on this? Here is the latest code that only
 gets the total to update when a new product is added.


 App

 ?xml version=1.0 encoding=utf-8?
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
 layout=horizontal
 xmlns:ns1=*
 xmlns:ns2=as_logic.*

 mx:states
 mx:State name=dark
 mx:SetProperty target={product}
 name=text
 value=Dark Chocolate/
 mx:SetProperty target={price}
 name=text
 value=50/
 /mx:State
 mx:State name=spread
 mx:SetProperty target={product}
 name=text
 value=Drinking Chocolate/
 mx:SetProperty target={price}
 name=text
 value=100/
 /mx:State
 /mx:states

 mx:Script
 ![CDATA[
 import mx.controls.listClasses.ListData;
 import mx.collections.ArrayCollection;

 [Bindable]
 private var orderColl:ArrayCollection=new ArrayCollection();

 private function addProduct():void
 {

 //Create an object to hold the data
 var obj:Object=new Object();
 //Assign the variables to it
 obj.Product=product.text;
 obj.Price=price.text;
 //Add the object to the list
 orderColl.addItemAt(obj, 0);

 }

 public function deleteOrder():void

 {

 //Remove the item from the array collection
 orderColl.removeItemAt(products.selectedIndex);

 }

 public function init():void
 {
 var total:Number=0;
 for (var i:String in orderColl)
 {
 total+=Number(orderColl[i].Price);
 }
 sum.text=usdFormatter.format(total.toString());
 }
 ]]
 /mx:Script

 mx:DefaultTileListEffect id=dtle0
 fadeOutDuration=300
 fadeInDuration=300
 moveDuration=650
 color=0xff/

 mx:CurrencyFormatter id=usdFormatter
 precision=0
 currencySymbol=$
 alignSymbol=left/


 mx:Canvas width=500
 height=300
 mx:Label x=10
 y=10
 text=Milk Chocolate
 id=product/
 mx:Label x=10
 y=36
 text=10
 id=price/
 mx:Button x=10
 y=62
 label=submit
 click=addProduct();init()/
 mx:Button x=10
 y=92
 label=Change State
 click=currentState='dark'/
 mx:Button x=10
 y=122
 label=Drinking Chocolate
 click=currentState='spread'/
 /mx:Canvas

 mx:VBox width=340
 height=340
 horizontalAlign=center
 verticalAlign=middle

 ns2:transparentList id=products

 width=300
 height=300
 dataProvider={orderColl}
 borderStyle=none
 itemsChangeEffect={dtle0}
 ns2:itemRenderer
 mx:Component
 mx:HBox width=100%

 height=100%
 horizontalAlign=center
 verticalAlign=middle
 horizontalGap=0
 mx:Image source=assets/trashcan.gif
 click=outerDocument.deleteOrder()/

 mx:Label text={data.Product}
 styleName=orderLabel/
 mx:Spacer width=100%/
 mx:Label id=price
 text=${Number(qty.text)* Number(oldPrice.text)}
 styleName=orderLabel/
 mx:TextInput id=qty
 width=30
 height=20
 text=1
 styleName=qtyInput/

 mx:Label id=oldPrice
 text={data.Price}
 visible=false
 includeInLayout=false/
 /mx:HBox
 /mx:Component
 /ns2:itemRenderer
 /ns2:transparentList

 mx:HBox
 mx:Label text=Total:
 color=#FF
 fontWeight=bold/
 mx:Label id=sum/

 /mx:HBox
 /mx:VBox

 /mx:Application

  



Re: [flexcoders] how to make drag and drop in flex 3

2011-12-09 Thread Sathya Moorthi K
refer the following links

http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_4.html#174194

http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_6.html#247937

http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_7.html#247940

http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_8.html#225115


Best Regards,

Sathya Moorthi K | MCA,
mailto: ksathy...@gmail.com**


On Thu, Dec 8, 2011 at 12:55 PM, azHanie adroi...@excite.com wrote:

 **


 hi,

 i have problem here. i have list of images to be arranged according to the
 ranking. however, i cant drop the image. below is the code. may i know
 where's the mistake?
 __

 ?xml version=1.0 encoding=utf-8?
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
 layout=vertical
 horizontalAlign=center
 backgroundGradientAlphas=[1.0, 1.0]
 backgroundGradientColors=[#FF, #FF]
 creationComplete=service.send() viewSourceURL=srcview/index.html

 mx:Script
 ![CDATA[
 import mx.core.DragSource;
 import mx.collections.ArrayCollection;
 import mx.rpc.events.ResultEvent;
 import mx.events.DragEvent;
 import mx.managers.DragManager;
 import mx.core.UIComponent

 [Bindable]
 private var images:ArrayCollection;

 private function serviceHandler(event:ResultEvent):void{
 images = event.result.gallery.image;
 }

 private function initiateDrag(event:MouseEvent,value:String):void{

 var dragInitiator:Image= event.currentTarget as Image;

 var dragSource:DragSource = new DragSource();
 dragSource.addData(value, 'value');

 var dragProxy:Image = new Image();
 dragProxy.source = event.currentTarget.source;
 dragProxy.width = 100 ;
 dragProxy.height = 100 ;

 DragManager.doDrag(dragInitiator, dragSource, event, dragProxy);
 }

 private function dragEnterHandler(event:DragEvent):void {
 var dropTarget:List=event.currentTarget as List;
 if (event.dragSource.hasFormat('value')) {
 DragManager.acceptDragDrop(dropTarget);
 }


 {
 DragManager.acceptDragDrop(UIComponent(event.target));
 }
 }

 ]]
 /mx:Script

 mx:HTTPService id=service url=datas.xml
 result=serviceHandler(event)/

 mx:Label text=Drag a thumbnail image inside the black box and drop it to
 display its bigger version/

 mx:HBox
 mx:Repeater dataProvider={images} id=rep
 mx:Image source=assets/thumbs/{rep.currentItem}
 mouseMove=initiateDrag(event,event.currentTarget.getRepeaterItem()) /
 /mx:Repeater
 /mx:HBox
 mx:List
 iconField=image_pic
 dragEnabled=true
 dropEnabled=true
 dragMoveEnabled=true
 rowCount=1
 columnCount=1
 rowHeight=60
 columnWidth=60
 verticalScrollPolicy=off
 alternatingItemColors=[#D3D3D3, #DDDADA]
 width=81 height=63
 paddingLeft=1 paddingRight=1 paddingTop=1 paddingBottom=1/
 mx:List
 iconField=image_pic
 dragEnabled=true
 dropEnabled=true
 dragMoveEnabled=true
 rowCount=1
 columnCount=1
 rowHeight=60
 columnWidth=60
 verticalScrollPolicy=off
 alternatingItemColors=[#D3D3D3, #DDDADA]
 width=81 height=63
 paddingLeft=1 paddingRight=1 paddingTop=1 paddingBottom=1/
 mx:List
 iconField=image_pic
 dragEnabled=true
 dropEnabled=true
 dragMoveEnabled=true
 rowCount=1
 columnCount=1
 rowHeight=60
 columnWidth=60
 verticalScrollPolicy=off
 alternatingItemColors=[#D3D3D3, #DDDADA]
 width=81 height=63
 paddingLeft=1 paddingRight=1 paddingTop=1 paddingBottom=1/
 mx:List
 iconField=image_pic
 dragEnabled=true
 dropEnabled=true
 dragMoveEnabled=true
 rowCount=1
 columnCount=1
 rowHeight=60
 columnWidth=60
 verticalScrollPolicy=off
 alternatingItemColors=[#D3D3D3, #DDDADA]
 width=81 height=63
 paddingLeft=1 paddingRight=1 paddingTop=1 paddingBottom=1/

 /mx:Application

 thnks


  



[flexcoders] Re: Needs to word wrap on FormItem label

2011-12-09 Thread valdhor
http://www.nbilyk.com/multiline-formitem-label

--- In flexcoders@yahoogroups.com, koti reddy koti_reddy972@... wrote:

 Hi,
 
 I have been fighting to wrap text the FormItem label using css but can't able 
 to achieve the task.
 
 Could any of you please suggest me what should i do if i have a too long 
 label and needs to wrap to half.
 
 I really appreciate your help.
 Koti





Re: [flexcoders] Re: getting the total of values of an array collection that is updated manually

2011-12-09 Thread claudiu ursica
You know there is an working example in this book pretty close to your, is flex 
4 though but you will get the picture.


http://www.amazon.com/Adobe-Flex-Training-Michael-Labriola/dp/0321660501


C




 From: ZIONIST stinas...@yahoo.com
To: flexcoders@yahoogroups.com 
Sent: Friday, December 9, 2011 4:52 PM
Subject: [flexcoders] Re: getting the total of values of an array collection 
that is updated manually
 

  
Hi Guys, i have finally got the total to update when new items are added to the 
cart. One thing that i have failed to do is to get the total to update when 
quantity is changed and when a product is removed from the cart(list 
component). Any help on this? Here is the latest code that only gets the total 
to update when a new product is added.

App

?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
layout=horizontal
xmlns:ns1=*
xmlns:ns2=as_logic.*
mx:states
mx:State name=dark
mx:SetProperty target={product}
name=text
value=Dark Chocolate/
mx:SetProperty target={price}
name=text
value=50/
/mx:State
mx:State name=spread
mx:SetProperty target={product}
name=text
value=Drinking Chocolate/
mx:SetProperty target={price}
name=text
value=100/
/mx:State
/mx:states

mx:Script
![CDATA[
import mx.controls.listClasses.ListData;
import mx.collections.ArrayCollection;

[Bindable]
private var orderColl:ArrayCollection=new ArrayCollection();

private function addProduct():void
{

//Create an object to hold the data
var obj:Object=new Object();
//Assign the variables to it
obj.Product=product.text;
obj.Price=price.text;
//Add the object to the list
orderColl.addItemAt(obj, 0);

}

public function deleteOrder():void
{

//Remove the item from the array collection
orderColl.removeItemAt(products.selectedIndex);

} 

public function init():void
{
var total:Number=0;
for (var i:String in orderColl)
{
total+=Number(orderColl[i].Price);
}
sum.text=usdFormatter.format(total.toString());
}
]]
/mx:Script

mx:DefaultTileListEffect id=dtle0
fadeOutDuration=300
fadeInDuration=300
moveDuration=650
color=0xff/

mx:CurrencyFormatter id=usdFormatter
precision=0
currencySymbol=$
alignSymbol=left/

mx:Canvas width=500
height=300
mx:Label x=10
y=10
text=Milk Chocolate
id=product/
mx:Label x=10
y=36
text=10
id=price/
mx:Button x=10
y=62
label=submit
click=addProduct();init()/
mx:Button x=10
y=92
label=Change State
click=currentState='dark'/
mx:Button x=10
y=122
label=Drinking Chocolate
click=currentState='spread'/
/mx:Canvas

mx:VBox width=340
height=340
horizontalAlign=center
verticalAlign=middle

ns2:transparentList id=products
width=300
height=300
dataProvider={orderColl}
borderStyle=none
itemsChangeEffect={dtle0}
ns2:itemRenderer
mx:Component
mx:HBox width=100%
height=100%
horizontalAlign=center
verticalAlign=middle
horizontalGap=0
mx:Image source=assets/trashcan.gif
click=outerDocument.deleteOrder()/
mx:Label text={data.Product}
styleName=orderLabel/
mx:Spacer width=100%/
mx:Label id=price
text=${Number(qty.text)* Number(oldPrice.text)}
styleName=orderLabel/
mx:TextInput id=qty
width=30
height=20
text=1
styleName=qtyInput/

mx:Label id=oldPrice
text={data.Price}
visible=false
includeInLayout=false/
/mx:HBox
/mx:Component
/ns2:itemRenderer
/ns2:transparentList
mx:HBox
mx:Label text=Total:
color=#FF
fontWeight=bold/
mx:Label id=sum/
/mx:HBox
/mx:VBox

/mx:Application


 

Re: [flexcoders] Re: getting the total of values of an array collection that is updated manually

2011-12-09 Thread Alex Harui
I haven’t been following this thread, and without looking at the book:

If you assume there won’t be more than 100 things in the cart, it is just as 
easy to add them all up every time there is a change.  Then some setup code 
should call:

orderColl.addEventListener(CollectionEvent.COLLECTION_CHANGE, calculateSum);

And calculate sum would do something like:

private function calculateSum(event:CollectionEvent):void
{
var amt:Number = 0;
var n:int = orderColl.length;
for (var i:int = 0; I  n; i++)
{
var cartEntry:Object = orderColl.getItemAt(i);
amt += cartEntry.quantity * cartEntry.price;
}
sum.text = amt.toPrecision(2);
}

On 12/9/11 2:09 PM, claudiu ursica the_bran...@yahoo.com wrote:






You know there is an working example in this book pretty close to your, is flex 
4 though but you will get the picture.

http://www.amazon.com/Adobe-Flex-Training-Michael-Labriola/dp/0321660501

C





 From: ZIONIST stinas...@yahoo.com
 To: flexcoders@yahoogroups.com
 Sent: Friday, December 9, 2011 4:52 PM
 Subject: [flexcoders] Re: getting the total of values of an array collection 
that is updated manually



Hi Guys, i have finally got the total to update when new items are added to the 
cart. One thing that i have failed to do is to get the total to update when 
quantity is changed and when a product is removed from the cart(list 
component). Any help on this? Here is the latest code that only gets the total 
to update when a new product is added.

App

?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
layout=horizontal
xmlns:ns1=*
xmlns:ns2=as_logic.*
mx:states
mx:State name=dark
mx:SetProperty target={product}
name=text
value=Dark Chocolate/
mx:SetProperty target={price}
name=text
value=50/
/mx:State
mx:State name=spread
mx:SetProperty target={product}
name=text
value=Drinking Chocolate/
mx:SetProperty target={price}
name=text
value=100/
/mx:State
/mx:states

mx:Script
![CDATA[
import mx.controls.listClasses.ListData;
import mx.collections.ArrayCollection;

[Bindable]
private var orderColl:ArrayCollection=new ArrayCollection();

private function addProduct():void
{

//Create an object to hold the data
var obj:Object=new Object();
//Assign the variables to it
obj.Product=product.text;
obj.Price=price.text;
//Add the object to the list
orderColl.addItemAt(obj, 0);

}

public function deleteOrder():void
{

//Remove the item from the array collection
orderColl.removeItemAt(products.selectedIndex);

}

public function init():void
{
var total:Number=0;
for (var i:String in orderColl)
{
total+=Number(orderColl[i].Price);
}
sum.text=usdFormatter.format(total.toString());
}
]]
/mx:Script

mx:DefaultTileListEffect id=dtle0
  fadeOutDuration=300
  fadeInDuration=300
  moveDuration=650
  color=0xff/

mx:CurrencyFormatter id=usdFormatter
  precision=0
  currencySymbol=$
  alignSymbol=left/

mx:Canvas width=500
   height=300
mx:Label x=10
  y=10
  text=Milk Chocolate
  id=product/
mx:Label x=10
  y=36
  text=10
  id=price/
mx:Button x=10
   y=62
   label=submit
   click=addProduct();init()/
mx:Button x=10
   y=92
   label=Change State
   click=currentState='dark'/
mx:Button x=10
   y=122
   label=Drinking Chocolate
   click=currentState='spread'/
/mx:Canvas

mx:VBox width=340
 height=340
 horizontalAlign=center
 verticalAlign=middle

ns2:transparentList id=products
 width=300
 height=300
 dataProvider={orderColl}
 borderStyle=none
 itemsChangeEffect={dtle0}
ns2:itemRenderer
mx:Component
mx:HBox width=100%
 height=100%
 horizontalAlign=center
 verticalAlign=middle
 horizontalGap=0
mx:Image source=assets/trashcan.gif
  click=outerDocument.deleteOrder()/
mx:Label text={data.Product}
  styleName=orderLabel/
mx:Spacer width=100%/
mx:Label id=price
  text=${Number(qty.text)* Number(oldPrice.text)}
  styleName=orderLabel/
mx:TextInput id=qty
  width=30
  height=20
  text=1
  styleName=qtyInput/

mx:Label id=oldPrice
  text={data.Price}
  visible=false
  includeInLayout=false/
/mx:HBox
/mx:Component
/ns2:itemRenderer
/ns2:transparentList
mx:HBox
mx:Label text=Total:
  color=#FF
  fontWeight=bold/
mx:Label id=sum/
/mx:HBox
/mx:VBox

/mx:Application













--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui


[flexcoders] app:/file.swf not being loaded into HTMLLoader (AIR)

2011-12-09 Thread mattgarland2000
It's not showing up.

I have a simple html file in src directory (preview.html)

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
html xmlns=http://www.w3.org/1999/xhtml; lang=en xml:lang=en
body
div id=flashContent height=675 width=1010
object type='application/x-shockwave-flash' width='100%' height='100%' 
id=flash 
param name=movie value=app:/main.swf/
param name=wmode value=opaque/
/object
/body
/div
/html

It is embedded as a string and loaded by an htmlLoader:

[Embed(source=preview.html, 
mimeType=application/octet-stream)]
private var previewStr:Class;

var html:HTMLLoader = new HTMLLoader();
var bytes:ByteArray = new previewStr();
var preview:String = 
bytes.readUTFBytes(bytes.length)
html.loadString(preview);
html.height=675;
html.width=1010;
var wrapper:UIComponent=new UIComponent();
wrapper.addChild(html);
addElement(wrapper);

The window appears...but without the swf. Does anyone know why?



[flexcoders] Re: app:/file.swf not being loaded into HTMLLoader (AIR)

2011-12-09 Thread mattgarland2000
I had to wait until the load before I added it to the display list...:)

--- In flexcoders@yahoogroups.com, mattgarland2000 alias@... wrote:

 It's not showing up.
 
 I have a simple html file in src directory (preview.html)
 
 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN 
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
 html xmlns=http://www.w3.org/1999/xhtml; lang=en xml:lang=en
   body
   div id=flashContent height=675 width=1010
   object type='application/x-shockwave-flash' width='100%' height='100%' 
 id=flash 
   param name=movie value=app:/main.swf/
   param name=wmode value=opaque/
   /object
   /body
   /div
 /html
 
 It is embedded as a string and loaded by an htmlLoader:
 
   [Embed(source=preview.html, 
 mimeType=application/octet-stream)]
   private var previewStr:Class;
 
 var html:HTMLLoader = new HTMLLoader();
   var bytes:ByteArray = new previewStr();
   var preview:String = 
 bytes.readUTFBytes(bytes.length)
   html.loadString(preview);
   html.height=675;
   html.width=1010;
   var wrapper:UIComponent=new UIComponent();
   wrapper.addChild(html);
   addElement(wrapper);
 
 The window appears...but without the swf. Does anyone know why?