Jump to content
Search Community

Problem Tweening an object within an MC

jackthe7th test
Moderator Tag

Recommended Posts

hi, new to this greensock thing, but so far it has been wonderful in accomplishing what I would like to do!

 

My problem is this: Im having trouble getting an object within an MC to tween. The object in the MC is a textField that loads external text files called Text_News. I figured I would just specify the parent MC using a dot operator:

 

timeline.append( TweenMax.to(BG.Text_Field, 1, {alpha:1}));

 

But this comes back with the error:

 

Error: Cannot tween a null object.

at com.greensock::TweenLite$iinit()

at com.greensock::TweenMax$iinit()

at com.greensock::TweenMax$/to()

at ZakAstor2_fla::MainTimeline/ZakAstor2_fla::frame2()

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at com.greensock::TweenLite/com.greensock:TweenLite::init()

at com.greensock::TweenMax/com.greensock:TweenMax::init()

at com.greensock::TweenMax/renderTime()

at com.greensock.core::SimpleTimeline/renderTime()

at com.greensock::TweenLite$/com.greensock:TweenLite::updateAll()

 

 

 

 

Does anyone know how to do this?

Link to comment
Share on other sites

give the movie clip that CONTAINs targetMC the instance name parentMC.

 

using "parent" as an instance name is going to to cause problems with the ActionScript reserved keyword parent.

 

change your code to say:

 

timeline.append( TweenMax.to(parentMC.targetMC, 1, {alpha:1}));

 

that should do it.

Link to comment
Share on other sites

heh I know, sorry i just called it parent to simplify it, the parent is actually called BG in my code.

 

so this is my actual code:

timeline.append( TweenMax.from(BG.Text_News, 2, {alpha:0}));

 

I realized something though, the object "Text_News" was not created on the stage like my other objects, it was created using AS3. Its a textField that loads an external html file:

var myTextLoader:URLLoader = new URLLoader();

var Text_News:TextField = new TextField();

myTextLoader.addEventListener(Event.COMPLETE, onLoaded);

function onLoaded(e:Event):void {

Text_News.htmlText = e.target.data;

addChild(Text_News);

}

myTextLoader.load(new URLRequest("Text/News.html"));

 

 

 

so I am trying to target this textField "Text_News", whose parent is BG.

Link to comment
Share on other sites

is the textfield created before or after the timeline code is run?

it needs to happen before.

 

is this code inside BG?

 

var myTextLoader:URLLoader = new URLLoader();

var Text_News:TextField = new TextField();

myTextLoader.addEventListener(Event.COMPLETE, onLoaded);

function onLoaded(e:Event):void {

Text_News.htmlText = e.target.data;

addChild(Text_News);

}

myTextLoader.load(new URLRequest("Text/News.html"));

 

the best thing you can do at this point is add a trace right beneath your timeline code:

 

trace(BG.Text_News)

if it is there you should get something like [object TextField] in your output.

 

if you don't get a favorable trace, double check your instance names and paths.

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