Comunidad de diseño web y desarrollo en internet online

Acceder a los controles de un componente externo

Citar            
MensajeEscrito el 07 Ene 2008 08:12 pm
Hola tengo una pregunta, tengo una aplicacion que se llama aplicacion.mxml que tiene un componente que se llama publicidad.mxml que tiene un titleList que muestra una imagen que se pasa por medio del dataprovider

publicidad.mxml

<?xml version="1.0" encoding="utf-8"?>
<lib:TileList xmlns:lib="http://www.adobe.com/2006/mxml" xmlns:mx="http://www.adobe.com/2006/mxml"
width="155" height="494" columnCount="1">
<lib:itemRenderer>
<mx:Component>
<mx:Canvas width="115" height="115">
<mx:Image width="130" height="112" x="0" y="2" source="{data.txt_picture}" toolTip="{data.txt_name}"/>
</mx:Canvas>
</mx:Component>
</lib:itemRenderer>
</lib:TileList>

como desde aplicacion.mxml por medio de una funcion puedo acceder a los items que tiene el TileList en publicidad.mxml ?

Gracias :D

Por josmurfe

6 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 07 Ene 2008 09:59 pm
Simplemente llamalo.

No se como invoques Publicidad, si abres un popup o lo metes en un contenedor, pero en cualquier forma que lo invoques, el objeto es accesible.

Código :

tuPublicidad.data


Tu publicidad es la variable(en caso de popup) o el id del contenedor que invoca publicidad.mxml.


Saludos

Por Dano

BOFH

4273 de clabLevel

14 tutoriales
4 articulos
10 ejemplos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Lugar estratégico para vigilarte

firefox
Citar            
MensajeEscrito el 07 Ene 2008 10:19 pm
Gracias por la pronto respuesta

Si con data acceso a la info lo que pasa es lo siguiente, lo que tengo que hacer es que publicidad.mxml cuando cambie el valor de la dataprovider quiero que se ejecute un efecto dentro de todos los objetos que se cargaron, entonces lo que tengo que hacer es agregar alguna funcion que cuando detecte el cambio en el dataprovider. Se me habia ocurrido dentro de la funcion que conecta al remoteobject ponerla ahi, pero me resulta mas facil agregar la funcion dentro del archivo publicidad.mxml para dispararlo cuando cambia la info.

Gracias y espero me esplicara lo mejor posible

salu2 :shock:

Por josmurfe

6 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 08 Ene 2008 12:07 am
Para eso nada mejor que los eventos:

Aqui mas info

Para explicarte mejor, detalla mas tu problema, ESCRIBE el código que tienes en application.mxml donde llamas a publicidad.mxml.

Saludos

Por Dano

BOFH

4273 de clabLevel

14 tutoriales
4 articulos
10 ejemplos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Lugar estratégico para vigilarte

firefox
Citar            
MensajeEscrito el 08 Ene 2008 12:42 am
excelente aporte me va a servir demasiado lo que me pasaste gracias de verdad

Aca adjunto un poco del codigo

esta es la application

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" backgroundColor="#69665b" layout="absolute">

prueba.mxml

<mx:Script>
<![CDATA[
import mx.collections.IViewCursor;
import model.ProductsStar;

private function mueve_productos():void{
storeViews.selectedIndex = 1;
}

]]>
</mx:Script>

<mx:HBox x="10" y="5" width="847" height="35">
<mx:ApplicationControlBar id="acb" width="846" height="34">
<mx:ToggleButtonBar height="100%" dataProvider="storeViews" styleName="storeButtonBar"/>
</mx:ApplicationControlBar>
</mx:HBox>
<mx:HBox x="10" y="44" width="847" height="462">
<mx:ViewStack id="storeViews" width="847" height="462" creationPolicy="all">
<inicio id="homeView" label="Home"
showEffect="WipeDown" hideEffect="WipeUp"
width="100%" height="100%"/>
<products id="productsView" label="Products"
showEffect="WipeDown" hideEffect="WipeUp"
width="100%" height="100%"/>
</mx:ViewStack>
</mx:HBox>
<mx:VBox x="862" y="5" width="155" height="495" horizontalAlign="right" verticalAlign="top">
<frm_publicidad id="publi_values" width="155" height="494" itemClick="mueve_productos()"/>
</mx:VBox>
</mx:Application>

ahora este es el componente de la publicidad

frm_publicidad.mxml

<?xml version="1.0" encoding="utf-8"?>
<lib:TileList xmlns:lib="http://www.adobe.com/2006/mxml" xmlns:mx="http://www.adobe.com/2006/mxml" width="155" height="494" columnCount="1"
dataProvider="{TileListdp}" rollOver="pause_refresh(event)" rollOut="pause_refresh(event)"
mouseMove="pause_refresh(event)" backgroundColor="#69665b" creationComplete="cambia_publicidad()">


<mx:RemoteObject id="servTopTen" source="SERVICES.ServiceTopTen" destination="amfphp" fault="HandlerFault(event)" showBusyCursor="true">
<mx:method name="SqlGetFour" result="getFour(event)" fault="HandlerFault(event)" />
</mx:RemoteObject>

<mx:Script>
<![CDATA[

import mx.collections.ArrayCollection;
import mx.utils.ArrayUtil;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;

private const TIMER_INTERVAL:int = 4000;

[Bindable] public var TileListdp:ArrayCollection;
[Bindable] public var t:Timer;

private function cambia_publicidad():void{
servTopTen.getOperation('SqlGetFour').send();
t = new Timer(TIMER_INTERVAL);
t.addEventListener(TimerEvent.TIMER, updateProducts);
t.start();
}

private function getFour(evt:ResultEvent):void{
TileListdp = new ArrayCollection( ArrayUtil.toArray(evt.result) );
}

private function HandlerFault(fault:FaultEvent):void{
Alert.show(fault.fault.faultString, fault.fault.faultCode.toString());
}

private function updateProducts(evt:TimerEvent):void {
servTopTen.getOperation('SqlGetFour').send();
}

public function pause_refresh(event:MouseEvent):void {

var tipo:String = (event.type == MouseEvent.ROLL_OUT ? "stop" : "start");

if ((event.type == MouseEvent.MOUSE_MOVE) || (event.type == MouseEvent.ROLL_OVER)){
if (t.running == true){
t.stop();
}
}else{
if (t.running == false){
t.start();
}
}

}//end function

]]>
</mx:Script>
<lib:itemRenderer>
<mx:Component>
<mx:Canvas width="115" height="115">
<mx:Image width="130" height="112" x="0" y="2" source="{data.txt_picture}" toolTip="{data.txt_name}"/>
</mx:Canvas>
</mx:Component>
</lib:itemRenderer>
</lib:TileList>

Ahora lo que no se es donde poner el efecto cuando se cambia el provider por medio de la funcion

Gracias por la ayuda

Por josmurfe

6 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 08 Ene 2008 06:21 am
En el nodo de application agrega lo que esta en negrita:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" backgroundColor="#69665b" layout="absolute" initialize="init()">


En el mismo application agrega estas funciones:

Código :

private function init():void
{
  publi_values.addEventListener("LeeDatos",onLeeDatos);
}
private function onLeeDatos(event:Event):void
{
  Alert.show("Datos leidos en tile list");
}


Y en publicidad donde quieras invocar el evento solo pon esto:

Código :

dispatchEvent( new Event("LeeDatos") );


Es todo con eso funciona.


Por cierto usa las etiquetas code cuando respondas con código.



saludos

Por Dano

BOFH

4273 de clabLevel

14 tutoriales
4 articulos
10 ejemplos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Lugar estratégico para vigilarte

firefox
Citar            
MensajeEscrito el 08 Ene 2008 06:26 pm
Dano te falto mencionar que en la clase donde llames dispatchEvent tiene que extender de EventDispatcher o alguna otra clase que lo haga, o implimentar IeventDispatcher y agregar los metodos que pide esta interface. Bueno lo dejo como por informar. :) saludos

Por bipsa

628 de clabLevel

1 tutorial
1 articulo

Genero:Masculino  

Colombia

safari
Citar            
MensajeEscrito el 08 Ene 2008 08:52 pm
Bipsa muchas gracias por tu aclaración. josmurfe usa componentes mxml, todos heredan de FlexUIComponent, por lo tanto ya heredan también de EventDispatcher.

saludos

Por Dano

BOFH

4273 de clabLevel

14 tutoriales
4 articulos
10 ejemplos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Lugar estratégico para vigilarte

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.