Re: [Flashcoders] Help: Confusion and Blue with Components

2006-07-14 Thread elibol

When you call gotoAndStop(), the player needs to first enter the frame where
mcParent is, this is why it works when you use onEnterFrame.

My technique for this has been to add a function call on the frame that the
clip resides in. I may call a function like Parent.init() on frame label
'TestFrame', or just init() and delegate the init function to a more
appropriate location:

import mx.utils.Delegate;

TestMC.init = Delegate.create(this, initTestMC);

function initTestMC(){
//this will be called when init() is called from within the movieclip
}

I hope this helps,

M

On 7/12/06, Tan [EMAIL PROTECTED] wrote:


Dear list,

I have been trying to solve this problem for a good while, but I wonder if
anyone has a good way to get around it. Here is the problem (you can
download the related Flash at: http://www.acts.net/Flash/ComponentBlue.zip

I have created a component called Parent, inside Parent timeline I have my
designer to layout components Child1 and Child2, so I only have to do the
wiring.

So now I have put Parent in the movie timeline at a frame labeled
TestFrame,
so we have a structure liked followed,

TestFrame
+ Parent
  - Child1
  - Child2


For the ease of description, I have classes with the same name as Parent,
Child1 and Child2. In the timeline, the Parent instance is named as
mcParent.


So somewhere in a function I will write like:

function myFunction():Void
{
  gotoAndStop(TestFrame);

  trace( this[mcParent] ); // it returns _level0.mcParent
  trace( Parent( this[mcParent] ); // the movieclip is there, but it
returns null }


Somehow I cannot get Parent as the Parent class. If I revise logic like:

function myFunction():Void
{
  gotoAndStop(TestFrame);

  trace( this[mcParent] ); // it returns _level0.mcParent
  trace( Parent( this[mcParent] ); // the movieclip is there, but it
returns null

  this.onEnterFrame = laterFunction;
}

function laterFunction():Void
{
  this.onEnterFrame = null;
  trace( this[mcParent] ); // it returns _level0.mcParent
  trace( Parent( this[mcParent] ); // now it returns _level0.mcParent
correctly }



The similar problem exists in Child1 and Child2 inside Parent timeline. It
seems to me that the MovieClip is not converted to its associated class
until later time, so I have to split my logic into two different
functions,
whic makes the code look cumbersome and hard to manage.

A more detailed example of the problem above can be downloaded at,
http://www.acts.net/Flash/ComponentBlue.zip

Although putting components on the stage using attachMovie might solve the
problem, but I would like the designer to have the freedom to arrange the
components on the stage the way he likes, and attachMovie would take away
this freedom. I wonder if anyone has a cleaner way around this problem.

TIA!

- Tangent

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Help: Confusion and Blue with Components

2006-07-12 Thread Tan
Dear list,

I have been trying to solve this problem for a good while, but I wonder if
anyone has a good way to get around it. Here is the problem (you can
download the related Flash at: http://www.acts.net/Flash/ComponentBlue.zip

I have created a component called Parent, inside Parent timeline I have my
designer to layout components Child1 and Child2, so I only have to do the
wiring. 

So now I have put Parent in the movie timeline at a frame labeled TestFrame,
so we have a structure liked followed, 

TestFrame
 + Parent
  - Child1
  - Child2 


For the ease of description, I have classes with the same name as Parent,
Child1 and Child2. In the timeline, the Parent instance is named as
mcParent. 


So somewhere in a function I will write like:

function myFunction():Void
{
  gotoAndStop(TestFrame); 
  
  trace( this[mcParent] ); // it returns _level0.mcParent
  trace( Parent( this[mcParent] ); // the movieclip is there, but it
returns null } 


Somehow I cannot get Parent as the Parent class. If I revise logic like:

function myFunction():Void
{
  gotoAndStop(TestFrame); 
  
  trace( this[mcParent] ); // it returns _level0.mcParent
  trace( Parent( this[mcParent] ); // the movieclip is there, but it
returns null 

  this.onEnterFrame = laterFunction;
} 

function laterFunction():Void
{
  this.onEnterFrame = null;
  trace( this[mcParent] ); // it returns _level0.mcParent
  trace( Parent( this[mcParent] ); // now it returns _level0.mcParent
correctly } 



The similar problem exists in Child1 and Child2 inside Parent timeline. It
seems to me that the MovieClip is not converted to its associated class
until later time, so I have to split my logic into two different functions,
whic makes the code look cumbersome and hard to manage. 

A more detailed example of the problem above can be downloaded at,
http://www.acts.net/Flash/ComponentBlue.zip 

Although putting components on the stage using attachMovie might solve the
problem, but I would like the designer to have the freedom to arrange the
components on the stage the way he likes, and attachMovie would take away
this freedom. I wonder if anyone has a cleaner way around this problem. 

TIA!

- Tangent

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com