Topic: Attach Movie

Hello,


  I've tried to create a small chumby app, using "attachMove", like this:

clip=_root.attachMovie("Weather","weather"+id,_root.getNextHighestDepth();
clip._x=100;
clip._y=100;

(where id is incremented).

This works well on Flash on PC, but not on Chumby? Nothing is displayed...
Note that if I drag the "Weather" clip on the screen and I download this Flash file on Chumby this works well. So this seems to be an issue with this piece of code, and not with the MovieClip itself.


  And an extra question for Flash developpers (I am a beginner!):

- how to define events in the movie clip that can be called from the main script. In the previous example, I had a function loadWeather() defined in the MovieClip , like this:

this.loadWeather=function(){
  .. do something...
}


But I can not call clip.loadWeather(); ??

  Thanks in advance.....

Re: Attach Movie

I'm pretty sure that getNextHighestDepth() is not a function in Flash lite 2.0 You can always make a variable, i, and manually figure it out. Or even just recreate that function in your code.

Re: Attach Movie

You shouldn't be attaching the moveclip to _root.

The issue is that on the prototype chumby units, your widget is being loadMovie'd into another movie (the Control Panel), and therefore _root isn't what you think it is.

You should use a relative path to use *your* main timeline rather than the Control Panel's.

An alternative is to put the line:

_lockroot = true;

on the first frame of your main timeline - this should change the meaning of _root to mean your movie if your movie is Flash 7.

Re: Attach Movie

You are right, this was linked to the _root reference.

Thanks a lot Chumbian.

Any tips about my second question?

Re: Attach Movie

On the second question, it's probably that you're calling the function before it's actually available to you.

This is a very, very common problem, particularly with new users of Flash.

The code on that frame must execute in order for that assignment to happen - for instance, it's *not* available immediately after attachng a movie.  It would also not be available to a parent movie when the first code is run on the parent.

Depending upon the version of Actionscript you're using, there are different solutions.

One common old-school trick is something like:

this.onEnterFrame = function() {
   someClip.doSomething();
   this.onEnterFrame = undefined;
}

...instead of just:

someClip.doSomething();

This wil execute on the *next* frame, after which the functions in the child clips should be available.