Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-25-2010, 08:40 AM   #1
circass
Registered User
 
Join Date: Aug 2010
Posts: 2
Default How to access a component in an itemrenderer ?

Hello,
i am trying to write something like image gallery.
I create a layout system by using that kind of code :


<s:Scroller width="100%" height="100%" id="gridContainer">
<sataGroup width="100%" id="gridDeneme">
<s:itemRenderer>
<mx:Component>
<s:ItemRenderer>
<ns1:ImageViewer imageURL="{data.imageUrl}"
id="imageViewer"
bitmapScaleFactorMax="5"
bitmapScaleFactorMin=".05"
width="{data.width}" height="{data.height}"
x="0" y="0"/>
</s:ItemRenderer>
</mx:Component>
</s:itemRenderer>
<s:layout>
<s:TileLayout />
</s:layout>
</sataGroup>
</s:Scroller>

I am using adobe imageviewer component with some changes and i want to use its functions, so i have to access the imageViewer which is inside that:

<s:itemRenderer>
<mx:Component>
<s:ItemRenderer>
<ns1:ImageViewer imageURL="{data.imageUrl}"
id="imageViewer"
bitmapScaleFactorMax="5"
bitmapScaleFactorMin=".05"
width="{data.width}" height="{data.height}"
x="0" y="0"/>
</s:ItemRenderer>
</mx:Component>
<s:itemRenderer>

how can i get those imageViewers in runtime ?

for(var i:int = 0; i< gridDeneme.numChildren;i++)
{
gridDeneme.getChildAt(i).filters = null;
}

I am accessing childs of gridDeneme Datagruop but when i want to cast them to imageViewer it returns me null... I dont know what else i can do...
Thank you
Regards.
circass is offline   Reply With Quote
Old 08-25-2010, 08:49 AM   #2
circass
Registered User
 
Join Date: Aug 2010
Posts: 2
Default I found the solution sorry for disturbtion

Ok i found the solution of my problem...

for(var i:int = 0; i< gridDeneme.numChildren;i++)
{
gridDeneme.getChildAt(i).filters = null;
var ali:ItemRenderer = gridDeneme.getChildAt(i) as ItemRenderer;
for(var j:int = 0; j< ali.numChildren;j++)
{
var veli:ImageViewer = ali.getChildAt(j) as ImageViewer;
veli.zoom("in");
}
}
with that i can access my viewers...
circass is offline   Reply With Quote
Old 08-26-2010, 07:16 PM   #3
hellix
Registered User
 
Join Date: Jun 2010
Location: Poland.
Posts: 9
Send a message via Skype™ to hellix
Default

Hi.

You can also to add eventlistener to Spark DataGroup:
ActionScript Code:
<s:DataGroup itemRenderer="dgControls.DgControlRenderer"                    rendererAdd="onRendererAdd(event)">  <fx:Script>   <![CDATA[    import spark.events.RendererExistenceEvent;    private var _itemRenderers:Array = [];      /**     * Array of itemrenderers     * */    public function get itemRenderers():Array    {     return _itemRenderers;    }      /**     * Add renderer to array     * */    protected function onRendererAdd(event:RendererExistenceEvent):void    {     _itemRenderers.push(event.renderer);    }   ]]>  </fx:Script> </s:DataGroup>

My itemrenderer is stored in another file. Everytime when instance of item renderer is created in method onRendererAdd i add this instance to array.

ItemRenderer display properties from vo PersonVo:

ActionScript Code:
public dynamic class PersonVo {   public var firstName:String;   public var surname:String;     public function PersonVo(firstName:String = null,      surname:String = null)   {    this.firstName = firstName;    this.surname =surname;   } }

ActionScript Code:
<s:ItemRenderer autoDrawBackground="true">  <s:HGroup gap="5"      height="100%">   <s:Label id="firstName"     text="{data.firstName}"/>   <s:Label id="surname"     text="{data.surname}"/>  </s:HGroup> </s:ItemRenderer>

Access to item renderer is clear and simple:

ActionScript Code:
var count:int = dg.itemRenderers.length;   for(var i:int = 0; i < count; i++) {      var dgRenderer:DgControlRenderer = dg.itemRenderers[i];      dgRenderer.firstName.text = "Ola";      dgRenderer.surname.text = "O."; }
---
Greetings
hellix is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:19 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.