Jump to content
Search Community

TweenMax from String of Instance Name

freedom1k test
Moderator Tag

Recommended Posts

Hello,

Within a XmL I have Instance names and Info that I used to link a Person's Pics which displays when certain buttons are picked. Works well.

I decided to add a Combo box, linked to the same XML and display people name. I hope to have the Button Glow and Change color when a name is selected.

I was able to trace and capture the Instance name of the button based on the selected name.

 

the buttons are located within a MC:

stillIsoPlan_MC.staff098

the sample variable below combines the selected name with a string to trace the exact format above.

var gettingMCObject:String = ( "stillIsoPlan_MC." + xmlGridValue[numSelect] );

In testing if I TweenMax the variable I get: 

  TweenMax.to(gettingMCObject, 1, {colorTransform:{tint:0xff0000}});  
    TypeError: Error #1010: A term is undefined and has no properties.

 

 

 

But if I hard Code the buttons location, the color change works fine:

TweenMax.to(stillIsoPlan_MC.staff098, 1, {colorTransform:{tint:0xff0000}});

Is there a way to use Instance Name from a String with the TweenMax feature?

Also, can you use the yoyo: property in TweemMax.to to isolate the color and glow of a mc or btn?

 

Your guidance is much appreciated!

 

Below is the code segment :

// ComboList 
myComBoBox.prompt = "Select Staff: "; 
var xmlLoader:URLLoader = new URLLoader();
var xmlArry:Array = new Array();
var xmlGridValue:Array = new Array();
var comboXMLData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("StaffListFromXMLSchema.xml"));
function LoadXML(e:Event):void{
comboXMLData  = new XML(e.target.data);
//trace(comboXMLData.staffInfo.length());
for(var i:uint=0;i<comboXMLData.staffInfo.length();i++)
{
xmlArry.push(comboXMLData.staffInfo.staffName[i]);
xmlGridValue.push(comboXMLData.staffInfo.gridValue[i]);
myComBoBox.dataProvider.sortOn("label");
myComBoBox.addItem( { label: xmlArry[i], data:i } );
myComBoBox.addEventListener(Event.CHANGE, doAction);
}
}
function doAction (e:Event):void
{
var numSelect:Number = Number(myComBoBox.selectedItem.data);  //data to line number
trace(xmlArry[numSelect]);
trace(xmlGridValue[numSelect]);
var gettingMCObject:String = ( "stillIsoPlan_MC." + xmlGridValue[numSelect] );
var prefixMCname:String = "stillIsoPlan_MC.";
trace(gettingMCObject);
//TweenMax.to(stillIsoPlan_MC.manager08, 1, {glowFilter:{color:0x91e600, alpha:1, blurX:30, blurY:30, strength:1, quality:2}, ease:Elastic.easeInOut});
TweenMax.to(stillIsoPlan_MC.xmlGridValue[numSelect], 1, {colorTransform:{tint:0xff0000}});
}

sample xml format: gridValue = Instance Name of buttons

 

 

<staffInfo>
<gridValue>manager12</gridValue>
<staffName>Hunting, Joe </staffName>
<quickDail>59xxx</quickDail>
<staffPhone>(6xx) 9xx-9xxx</staffPhone>
<staffPC>OH02-XXXX</staffPC>
<staffPcPort>0000D1</staffPcPort>
<imageLarge>StaffPics/LowRes/Hunting, Joe_LR.jpg</imageLarge>
</staffInfo>

 

 

 

Link to comment
Share on other sites

Hi, 

 

You can't pass String values as targets of tweens.

Just like this won't work

var gettingMCObject:String = ( "stillIsoPlan_MC." + xmlGridValue[numSelect] );
gettingMCObject.x = 200 //will throw error

I didn't look over your full code but here are some ways to use String values to target child elements of MovieClips.

 

Assume a MovieClip with instance name parent_mc contains child1_mc. 

Typically you would target child1_mc with

 

parent_mc.child1_mc.someProperty = someValue

 

If you are using String values as the instance names, you can do:

 

var nameOfParentMC:String = "parent_mc";
var someValueFromXML:String = "child1";


this["parent_mc"][someValueFromXML].x = 100;
parent_mc[someValueFromXML].y = 100;
this[nameOfParentMC][someValueFromXML].rotation = 45;

Attached is an FLA example. Hopefully it helps you with xml data

 

 

 

dynamicTarget.fla.zip

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...