[Flashcoders] problems accessing a MovieClip / display list issue

2009-07-03 Thread Isaac Alves
Problems trying to access a MovieClip that contains a dynamically loaded
image, inside dynamically created menu items.

I hope the code is self explanatory !

function mouseOverItem(e:Event):void {
var item:MenuItem = e.target as MenuItem;
 trace (item.getChildAt(3).name);
trace (item.getChildAt(3));
trace (item.bt_title);
 trace (item.getChildAt(4).name);
trace (item.getChildAt(4));
trace (item.icone);

new GTween(item.bt_title, 0.3, {y:25}, easing1);
new GTween(item.bt_subtitle, 0.3, {y:25}, easing1);
new GTween(item.icone, 0.3, {y:100}, easing1);/*/ doesn´t work!!
*


*The tracing output this:*

bt_title
[object MovieClip]
[object MovieClip]
icone
[object MovieClip]
undefined

*QUESTION: Why do i get undefined? shouldn´t I get  [object MovieClip]
instead ?*

Thanks!!

In case this code is not clear:

function iniciarMenu ():void{

for (var i:Number = 0; i  my_total; i++){

var menuItem:MenuItem = new MenuItem();
menuItem.x = (menuItem.width + 2)*i;
menuItem.bt_title._txt.text = my_items[...@title;
menuItem.bt_title._txt.antiAliasType = AntiAliasType.ADVANCED;
menuItem.bt_subtitle._txt.text = my_items[...@subtitle;
menuItem.bt_subtitle._txt.antiAliasType = AntiAliasType.ADVANCED;

menuItem.linkTo = my_items[...@link;
menuItem.mouseChildren = false;

menuItem.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);
menuItem.addEventListener(MouseEvent.MOUSE_OUT, mouseOutItem);
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);

menu_mc.addChild(menuItem);
menuArray[i] = menuItem;

var iconURL = my_items[...@icon;
var iconLoader = new Loader();
iconLoader.load(new URLRequest(iconURL));
iconLoader.name = i;
iconLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, iconLoaded);

}
}

function iconLoaded(e:Event):void{
var my_icon:Loader = Loader(e.target.loader);
var iconMC:MovieClip = new MovieClip();
iconMC.addChild(my_icon);
menuArray[my_icon.name].addChild(iconMC);

iconMC.x = 100;
iconMC.y = 35;
iconMC.alpha = 0;
iconMC.name = icone;
new GTween(iconMC, 0.9, {alpha:0.8}, easing1);
 my_icon.contentLoaderInfo.removeEventListener(Event.COMPLETE, iconLoaded);
my_icon = null;
}
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] problems accessing a MovieClip / display list issue

2009-07-03 Thread Ktu
Just a thought, try doing getChildByName(icone);

What it looks like, is that there is no member variable in the MenuItem
class called icone. You can't call object.child by using the name property
of the child. The bt_title does, because probably you have defined in the
MenuItem class a variable called bt_title. It looks like you did not do the
same with the icon. If you use the getChildByName() that will give you the
results you want.

Ktu

On Fri, Jul 3, 2009 at 2:01 PM, Isaac Alves isaacal...@gmail.com wrote:

 Problems trying to access a MovieClip that contains a dynamically loaded
 image, inside dynamically created menu items.

 I hope the code is self explanatory !

 function mouseOverItem(e:Event):void {
 var item:MenuItem = e.target as MenuItem;
  trace (item.getChildAt(3).name);
 trace (item.getChildAt(3));
 trace (item.bt_title);
  trace (item.getChildAt(4).name);
 trace (item.getChildAt(4));
 trace (item.icone);

 new GTween(item.bt_title, 0.3, {y:25}, easing1);
 new GTween(item.bt_subtitle, 0.3, {y:25}, easing1);
 new GTween(item.icone, 0.3, {y:100}, easing1);/*/ doesn´t
 work!!
 *


 *The tracing output this:*

 bt_title
 [object MovieClip]
 [object MovieClip]
 icone
 [object MovieClip]
 undefined

 *QUESTION: Why do i get undefined? shouldn´t I get  [object MovieClip]
 instead ?*

 Thanks!!

 In case this code is not clear:

 function iniciarMenu ():void{

 for (var i:Number = 0; i  my_total; i++){

 var menuItem:MenuItem = new MenuItem();
 menuItem.x = (menuItem.width + 2)*i;
 menuItem.bt_title._txt.text = my_items[...@title;
 menuItem.bt_title._txt.antiAliasType = AntiAliasType.ADVANCED;
 menuItem.bt_subtitle._txt.text = my_items[...@subtitle;
 menuItem.bt_subtitle._txt.antiAliasType = AntiAliasType.ADVANCED;

 menuItem.linkTo = my_items[...@link;
 menuItem.mouseChildren = false;

 menuItem.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);
 menuItem.addEventListener(MouseEvent.MOUSE_OUT, mouseOutItem);
 menuItem.addEventListener(MouseEvent.CLICK, itemClicked);

 menu_mc.addChild(menuItem);
 menuArray[i] = menuItem;

 var iconURL = my_items[...@icon;
 var iconLoader = new Loader();
 iconLoader.load(new URLRequest(iconURL));
 iconLoader.name = i;
 iconLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, iconLoaded);

 }
 }

 function iconLoaded(e:Event):void{
 var my_icon:Loader = Loader(e.target.loader);
 var iconMC:MovieClip = new MovieClip();
 iconMC.addChild(my_icon);
 menuArray[my_icon.name].addChild(iconMC);

 iconMC.x = 100;
 iconMC.y = 35;
 iconMC.alpha = 0;
 iconMC.name = icone;
 new GTween(iconMC, 0.9, {alpha:0.8}, easing1);
  my_icon.contentLoaderInfo.removeEventListener(Event.COMPLETE, iconLoaded);
 my_icon = null;
 }
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders