Ultrashock Forums > Flash > ActionScript
AS3 - Transition doesn't work?

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
AS3 - Transition doesn't work?
Old 2009-11-09

Hi all. I'm creating a script that imports an Mc from the library. Then I position the x,y coordinates of the mc. Then I want to run a transition of the mc. I can import the mc, move the mc to the correct coordinates. But I can't get the transition to work.

Hopefully someone here can point me in the right direction.

Code:
import flash.events.*;
import flash.display.SimpleButton;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;


var currentButtn;
var currentPage:Number;
var newPage:Number;
var newNC:String;
var popUpTween1:Tween;
var newMcNum:Number;
var newMcLoc:Number;
var newMc:MovieClip;
var eventName:String
var mcEvent:MovieClip
var mcClass:*;


	function importAndMoveMc():void
	{
		var p:Number;
		if(newPage > currentPage) 
		{	
			newMcNum = 0;
			for(p = currentPage +1; p <= newPage;p++)//count to the right
			{
				eventName = "event"+p;
				
				newMcNum ++;
				newMcLoc = newMcNum * 715;				
				
				mcClass = getDefinitionByName(eventName);
				mcEvent = new mcClass();
				mcEvent.x = newMcLoc;
				mcEvent.y = 4.8;
				addChild(mcEvent);
///////////////////////////////////////
			
							
			}
		}
		else if (newPage < currentPage)
		{
			newMcNum = 0;
			for(p = currentPage -1; p >= newPage;p--)
			{
				eventName = "event"+p;
				
				newMcNum ++;
				
				newMcLoc = newMcNum * -715;
				
				mcClass = getDefinitionByName(eventName);
				mcEvent = new mcClass();
				mcEvent.x = newMcLoc;
				mcEvent.y = 4.8;
				addChild(mcEvent);
				
			}
		}
		else if (newPage == currentPage)
		{
			trace("Same Page");
		}
		currentPage = newPage;
			var mcTrans1 = "move"+p;
			mcTrans1 = new Tween(mcEvent,"x",Regular.easeIn, mcEvent.x = newMcLoc, mcEvent.x = -200, 1, true);
	}
postbit arrow 5 comments | 146 views postbit arrow Reply: with Quote   
Registered User
BSMH is offline
seperator
Posts: 197
2004-07-28
BSMH lives in United States
seperator

Ultrashock Member Comments:
Isocase's Avatar Isocase Isocase is offline Isocase lives in United States 2009-11-09 #2 Old  
Your tween is messed up.

Code:
mcTrans1 = new Tween(mcEvent,"x",Regular.easeIn, mcEvent.x = newMcLoc, mcEvent.x = -200, 1, true);

Should be
//new Tween(object,"object property you want to change", ease, start, finish, 1, true);
mcTrans1 = new Tween(mcEvent, "x", Regular.easeIn, mcEvent.x, -200, 1, true);
Reply With Quote  
BSMH BSMH is offline BSMH lives in United States 2009-11-09 #3 Old  
It still doesn't work. It will import the mc to the stage. It will position it. But it won't run the tween.
Reply With Quote  
BSMH BSMH is offline BSMH lives in United States 2009-11-09 #4 Old  
I think it has something to do with grabbing the mcEvent mc on the stage. I swapped out the name mcEvent in the tween for an mc thats already on the stage. It worked perfectly. So maybe I'm not referencing the imported mc correctly.
Reply With Quote  
BSMH BSMH is offline BSMH lives in United States 2009-11-09 #5 Old  
To make matters even more complicated, it will work one moment, the next time I compile it (without any changes) it won't work.
Reply With Quote  
BSMH BSMH is offline BSMH lives in United States 2009-11-10 #6 Old  
Could it also be that by the time the transition kicks in, the child hasn't been fully imported?
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: