sharedObject does not save my data. - actionscript-2

static private function ifonEnternameFrame():Void
{
so.data.name = _root.getName.text;
//trace(so.data.name);
_root.nameBtn.onPress = function ()
{
_root.gotoAndStop(2);
}
}
When you start the application this code will save your name.
But when you then go to another function then it says that it's undefined.
trace(so.data.name);
I traced this when I was on the next frame and it couldn't find the previous name.
Please help.

Flushing the shared object data is necessary to get those variables.
Use the flush function of shared object.

Your problem doesn't come from SharedObject. The origin of your error message is that your textField getName is incorrectly named in your code.
If you trace _root.getName.text in your function ifonEnternameFrame you shall have the same error message:
trace(_root.getName.text); // undefined

Related

When does RTCDataChannel.onerror is called?

I'm making a program to transmit data with WebRTC. I want to implement RTCDataChannel.onerror because I want to deal with an error event.
I read the document below, but the explanation is ambiguous. I want more specific information about the error. I want to know what happens when this method is called.
https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/onerror
The RTCDataChannel.onerror is an attribute which you should set to a function. You should set the value of RTCDataChannel.onerror to a function which handles the error. For example:
RTCDataChannel.onerror = function(error) {
// handle the error
alert("Uh oh, there is a problem. " + error);
}

Blockly How to create a Variable to the workspace (developer variable)

I want to create a Developer Variable to the workspace in Blockly, but I cannot find the necessary function/method.
I do not want to create the variable over a button. The variable should be included even if there is no block in the workspace.
With these two functions I can get the already created variables:
var variables = workspace.getAllVariables();
var dev_var = Blockly.Variables.allDeveloperVariables(workspace);
But what is the setting function?
Developer variables are variables that will never be visible to the user, but will exist in the generated code. If that's what you're looking for: there's no API for it, but here are some things you can do.
If you want to reserve the name so that users can't accidentally override your variable, call yourGenerator.addReservedWords('var1,var2,...'). You can initialize the variable in your wrapper code.
If you really want Blockly to both reserve and declare the variable for you, you could override the init function on your generator.
On the other hand, if what you want is a user-visible variable that always shows up in the toolbox, without the user creating it, you should call yourWorkspace.createVariable('variable_name').
The unit test blocks all assume that the variable unittestResults exists and can be written to. To indicate this, the block definition includes the function getDeveloperVars, which returns an array of strings. Each string is a variable name.Follow this issue in gtihub
Blockly.Blocks['unittest_fail'] = {
// Always assert an error.
init: function() {
this.setColour(65);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput('test name'), 'MESSAGE')
.appendField('fail');
this.setTooltip('Records an error.');
},
getDeveloperVars: function() {
return ['unittestResults'];
}
};
LINK : https://github.com/google/blockly/issues/1535

How do I get the Event.Complete event in a file upload to fire in Flash Builder

The file is getting uploaded properly and my ProgessEvent.Progress method is showing 100% complete, but my Event.Complete method does not fire. Do I have to send something specific back from the server? I am simply sending back a success message. I am not getting any errors.
I suppose I could just proceed when the progress method hits 100%. Shouldn't the Event.Complete method be firing after the data is sent and a response is received from the server?
**Update: I am getting an error with my Event.Complete method....
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event#1277971f1 to flash.events.DataEvent.
* I fixed the problem by changing my onLoadComplete(event:DataEvent) method to onLoadComplete(event:Event). The error went away and I my method is now firing. I will answer my own question when the system allows me to.
Relative code follows:
fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, onFileSelected);
fileRef.addEventListener(Event.COMPLETE, onUploadComplete);
fileRef.addEventListener(ProgressEvent.PROGRESS,onUploadProgress);
fileRef.addEventListener(IOErrorEvent.IO_ERROR, onUploadError);
fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onUploadError);
private function onUploadProgress(event:ProgressEvent):void {
status = ((event.bytesLoaded * 100) / event.bytesTotal).toString();
}
private function onUploadComplete(event:DataEvent): void {
status = "Complete";
}
private function onUploadError(event:Event):void {
if (event is IOErrorEvent) {
Alert.show((event as IOErrorEvent).text.toString());
} else if (event is SecurityErrorEvent) {
Alert.show((event as SecurityErrorEvent).text.toString());
} else {
status = "Unknown error";
}
}
I changed ...
private function onUploadComplete(event:DataEvent):void {
status = "Complete: "+event.toString();
}
To...
private function onUploadComplete(event:Event):void {
status = "Complete: "+event.toString();
}
I am guessing this is because I am not sending data back, only a simple xml block. Hope this helps someone else.

How to register component interface in wxwebconnect?

I'm doing an experiment with wxWebConnect test application, incorporating the xpcom tutorial at "http://nerdlife.net/building-a-c-xpcom-component-in-windows/"
I adapt MyComponent class as necessary to compile together with testapp.exe (not as separate dll), and on MyApp::OnInit I have the following lines:
ns_smartptr<nsIComponentRegistrar> comp_reg;
res = NS_GetComponentRegistrar(&comp_reg.p);
if (NS_FAILED(res))
return false;
ns_smartptr<nsIFactory> prompt_factory;
CreateMyComponentFactory(&prompt_factory.p);
nsCID prompt_cid = MYCOMPONENT_CID;
res = comp_reg->RegisterFactory(prompt_cid,
"MyComponent",
"#mozilla.org/mycomp;1",
prompt_factory);
Those lines are copied from GeckoEngine::Init(), using the same mechanism to register PromptService, etc. The code compiles well and testapp.exe is running as expected.
I put javascript test as below :
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const cid = "#mozilla.org/mycomp;1";
obj = Components.classes[cid].createInstance();
alert(typeof obj);
// bind the instance we just created to our interface
alert(Components.interfaces.nsIMyComponent);
obj = obj.QueryInterface(Components.interfaces.nsIMyComponent);
} catch (err) {
alert(err);
return;
}
and get the following exception:
Could not convert JavaScript argument arg 0 [nsISupport.QueryInterface]
The first alert says "object", so the line
Components.classes[cid].createInstance()
is returning the created instance.
The second alert says "undefined", so the interface nsIMyComponent is not recognized by XULRunner.
How to dynamically registering nsIMyComponent interface in wxWebConnect environment ?
Thx
I'm not sure what is happening here. The first thing I would check is that your component is scriptable (I assume it is, since the demo you copy from is). The next thing I would check is whether you can instantiate other, standard XULRunner components and get their interface (try something like "alert('Components.interfaces.nsIFile');" - at least in my version of wxWebConnect this shows an alert box with string "nsIFile".
Also, I think it would be worth checking the Error Console to make sure there are no errors or warnings reported. A magic string to do that (in Javascript) is:
window.open('chrome://global/content/console.xul', '', 'chrome,dialog=no,toolbar,resizable');

vtable error. "vtable for ETRun", referenced from:

I have an object called Run. I can instantiate in header of a class. But, when i try to do the same .cpp file the above error was popped out.
vtable error. "vtable for Run",
referenced from:
__ZTV5Run$non_lazy_ptr in Para.o
string Para::name()
{
Run* newRun = new Run;
return mName;
}
how can i get out of this error...
This probably happens because Run is a derived class, and it has a declaration of some virtual function but this function is not implemented.
Try to check whether your problem is this case.