• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How can you determine the absolute path to a dynamically created NetStream object?

New Here ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

We are trying to implement video captioning with a freeware component, ccforflash. This requires us to provide an absolute or relative path  to our NetStream object. How can we determine this path in Flash CS5 AS3?

From the CCforFlashCS5 documentation:

"2. Object name and path

Type the name and path.  This is the instance name of the object with which CCforFlashAS3 will synchronize. It must be spelled correctly, since CCforFlashAS3 will query the object with this name for timing information in order to synchronize the captions. The path must also be included; either relative to the CCforFlashAS3 component (i.e. this.parent) or the absolute path from the main level of the movie (root)."

TOPICS
ActionScript

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 26, 2012 Jun 26, 2012

I guess I understand your problem and agree that AS2 had a nice way of identifying a path to something as compared to what AS3 does.  I am going to see if I can stir up someone else's interest in your posting who is a better sleuth than I.

But if I can get stoopid for a minute and suggest trying something (I would try it)... If you have access to the code where the NetStream object is instantiated, right after it is given life, assign that instance to a variable you have in the main timeline and

...

Votes

Translate

Translate
LEGEND ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

You determine it based on where you have the objects located.  If your component is in the same timeline as the NetStream object, then a relative path will probably be the easiest... it will just be the instance name of the object. 

If the objects are on different timelines, then you might find it easier to target using a path from the root timeline, though using a relative path still might be easier if the NetStream is in a child object relative to the timeline of the component.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

It would be easier if the NetStream object was created on an easily identifiable place on the timeline. This player has an MVC architecture. The NetStream object is created in a subclass to Model class, which is itself a subclass of the EventDispatcher object. The View class access it via an interface.

As you can guess, it's not that straightforward to determine where the NetStream object is located on the timeline. This is compounded by the fact that the NetStream object does not have a name property.

I've tried methods like these, but they only work for the DisplayObject class:

public static function displayObjectPath( avDisplayObject : DisplayObject ) :String
{
var lvPath:String = "";
do
{
if( avDisplayObject.name ) {
// var obj_name:String = (avDisplayObject.name == 'root1') ? 'root' : avDisplayObject.name;
if (avDisplayObject.name != 'root1') {
lvPath = avDisplayObject.name
   + ( lvPath == "" ? "" : "." + lvPath );
}
} else {
trace("displayObjectPath() NO NAME avDisplayObject="+avDisplayObject);
}
} while( avDisplayObject = avDisplayObject.parent );
return lvPath;
} // displayObjectPath
private  function showChildren(d:DisplayObjectContainer):void {
trace("showChildren()");
if (d.numChildren>0) {
for (var c:Number = 0; c < d.numChildren; c++) {
trace("showChildren c=",c," name=",d.getChildAt(c).name);
}
}
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

Are you saying you have no idea where the NetStream object is declared?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

I'm saying that the NetStream object and Video object are declared in the Model class which is a subclass of a EventDispatcher. It's not declared inside a DisplayObject or MovieClip, which I could get the path to. I know the DisplayObject that they are attached to, but the Video and NetStream objects don't have name attributes. I've tried using the Video and NetStream object variable names and that doesn't work.

Is there some debugging method in Flash that will show you the path to an object that is not a DisplayObject? e.g. settings in the debugger config file?

I think this plug-in that I'm working with was originally written in AS2. In AS2, you could just trace the object and see the path.

Thanks for trying to help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

I guess I understand your problem and agree that AS2 had a nice way of identifying a path to something as compared to what AS3 does.  I am going to see if I can stir up someone else's interest in your posting who is a better sleuth than I.

But if I can get stoopid for a minute and suggest trying something (I would try it)... If you have access to the code where the NetStream object is instantiated, right after it is given life, assign that instance to a variable you have in the main timeline and use that variable (and the root timeline or a "this"-based reference for the path requirement) for your CCforFlashCS5 needs. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2012 Jun 27, 2012

Copy link to clipboard

Copied

That worked! Thanks, Ned.

The model, for some reason, did not have a reference to the root MovieClip. Once I added that, I could make the assignment you suggested and - voila, it works! I guess the plug-in doesn't care that the path leads to the DisplayObject that contains the video; it just needs a reference to the NetStream object.

Thanks for your "stoopid" sugguestion.

-Chris

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 27, 2012 Jun 27, 2012

Copy link to clipboard

Copied

LATEST

Well whaddya know!  You're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

define a public getter for your Model class that returns your netstream instance and pass your model instance dot getter to that component.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines