Jump to content
Search Community

Cant target and tween MovieClip loaded with ImageLoader

obi_wan test
Moderator Tag

Recommended Posts

Hello everyone I am having a tough time and any help would be greatly appreciated. I have several movieclips that I load with loader max, when the user clicks on the movieclip it scales the movieclip selected which is the event.currentTarget from 60% to 100%. The problem I am having is that if it is not the currentTarget it should scale down to 60%. I have the logic correct but am having a really rough time targeting all other movieclips that are not the current target. Please review the code attached. I am open to any better solutions and any help again would be very appreciated. Thank you for your time.

 

	private function initEaselItems():void
	{
		var easelItemURL			:String;
		var totalEaselItems			:Number = _xmlsource.easelAssets.alphabet.length();

		for(var i:int=0; i			{
			easelItemURL 			= _xmlsource.easelAssets.alphabet.@imageURL[i];
			_easelItemClip			= new MovieClip();
			_easelItemClip.name		= "easelItemClip"+[i];
			_easelItemClip.index	= [i];
			_easelItemClip.x		= _xmlsource.easelAssets.alphabet.@xPos[i];
			_easelItemClip.y		= _xmlsource.easelAssets.alphabet.@yPos[i];
			_easelItemClip.alpha	= 0;
			_easelItem 				= new ImageLoader(easelItemURL,
										{
											estimatedBytes:2400,
											container:_easelItemClip,
										});
			_easel.alphabetContainer.addChild(_easelItemClip);
			_easelItem.load();
			_easelItemClip.addEventListener(MouseEvent.CLICK,easelItemHandler,false,0,true);
			TweenLite.to(_easelItemClip, .5, {alpha:1, scaleX:.6, scaleY:.6, delay:(i*.15)});
			_levelTwoArray.push(_easelItemClip.name);
		}
	}


	private function easelItemHandler(event:MouseEvent):void
	{
		var totalEaselItems	:Number = _xmlsource.easelAssets.alphabet.length();
		var item			:String = event.currentTarget.name;
		trace(_levelTwoArray[i]);
			for (var i:int = 0; i<=totalEaselItems; i++) 
			{
				if (item == _levelTwoArray[i])
				{
					trace("scale selected item up:");
					TweenLite.to(event.currentTarget, .5, {transformAroundCenter:{scaleX:1, scaleY:1}});
				}
				else
				{
					trace("scale on all other items down");
					// the code below throws an error I cant target the rest of the movie clips
					//TweenLite.to(_easel.alphabetContainer["easelItemClip"+ i], .5, {transformAroundCenter:{scaleX:1, scaleY:1}});
				}
			}
	}

Link to comment
Share on other sites

consider the following:

 

var someContainer:MovieClip = new MovieClip();
addChild(someContainer);

for (var i:int = 0; i 	var b:Box = new Box();
b.name = "b" + i;
b.x = i*60;
someContainer.addChild(;
}

//the next line will cause an error
//someContainer["b1"].y = 100;	


//the next line will work fine
someContainer.getChildByName("b1").y = 100;

 

so in your example you could do:

 

TweenLite.to(_easel.alphabetContainer.getChildByName("easelItemClip"+ i), .5, {transformAroundCenter:{scaleX:1, scaleY:1}});

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...