<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init()"
layout="absolute"
xmlns:ns1="components.*"
backgroundGradientColors="[#ffffff,#ffffff]" width="907" height="614" viewSourceURL="srcview/index.html">
<mx:Style>
Button
{
borderColor: #9BDB20;
color: #FFFFFF;
cornerRadius: 5;
fillAlphas: 1.0, 1.0, 1.0, 1.0;
fillColors: #94DA08, #72C142, #C8D9A6, #60C125;
fontAntiAliasType: advanced;
fontFamily: "Arial";
fontStyle: normal;
textAlign: right;
themeColor: #A2FF00;
fontWeight: bold;
leading: 0;
}
@font-face
{
fontFamily: "Arial";
fontWeight: bold;
fontStyle: italic;
}
@font-face
{
fontFamily: "Arial";
fontWeight: normal;
fontStyle: italic;
}
@font-face
{
fontFamily: "Arial";
fontWeight: bold;
fontStyle: normal;
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.events.CollectionEvent;
import mx.events.ColorPickerEvent;
import mx.events.IndexChangedEvent;
import flash.events.Event;
import flash.display.Bitmap;
import flash.display.BitmapData;
import components.*;
import flash.events.MouseEvent;
import mx.managers.PopUpManager;
import mx.core.IFlexDisplayObject;
import mx.messaging.messages.ErrorMessage;
import mx.charts.CategoryAxis;
import mx.events.DragEvent;
import mx.collections.ArrayCollection;
import mx.core.ScrollPolicy;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
public var previewTshirtFront:BitmapData ;
public var previewTshirtBack:BitmapData;
public var previewTshirtFrontContainer:Bitmap;
public var previewTshirtBackContainer:Bitmap;
private var myLoginForm:IFlexDisplayObject; private var myIndicateForm:IFlexDisplayObject; private var queryString:String; private var request:URLRequest;
private var mainImage:Loader;
[Bindable]
public var colorArray:ArrayCollection = new ArrayCollection();
public var colorArrayCollection:ArrayCollection = new ArrayCollection();
public const URLREMOTA:String="http://www.4e-commerce.com.br/caliopes";
public function init():void{
initTshirtFront(); initTshirtBack();
previewTshirtFrontContainer.visible = true;
previewTshirtBackContainer.visible = false;
pixArtBack.visible = false;
btnChangeToBack.visible = true;
btnChangeToFront.visible = false;
tshirtFrontColor.visible = true;
tshirtFrontLines.visible = true;
tshirtBackColor.visible = false;
tshirtBackLines.visible = false;
previewTshirt.addEventListener(Event.ENTER_FRAME,camisetaFrontUpdate);
queryString = Application.application.parameters.img;
if (queryString != ""){
pixArtFront.loadQueryStringImage(queryString);
}
getTamanhoProductInfo.send();
}
private function erroHTTPService(event:FaultEvent):void{
Alert.show("ERRO: "+event.message);
}
public function initTshirtBack():void{
previewTshirtBack = new BitmapData(pixArtBack.mainCanvas.width, pixArtBack.mainCanvas.height, true);
previewTshirtBack.draw(pixArtBack.mainCanvas);
previewTshirtBackContainer = new Bitmap(previewTshirtBack);
previewTshirtBackContainer.width = previewTshirt.width;
previewTshirtBackContainer.height = previewTshirt.height;
previewTshirt.addChild(previewTshirtBackContainer);
}
public function initTshirtFront():void{
previewTshirtFront = new BitmapData(pixArtFront.mainCanvas.width, pixArtFront.mainCanvas.height, true);
previewTshirtFront.draw(pixArtFront.mainCanvas);
previewTshirtFrontContainer = new Bitmap(previewTshirtFront);
previewTshirtFrontContainer.width = previewTshirt.width;
previewTshirtFrontContainer.height = previewTshirt.height;
previewTshirt.addChild(previewTshirtFrontContainer);
}
public function camisetaBackUpdate(evt:Event):void{
previewTshirtBack.draw(pixArtBack.mainCanvas,null,null,null,null,true);
}
public function camisetaFrontUpdate (evt:Event):void{
previewTshirtFront.draw(pixArtFront.mainCanvas,null,null,null,null,true);
}
public function showCamisetaBack(evt:MouseEvent):void{
if (previewTshirt.hasEventListener(Event.ENTER_FRAME))previewTshirt.removeEventListener(Event.ENTER_FRAME,camisetaFrontUpdate);
previewTshirt.addEventListener(Event.ENTER_FRAME,camisetaBackUpdate);
previewTshirtFrontContainer.visible = false;
previewTshirtBackContainer.visible = true;
pixArtBack.visible = true;
pixArtFront.visible = false;
btnChangeToBack.visible = false;
btnChangeToFront.visible = true;
tshirtFrontColor.visible = false;
tshirtFrontLines.visible = false;
tshirtBackColor.visible = true;
tshirtBackLines.visible = true;
lblTshirtSide.text = "FUNDO CAMISETA";
}
public function showCamisetaFront(evt:MouseEvent):void{
if (previewTshirt.hasEventListener(Event.ENTER_FRAME))previewTshirt.removeEventListener(Event.ENTER_FRAME,camisetaBackUpdate);
previewTshirt.addEventListener(Event.ENTER_FRAME,camisetaFrontUpdate);
previewTshirtFrontContainer.visible = true;
previewTshirtBackContainer.visible = false;
pixArtFront.visible = true;
pixArtBack.visible = false;
btnChangeToBack.visible = true;
btnChangeToFront.visible = false;
tshirtFrontColor.visible = true;
tshirtFrontLines.visible = true;
tshirtBackColor.visible = false;
tshirtBackLines.visible = false;
lblTshirtSide.text = "FRENTE CAMISETA";
}
public function changeTshirtColor(evt:ColorPickerEvent):void{
pixArtFront.mainCanvas.setStyle("backgroundColor", evt.color.toString());
pixArtBack.mainCanvas.setStyle("backgroundColor", evt.color.toString());
var colorTransform:ColorTransform = tshirtFrontColor.transform.colorTransform;
colorTransform.color = evt.color;
tshirtFrontColor.transform.colorTransform = colorTransform;
tshirtBackColor.transform.colorTransform = colorTransform;
}
private function showPopUp(e:MouseEvent):void { if (e.currentTarget.name == "buyBtn"){
myLoginForm = PopUpManager.createPopUp(this, LoginForm, true);
}else {
myIndicateForm = PopUpManager.createPopUp(this, IndicateForm, true);
}
}
private function carregarProdutoInfo(event:ResultEvent):void{
var informacoes:XML;
informacoes=XML(event.result);
informacoes.normalize();
var dados:XMLList = informacoes.data;
var varSize:String ="Color";
for(var i:int =0; i<(dados.length()); i++){
if(varSize==dados[i].attribute("id").toString()){
for(var j:int =0; j<(dados[i].option.length()); j++){
colorArray.addItem(dados[i].option[j].toString());
colorArrayCollection.addItem(dados[i].option[j]);
}
}
}
pixArtFront.mainCanvas.setStyle("backgroundColor", tshirtColorPicker.selectedColor.toString());
pixArtBack.mainCanvas.setStyle("backgroundColor", tshirtColorPicker.selectedColor.toString());
var colorTransform:ColorTransform = tshirtFrontColor.transform.colorTransform;
colorTransform.color = tshirtColorPicker.selectedColor;
tshirtFrontColor.transform.colorTransform = colorTransform;
tshirtBackColor.transform.colorTransform = colorTransform;
}
]]>
</mx:Script>
<mx:HTTPService id="getTamanhoProductInfo" url="http://www.4e-commerce.com.br/caliopes/crex_read.php" method="POST" showBusyCursor="true" resultFormat="e4x"
result="carregarProdutoInfo(event)" >
<mx:request xmlns="">
<cmd>get_product_attributes</cmd>
<pid>28</pid>
</mx:request>
</mx:HTTPService>
<mx:HTTPService id="srv" url="process.php" method="POST" showBusyCursor="true" resultFormat="e4x"/>
<mx:Button label="Comprar" click="showPopUp(event)" x="666" y="493" labelPlacement="right" color="#000000" id="buyBtn"/>
<mx:Button label="Indique" click="showPopUp(event)" x="777" y="493" labelPlacement="right" color="#000000" id="indicateBtn" />
<mx:Image x="614" y="101" toolTip="Preview de sua camiseta" id="tshirtBackColor" width="271" height="255">
<mx:source>components/assets/tshirtBackBackground.swf</mx:source>
</mx:Image>
<mx:Image x="614" y="101" toolTip="Preview de sua camiseta" id="tshirtBackLines" width="271" height="255">
<mx:source>components/assets/tshirtBackLines.swf</mx:source>
</mx:Image>
<mx:Image x="614" y="101" toolTip="Preview de sua camiseta" id="tshirtFrontColor" width="271" height="255">
<mx:source>components/assets/tshirtFrontBackground.swf</mx:source>
</mx:Image>
<mx:Image x="614" y="101" toolTip="Preview de sua camiseta" id="tshirtFrontLines" width="271" height="255">
<mx:source>components/assets/tshirtFrontLines.swf</mx:source>
</mx:Image>
<mx:Image x="689" y="154" height="175" width="121" id="previewTshirt" showEffect="Fade"/>
<mx:Label x="630" y="63.85" text="CAMISETA MASCULINA 100% ALGODÃO" fontFamily="TimesNewsRoman" fontStyle="italic" fontWeight="bold" color="#5F322C" fontSize="12"/>
<mx:Label x="693" y="399.95" text="FRENTE CAMISETA" fontFamily="TimesNewsRoman" fontStyle="italic" fontWeight="bold" color="#5F322C" fontSize="12" id="lblTshirtSide"/>
<mx:Label x="693" y="364.95" text="Cor da camiseta" fontFamily="TimesNewsRoman" fontStyle="italic" fontWeight="bold" color="#5F322C" fontSize="12" id="label0"/>
<ns1:PixArt x="10" y="10" id="pixArtFront" showGuide="false" horizontalScrollPolicy="off" verticalScrollPolicy="off" guideWidth="244" guideHeight="355"
filePath="process.php" clientGetsCopy="true"
clipArtSource="http://4e-commerce.com.br/caliopes/processed/clipart.xml" borderColor="#FFFFFF" backgroundColor="#FFFFFF" backgroundAlpha="0"
processedPixLocation="{URLREMOTA+'/processed'}"
rawPixLocation="{URLREMOTA+'/pix'">
</ns1:PixArt>
<mx:Button x="702" y="429" label="Fundo Camiseta"
labelPlacement="right"
click="showCamisetaBack(event)" id="btnChangeToBack" color="#000000"
toolTip="Clique para editar o fundo de sua camiseta"/>
<mx:Button x="702" y="429" label="Frente Camiseta"
labelPlacement="right"
click="showCamisetaFront(event)" id="btnChangeToFront" color="#000000"
toolTip="Clique para editar a frente de sua camiseta"/>
<ns1:PixArt x="10" y="10" id="pixArtBack" showGuide="false" horizontalScrollPolicy="off" verticalScrollPolicy="off" guideWidth="244" guideHeight="355"
filePath="process.php" clientGetsCopy="false"
clipArtSource="http://4e-commerce.com.br/caliopes/processed/clipart.xml" borderColor="#FFFFFF" backgroundColor="#FFFFFF" backgroundAlpha="0" visible="true"
processedPixLocation="{URLREMOTA+'/processed'}"
rawPixLocation="{URLREMOTA+'/pix'}">
</ns1:PixArt>
<mx:ColorPicker x="666" y="363" dataProvider="{colorArray}" id="tshirtColorPicker" enabled="true" selectedColor="#FFFFFF"
change="changeTshirtColor(event)" itemRollOver="changeTshirtColor(event)"/>
</mx:Application>