MEU JISUIS CRISTIM!!!  que tamanho de código difícil!

    Bom...  fiz o seguinte...  coloquei um prontiJob imprimindo pra te 
mostrar como funciona a lógica usando seu código mesmo.  Mas precisa 
mexer ainda pra conseguir um bom resultado final ok?
    O normal de usar o flexPrintJob é ter um MXML específico para ser 
enviado à impressora. Isso porque é mais dificil de enxergar quando vc 
muda tanto a tela usando o states.  E a tela feita para impressão 
costuma ser muito diferente do que a visualizada no monitor.
    Pra fazer usando o seu jeito (com states) vc precisa colocar uma 
HBox que seja pai de todos os outros componentes e dar um ID a ela.  
Depois vc adiciona ao FlexPrintJob esse id.
    eu fiz o exemplo usando sua Hbox chamada: hbox12...  mas o correto 
mesmo é alguma outra que seja mais externa mas eu achei dificil 
encontrar..  então deixo contigo.

primeira coisa é criar a função que trata a impressão:

private function imprime():void {
                var printJob:FlexPrintJob = new FlexPrintJob();
                printJob.printAsBitmap = false;
               
                if (printJob.start()) {
                   
                    this.width=printJob.pageWidth;
                    this.height=printJob.pageHeight;
                   
                    printJob.addObject( hbox12 );
                   
                    printJob.send();
                }
            }

lembrando de adicionar o import do FlexPrintJob:
import mx.printing.FlexPrintJob;


depois vc precisa fazer o botão de "imprimir" chamar esse codigo:
<mx:Button label="Imprimir" click="imprime()"/>


e boa.  Já deve imprimir. Mas procure fazer um mxml separado. Fica bem 
mais tranquilo de programar.  Olha na documentação do FlexPrintJob que 
tem um exemplo bem tranquilo lá.


    Abraço,
    Luís Eduardo



FabianoB escreveu:
> <b>Olá Luiz Eduardo, ta na mão o código, se puder ajudar agradeço,
> valeu mesmo.</b>
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute" backgroundGradientColors="[#ffffff, #ff7d7d]"
> height="750" width="780">
>
>
>       <mx:Script>
>               <![CDATA[
>                       import mx.rpc.events.ResultEvent;
>
>                       public function gravarUsuario(): void {
>                               roMeuProjeto.gravarUsuario.send();
>                                currentState="imprimir"
>                       }
>
>
>               ]]>
>       </mx:Script>
>
>
>
>
>       <mx:states>
>               <mx:State name="imprimir">
>                       <mx:RemoveChild target="{button1}"/>
>                       <mx:RemoveChild target="{text1}"/>
>                       <mx:RemoveChild target="{applicationcontrolbar1}"/>
>                       <mx:RemoveChild target="{text6}"/>
>                       <mx:RemoveChild target="{hbox13}"/>
>                       <mx:RemoveChild target="{form1}"/>
>                       <mx:RemoveChild target="{text7}"/>
>                       <mx:AddChild position="lastChild">
>                               <mx:HBox x="57" y="161" width="658" height="44">
>                                       <mx:Text text="Seu cadastro foi 
> efetuado com sucesso! Clique no
> botão ao lado para imprimir sua solicitação de reserva"
> textAlign="center" width="487" fontWeight="bold" height="38"
> fontSize="13"/>
>                                       <mx:Button label="Imprimir"/>
>                               </mx:HBox>
>                       </mx:AddChild>
>                       <mx:SetProperty target="{hbox12}" name="height" 
> value="447"/>
>                       <mx:SetProperty target="{hbox12}" name="y" value="213"/>
>                       <mx:AddChild relativeTo="{hbox12}" position="lastChild">
>                               <mx:Form width="100%" height="100%">
>                                       <mx:HBox width="615" height="22">
>                                               <mx:FormItem label="Data:">
>                                                       <mx:Label text="Label" 
> width="101"/>
>                                               </mx:FormItem>
>                                               <mx:FormItem label="Hora:">
>                                                       <mx:Label text="Label" 
> width="101"/>
>                                               </mx:FormItem>
>                                               <mx:FormItem label="Código:">
>                                                       <mx:Label text="Label" 
> width="101"/>
>                                               </mx:FormItem>
>                                       </mx:HBox>
>                                       <mx:FormItem label="Nome" 
> fontWeight="bold">
>                                               <mx:TextInput width="547" 
> editable="false"/>
>                                       </mx:FormItem>
>                                       <mx:FormItem label="E-mail" 
> fontWeight="bold">
>                                               <mx:TextInput width="547" 
> editable="false"/>
>                                       </mx:FormItem>
>                                       <mx:FormItem label="Telefone" 
> fontWeight="bold">
>                                               <mx:TextInput width="274" 
> editable="false"/>
>                                       </mx:FormItem>
>                                       <mx:HBox width="526" height="20" 
> id="hbox8">
>                                                                       
> <mx:Text text="Nome dos acompanhantes" width="234"
> textAlign="left" fontWeight="bold"/>
>                                                                       
> <mx:Text text="Data de nascimento" width="265"
> textAlign="right" fontWeight="bold"/>
>                                       </mx:HBox>
>                                       <mx:HBox width="535" height="23" 
> id="hbox16">
>                                                                       
> <mx:Label text="Label" width="378"/>
>                                                                       
> <mx:Spacer width="20" height="20"/>
>                                                                       
> <mx:Label text="Label" width="118"/>
>                                       </mx:HBox>
>                                       <mx:HBox width="535" height="23" 
> id="hbox14">
>                                                                       
> <mx:Label text="Label" width="378"/>
>                                                                       
> <mx:Spacer width="20" height="20"/>
>                                                                       
> <mx:Label text="Label" width="118"/>
>                                       </mx:HBox>
>                                       <mx:HBox width="535" height="23" 
> id="hbox15">
>                                                                       
> <mx:Label text="Label" width="378"/>
>                                                                       
> <mx:Spacer width="20" height="20"/>
>                                                                       
> <mx:Label text="Label" width="118"/>
>                                       </mx:HBox>
>                                       <mx:Text text="Período(s) escolhido(s)" 
> width="234"
> textAlign="left" fontWeight="bold"/>
>                                               <mx:HBox width="615" 
> height="22">
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                               </mx:HBox>
>                                               <mx:HBox width="615" 
> height="22">
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                               </mx:HBox>
>                                               <mx:HBox width="615" 
> height="22">
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                               </mx:HBox>
>                                               <mx:HBox width="615" 
> height="22">
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                               </mx:HBox>
>                                               <mx:HBox width="615" 
> height="22">
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                               </mx:HBox>
>                                               <mx:HBox width="615" 
> height="22">
>                                                               <mx:Label 
> text="Label" width="301"/>
>                                                               <mx:Text 
> text="Andar de preferência:" fontWeight="bold"/>
>                                                               <mx:Label 
> text="Label" width="91"/>
>                                               </mx:HBox>
>
>                               </mx:Form>
>                       </mx:AddChild>
>                       <mx:SetProperty name="height" value="100%"/>
>                       <mx:AddChild position="lastChild">
>                               <mx:VBox x="58" y="668" height="312" 
> width="666">
>                                       <mx:Text text="Observações:" 
> width="284" height="20"
> fontWeight="bold"/>
>                                       <mx:Text width="284" height="20" 
> text="a) Horário de entrada: 16
> horas" fontWeight="bold"/>
>                                       <mx:Text width="284" height="20" 
> text="b) Horário de saída: 10
> horas" fontWeight="bold"/>
>                                       <mx:Text width="666" height="31" 
> text="c) Desistência: é
> obrigatória a comunicação com 10 dias de antecedência ao início do
> período requerido, sob pena de pagamento integral." fontWeight="bold"/
>   
>                                       <mx:Text width="666" height="20" 
> text="d) As roupas de cama, de
> banho e redes de descanso para a sacada, devem ser levadas pelo
> associado." fontWeight="bold"/>
>                                       <mx:Text text="A APMP cobrará para a 
> próxima temporada, o pacote
> no valor de R$ 450,00 (quatrocentos e cinqüenta reais), importância
> correspondente a 07 (sete) diárias, incluído o café da manhã para até
> 05 (cinco) pessoas por apartamento e taxa de limpeza. O valor será
> descontado na folha de pagamento do mês subseqüente ao uso, mediante
> autorização concedida pelo associado no ato da inscrição." width="666"
> height="61" textAlign="left"/>
>                                       <mx:Text width="666" height="37" 
> textAlign="left">
>                                               <mx:text>As normas de 
> utilização são as constantes do
> Regulamento Geral do Uso de Bens da Sede Litorânea, sendo que qualquer
> reclamação deverá ser encaminhada, por escrito, aos diretores da
> Sede.</mx:text>
>                                       </mx:Text>
>                                       <mx:Text text="Maiores informações 
> poderão ser obtidas junto a
> Secretaria da APMP com Silvana (0xx41) 3352-2919."/>
>                                       <mx:Text text="Limitando-nos ao 
> exposto, presta-se a ocasião para
> manifestarmos a Vossa Excelência a garantia de nosso apreço e estima
> pessoal." width="664"/>
>                               </mx:VBox>
>                       </mx:AddChild>
>                       <mx:SetProperty name="width" value="100%"/>
>                       <mx:AddChild position="lastChild">
>                               <mx:Text text="Maria Tereza Uille Gomes 
> Presidente APMP"
> textAlign="center" width="149" fontWeight="bold" y="988"
> horizontalCenter="0"/>
>                       </mx:AddChild>
>                       <mx:AddChild position="lastChild">
>                               <mx:Text text="Marcia Isabele Graf Beninca 
> Diretora"
> textAlign="center" width="207" fontWeight="bold" y="1037"
> horizontalCenter="-240.5"/>
>                       </mx:AddChild>
>                       <mx:AddChild position="lastChild">
>                               <mx:Text textAlign="center" width="151" 
> fontWeight="bold" y="1037"
> horizontalCenter="275.5" text="Wilson José Galheira Diretor"/>
>                       </mx:AddChild>
>               </mx:State>
>       </mx:states>
>       <mx:ApplicationControlBar width="666" y="120" horizontalCenter="0"
> id="applicationcontrolbar2">
>               <mx:Text text="Solicitação de reserva para uso da Sede 
> Litorânea"
> width="100%" height="100%" textAlign="center" fontWeight="bold"
> fontSize="13" color="#ff0000" id="text5"/>
>       </mx:ApplicationControlBar>
>       <mx:Image source="icones/logo.png" y="10" horizontalCenter="0"/>
>
>       <mx:HBox y="186" width="666" height="544" horizontalCenter="1"
> id="hbox12">
>               <mx:Form width="100%" height="100%" id="form1">
>                       <mx:FormItem label="Associado" fontWeight="bold">
>                               <mx:TextInput width="557" id="nome" 
> maxChars="100"/>
>                       </mx:FormItem>
>                       <mx:FormItem label="E-mail" fontWeight="bold" 
> id="formitem1">
>                               <mx:TextInput width="557" color="#0000ff" 
> id="email" maxChars="50"/
>   
>                       </mx:FormItem>
>                       <mx:FormItem label="Telefone" fontWeight="bold" 
> id="formitem2">
>                               <mx:TextInput width="193" id="fone" 
> maxChars="9"/>
>                       </mx:FormItem>
>                                               <mx:HBox width="526" 
> height="20" id="hbox11">
>                                                                               
> <mx:Text text="Nome dos acompanhantes" width="234"
> textAlign="left" fontWeight="bold"/>
>                                                                               
> <mx:Text text="Data de nascimento" width="265"
> textAlign="right" fontWeight="bold"/>
>                                               </mx:HBox>
>                                               <mx:HBox width="100%" 
> height="28" id="hbox10">
>                                                                               
> <mx:TextInput width="300" id="depum" maxChars="255"/>
>                                                                               
> <mx:Spacer width="70" height="20"/>
>                                                                               
> <mx:TextInput width="140" id="datadepum" maxChars="20"/>
>                                                                               
> <mx:Text text="(dd/mm/aaaa)" color="#ff0000"/>
>                                               </mx:HBox>
>
>                                               <mx:HBox width="100%" 
> height="28" id="hbox9">
>                                                                               
> <mx:TextInput width="300" id="depdois" maxChars="255"/>
>                                                                               
> <mx:Spacer width="70" height="20"/>
>                                                                               
> <mx:TextInput width="140" id="datadepdois" maxChars="20"/>
>                                                                               
> <mx:Text text="(dd/mm/aaaa)" color="#ff0000" id="text3"/>
>                                               </mx:HBox>
>                                               <mx:HBox width="100%" 
> height="28" id="hbox7">
>                                                                               
> <mx:TextInput width="300" id="deptres" maxChars="255"/>
>                                                                               
> <mx:Spacer width="70" height="20"/>
>                                                                               
> <mx:TextInput width="140" id="datadeptres" maxChars="20"/>
>                                                                               
> <mx:Text text="(dd/mm/aaaa)" color="#ff0000"/>
>                                               </mx:HBox>
>                                               <mx:HBox width="100%" 
> height="28" id="hbox0">
>                                                                               
> <mx:TextInput width="300" id="depquatro" maxChars="255"/>
>                                                                               
> <mx:Spacer width="70" height="20"/>
>                                                                               
> <mx:TextInput width="140" id="datadepquatro" maxChars="20"/>
>                                                                               
> <mx:Text text="(dd/mm/aaaa)" color="#ff0000"/>
>                                               </mx:HBox>
>
>                                                                               
> <mx:Text text="Enumere os períodos de acordo com sua
> preferência " fontWeight="bold" color="#ff0000" fontSize="12"
> id="text2"/>
>                                                                               
> <mx:HBox width="100%" height="25" id="hbox6">
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p1"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="1º - 20/12/07 a 27/12/07 - 
> NATAL"
> color="#000000"/>
>                                                                               
>                                 <mx:Spacer width="108" height="20"/>
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p7"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="7º - 31/01/08 a 07/02/08 - 
> CARNAVAL"
> color="#000000"/>
>                                                                               
> </mx:HBox>
>                                                                               
> <mx:HBox width="100%" height="25" id="hbox5">
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p2"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="2º - 27/12/07 a 03/01/08 - ANO 
> NOVO"
> color="#000000"/>
>                                                                               
>                                 <mx:Spacer width="82" height="20"/>
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p8"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="8º - 07/02/08 a 14/02/08" 
> color="#000000"/
>   
>                                                                               
> </mx:HBox>
>                                                                               
> <mx:HBox width="100%" height="25" id="hbox4">
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p3"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="3º - 03/01/08 a 10/01/08" 
> color="#000000"/
>   
>                                                                               
>                                 <mx:Spacer width="155" height="20"/>
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p9"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="9º - 14/02/08 a 21/02/08" 
> color="#000000"/
>   
>                                                                               
> </mx:HBox>
>                                                                               
> <mx:HBox width="100%" height="25" id="hbox3">
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p4"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="4º - 10/01/08 a 17/01/08" 
> color="#000000"/
>   
>                                                                               
>                                 <mx:Spacer width="155" height="20"/>
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p10"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="10º - 21/02/08 a 28/02/08"
> color="#000000"/>
>                                                                               
> </mx:HBox>
>                                                                               
> <mx:HBox width="100%" height="25" id="hbox2">
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p5"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="5º - 17/01/08 a 24/01/08" 
> color="#000000"/
>   
>                                                                               
>                                 <mx:Spacer width="155" height="20"/>
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p11"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="11º - 28/02/08 a 06/03/08"
> color="#000000"/>
>                                                                               
> </mx:HBox>
>                                                                               
> <mx:HBox width="100%" height="25" id="hbox1">
>                                                                               
>                                 <mx:TextInput width="29" color="#0000ff" 
> id="p6"
> maxChars="2"/>
>                                                                               
>                                 <mx:Text text="6º - 24/01/08 a 31/01/08" 
> color="#000000"/
>   
>                                                                               
>                                 <mx:Spacer width="155" height="20"/>
>                                                                               
>                                 <mx:TextInput width="29" color="#ff0000" 
> id="andar"
> maxChars="1"/>
>                                                                               
>                                 <mx:Text text="Andar de preferência (1 - 4)"
> color="#ff0000" fontWeight="bold" fontSize="11" id="text6"/>
>                                                                               
> </mx:HBox>
>
>                                                                               
>                                                                 <mx:HBox 
> width="100%" height="52" id="hbox13">
>                                                                               
>                                                                               
>                                                                               
>                                     <mx:ApplicationControlBar
> width="557" height="42" id="applicationcontrolbar1">
>                                                                               
>                                                                               
>                                                                               
>                                             <mx:Text width="100%" 
> height="100%"
> textAlign="center" fontWeight="bold" fontSize="10" color="#000000"
> id="text1">
>                                                                               
>                                                                               
>                                                                               
>                                                     <mx:text>Só confirme após 
> a
> digitação de todos os dados. Caso deseje alterar algum dado entre em
> contato com a APMP (41 3352-2919) ou envie um e-mail para
> [EMAIL PROTECTED]</mx:text>
>                                                                               
>                                                                               
>                                                                               
>                                             </mx:Text>
>                                                                               
>                                                                               
>                                                                               
>                                     </mx:ApplicationControlBar>
>                                                                               
>                                                                               
>                                                                               
>                                     <mx:Button label="Confirma"
> click="gravarUsuario()" height="42" width="67" id="button1"
> labelPlacement="top"/>
>                                                                               
>                                                                 </mx:HBox>
>
>
>
>               </mx:Form>
>       </mx:HBox>
>       <mx:Text y="160" text="Informe o nome do(a) associado(a) e seu(s)
> acompanhante(s)" fontWeight="bold" horizontalCenter="0" id="text7"/>
>
>
> <mx:RemoteObject id="roMeuProjeto" destination="amfphp"
> source="meuProjeto.meuProjeto" showBusyCursor="true">
>
>       <mx:method name="gravarUsuario">
>
>               <mx:arguments>
>                       <nome>
>                               {nome.text}
>                       </nome>
>
>                       <email>
>                               {email.text}
>                       </email>
>
>                       <fone>
>                               {fone.text}
>                       </fone>
>
>                       <depum>
>                               {depum.text}
>                       </depum>
>                       <datadepum>
>                               {datadepum.text}
>                       </datadepum>
>
>                       <depdois>
>                               {depdois.text}
>                       </depdois>
>                       <datadepdois>
>                               {datadepdois.text}
>                       </datadepdois>
>
>                       <deptres>
>                               {deptres.text}
>                       </deptres>
>                       <datadeptres>
>                               {datadeptres.text}
>                       </datadeptres>
>
>                       <depquatro>
>                               {depquatro.text}
>                       </depquatro>
>                       <datadepquatro>
>                               {datadepquatro.text}
>                       </datadepquatro>
>
>                       <p1>
>                               {p1.text}
>                       </p1>
>                       <p2>
>                               {p2.text}
>                       </p2>
>                       <p3>
>                               {p3.text}
>                       </p3>
>                       <p4>
>                               {p4.text}
>                       </p4>
>                       <p5>
>                               {p5.text}
>                       </p5>
>                       <p6>
>                               {p6.text}
>                       </p6>
>                       <p7>
>                               {p7.text}
>                       </p7>
>                       <p8>
>                               {p8.text}
>                       </p8>
>                       <p9>
>                               {p9.text}
>                       </p9>
>                       <p10>
>                               {p10.text}
>                       </p10>
>                       <p11>
>                               {p11.text}
>                       </p11>
>                       <andar>
>                               {andar.text}
>                       </andar>
>               </mx:arguments>
>
>       </mx:method>
>
> </mx:RemoteObject>
>
> </mx:Application>
>
>
> On 25 out, 06:16, Luis Eduardo - Suprasis Softwares
> <[EMAIL PROTECTED]> wrote:
>   
>>    Pode enviar um código?  Seria bem mais fácil ajudar.
>>
>>     abraços,
>>     Luís Eduardo
>>
>> FabianoB escreveu:
>>
>>
>>
>>     
>>> Olá pessoal
>>>       
>>> sou novato em Flex, peço ajuda a todos.
>>>       
>>> tenho um pequeno projeto com 2 states, no segundo possuo 2 HBox uma
>>> imagem e um ApplicationControlBar dentro de um HBox o botão
>>> "imprimir".
>>>       
>>> quero q imprima toda a página do 2 state, sem exceções.
>>>       
>>> tentei usar printJob, mas sem resultados, talvez esteja utilizando de
>>> modo errado.
>>>       
>>> alguém pode me ajudar?
>>>       
>>> vlw- Ocultar texto entre aspas -
>>>       
>> - Mostrar texto entre aspas -
>>     
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
Você recebeu esta mensagem porque está inscrito na lista "flexdev"
Para enviar uma mensagem, envie um e-mail para [email protected]
Para sair da lista, envie um email em branco para [EMAIL PROTECTED]
Mais opções estão disponíveis em http://groups.google.com/group/flexdev
-~----------~----~----~----~------~----~------~--~---

Responder a