NetStream OnMetaData error - actionscript-3

I have this error:
on this code :
In another project, my class works well, but here it does not. Why?

Your video contains closed caption events, but you haven't registered an event listener to handle the "Show this line of text" event (OnMetaData), so the appearance of caption data is an uncaught exception.
Register an event listener, even if it does nothing, or use a video without captions.

Related

Error 1120 For stage instances

I am getting a number of errors for each of my items, each on different keyframes.
I have "Automatically Declare Stage Instances" turned off so I thought that might be having something to do with it. It is quite annoying. The errors only show up when I test the MainMenu scene, testing the movie has the buttons not animating.
I have tried to fit all the info into some screen shots.
I would appreciate any help you could render. At this point I'm out of ideas.
Errors and Instance Properties
Symbol Properties of Menu and Script Class
Either: the button you are targeting is incorrect..
Your error reads: access to undefined property button_main_quit //check the spelling "button_main_quit"
Also you should use debug mode it will tell you where the error is
Another: the button is declared on a different frame after the instance was already assigned.
An example:
Lets say you have two timelines the top is named actions the second is named content: in the top actions timeline frame 1 you add an event Enter-Frame function for example: then you add a listener for a button call it "btn_1".Now on the content layer, you add the button but on the 5th frame on the content layer:
now you will have the error because the button was not on the stage to be assigned ready for the listener we had added on the enter-Frame function on frame one.
Hopefully you get the idea.

addEventListener and gotoAndStop for a menu in a game gives error

I'm new at flash as3. Today, I am trying to code a menu in a game which will refer to a startscreen for a game to show the buttons for the game.
In this startscreen, there is a button to link back to the menu. It doesn't work. I am getting this,
Error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at SuperSpill_fla::MainTimeline/frame1()
It looks like to me the only possible thing that could have happened is that mus doesn't exist anymore. This suggests that the code is running in a frame where mus is no longer on stage.
I would expect that in most versions of the Flash Player that the frame wouldn't fully render between goToAndStop and the next line, but my suggestion would be to either swap the order of those lines or change it to
event.currentTarget.removeEventListener(MouseEvent.CLICK, musSpill)

How to capture all keyboard input to a custom element?

Here is my problem: I've got a swf loaed inside my loader an in that swf I have a keylistener:
stage.addEventListener(KeyboardEvent.KEY_DOWN, this.__onKeyDown, false, int.MAX_VALUE);
Now I'm adding a TextInput to this stage and I would like this input to catch all keyboard events while I'm focusing it. Is it possible to do so that native __onKeyDown will not fire until my TextInput has lost focus?
Thank you for your answers and sorry for my bad english.
You could give your listener higher priority (which you are), and stopAllPropogation in your handler. I've never tried this with an embedded swf so if it doesn't work right away, you could also try listening to the event in the capture phase (third parameter in addEventListener).
function __onKeyDown(e:KeyboardEvent):void {
e.stopImmediatePropagation();
//rest of you handler code here
}

Error 1009 in AS3

I have TextField instance called inputWord which contains no text on the first frame. On the same frame, on the actions layer, any time when I refer to inputWord in any way, there is an error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at DC/frame1()[DC::frame1:19] //DC is the name of document class that I created.
at flash.display::MovieClip/gotoAndStop()
at DC()[C:\Users\nikkka\Desktop\flash\DC.as:25]
19 is the number of line where my code that involves inputWord is located. It works, I mean I write
inputWord.text = "smth"
it text becomes "smth" but there is the same error. Why?
The problem is with gotoAndStop()
in as2, when you do a gotoAndStop you can access the resources in the frame right away, as Kevin pointed out, the frame has to be rendered first
to do this, you need to use an onrender listener to fire when you rendered the frame to deal with the frame related logic. Then you need to invalidate the stage, to force the rendering to fire.
like so:
stage.addEventListener(Event.RENDER, onRenderStage);
protected function onRenderStage(ev:Event):void {
inputWord.text = "smth"
trace(inputWord.text);
}
gotoAndStop(5);
stage.invalidate();
Probably on the first frame, inputWord is not loaded yet so you get an error. On the next frames, it is loaded so the text is being set successfully. The solution is test for the existence of the text field before setting it:
if (this.inputWord) this.inputWord.text = "smth";

Communicating to Parent SWF

Hey guys I'm having such a hard time of it today.
I have a game, I've loaded into a parent SWF -
I would like my parent SWF to accept events I dispatch from within the game,
or have the ability to talk both ways.
--
Reason is, I would like to unload and load the game back in, once the end screen is active.
Any help and I'll give you beer.
thanks in advance.
Are the events dispatched by your game allowed to bubble up to your loader swf? The default value for the Event constructor sets this to false. If you were to set it to true, however, an event dispatched by a child swf would make it to its parent's listener.
For example: this.dispatchEvent(new Event("SOME_GAME_EVENT", true, true));
The first 'true' value says that the event should bubble up through the object hierarchy. The second says that the Event is cancelable. Once your loader swf has handled the Event, it is best to then call .stopPropagation() on the event so it does not further bubble unneccessarily.
can't you put in your parentSWF:
childSWF.addEventListener(MyCustomEvent.SOME_EVENT, listener) and just dispatch the events from the game?
As for talking the other way, it can call childSWF.someFunction() to call functions in the document class of childSWF, etc.