Why as3 giving me syntax error in a for loop? - actionscript-3

I'm new with actionscript and I keep getting syntax error with the following for loop:
for each (target:Target in targets) {
if(target != null) {
target.parent.removeChild(target);
}
}
And I got this error message:
Syntax error: expecting in before colon.
What is the problem?

You forgot to declare the variable, it should be:
for each (var target:Target in targets) {
// …
}
Note the var.

Related

setAttribute is undefined ,why?

This is my code follow:
[in html]```
```
[in css]```
.myclass {
width:50%;
}```
[in js] function changewidth() { let mynodes = document.getElementsByClassName('.myclass'); mynodes.setAttribute('width','100%'); }
then, when this function be run, it display:
Uncaught TypeError: Cannot read properties of undefined, when reading 'setAttribute'
what happen and how to correct ?
thanks
The error says that the myNodes variable is undefined meaning JavaScript cant find it anywhere because it doesn't exist.
Remove the dot(.) in
document.getElementsByClassName('.myclass')
It should be
document.getElementsByClassName('myclass')

Uncaught Error: Undefined constant "image"

I've an error when i execute the API JSON :
This is my code :
$image = get_the_post_thumbnail_url($post);
if (!image) {
$image = "";
}
And the error :
Uncaught Error: Undefined constant "image" in C:\xampp\htdocs\app\wp-content\themes\twentytwenty\functions.php:873
thx
There is an issue in this line.
if (!image) {
.. it should be.
if (!$image) {
It is a weird logic though because it says that when the $image is undefined or empty, empty it or assign a blank string literal to it.

convertFromRaw giving this error "Invariant Violation: invalid RawDraftContentState"

I want to convert html code to draft object to save my editorState
But convertFromRaw function giving me Invariant Violation: invalid RawDraftContentState <- this error.
try {
const htmlToDraftObject = htmlToDraft(
post.content
);
console.log(htmlToDraftObject);
console.log(convertFromRaw(htmlToDraftObject));
} catch (error) {
console.log(error, "error");
}
console.log(htmlToDraftObject);
this line is returns this object
{"contentBlocks":[{"key":"apdo3","type":"unstyled","text":"\"\\n","characterList":[{"style":[],"entity":null},{"style":[],"entity":null},{"style":[],"entity":null}],"depth":0,"data":{}},{"key":"2lgc","type":"unstyled","text":"","characterList":[],"depth":0,"data":{}},{"key":"118p1","type":"atomic","text":" \\n","characterList":[{"style":[],"entity":"5526de6f-06fd-445d-9ae4-e5bae145adab"},{"style":[],"entity":null},{"style":[],"entity":null}],"depth":0,"data":{}},{"key":"13tke","type":"unstyled","text":"\\n\"","characterList":[{"style":[],"entity":null},{"style":[],"entity":null},{"style":[],"entity":null}],"depth":0,"data":{}}],"entityMap":{"5526de6f-06fd-445d-9ae4-e5bae145adab":{"type":"IMAGE","mutability":"MUTABLE","data":{"src":"\\\"https://p.bigstockphoto.com/GeFvQkBbSLaMdpKXF1Zv_bigstock-Aerial-View-Of-Blue-Lakes-And--227291596.jpg\\\"","alt":"\\\"undefined\\\"","height":"","width":""}}}}
post.content is a simple html code
I tried it without htmlToDraft function too .But it gave me another error
what am I doing wrong?

react native- json parsing (cant parse json object in my code)

Here is my code. In this I got x but when I try to parsing x for getting object of x 'isloggedin' it gives error. what should I do wrong tell me if you understand my problem.
componentDidMount() {
this.onLoad();
}
onLoad = async () => {
try {
var walletdata = await AsyncStorage.getItem('wallet');
this.setState({x: JSON.parse(walletdata)})
this.setState({y: JSON.stringify(this.state.x)})
console.log("output: "+ this.state.y);
console.log("output y:"+JSON.parse(this.state.y.isloggedIn));
}catch(error){
console.log("error: "+error);
}
}
error: SyntaxError: JSON Parse error: Unexpected identifier "undefined"
Probably is because 'wallet' key has undefined value in the caché storage. You should check first the value (right after getting the item from the storage) and if it's undefined then you have to set it first.
Probably you need to wait for the first setState function to finish, So that you can get access to it in second call.
In short, It will take some time for setting your value in State and you are trying to access it before updating the state. So try to access the values in the callback of setState function.
Instead of this,
this.setState({x: JSON.parse(walletdata)})
this.setState({y: JSON.stringify(this.state.x)})
console.log("output: "+ this.state.y);
console.log("output y:"+JSON.parse(this.state.y.isloggedIn));
You can use this:
this.setState({x: JSON.parse(walletdata),y: JSON.stringify(walletdata.x)},()=>{
console.log("output: "+ this.state.y);
console.log("output y:"+JSON.parse(this.state.y.isloggedIn));
});
I have solved my problem. Thank you for your answers. below is how could I solved my question.
try {
var walletdata = await AsyncStorage.getItem('wallet');
this.setState({wallet: JSON.stringify(JSON.parse(walletdata))})
this.setState({isLoggedin:JSON.parse
(this.state.wallet).isLoggedin});
console.log(this.state.isLoggedin);
}catch(error){
console.log("error: "+error);
}

Hel­p with actionscript 3 syntax

I would like your help here, this is my actionscript3 code.
Everytime I compile I get error.
Line 1537 1073: Syntax error: expecting a catch or a finally clause.
This is the code
{
try
{
}
_loc_3.badge.gotoAndStop(param1.split(":")[2]);
}
And the second error
{
try
{
}
_loc_3.badge.gotoAndStop(param1.split(":")[2]);
}
The second error says:
Line 1537 1084: Syntax error: expecting rightbrace before semicolon.
Could anyone help me here, thanks in advance.
UPDATE: After I add a right brace before the semicolon it gives more errors.
The first error is really explicit, you need a catch block. The empty try block is useless.
The syntax found on a website.
try {
//Your code
}
catch(e:Error) { // Error handling
trace("Error found: " + e);
}
//Optional
finally {
// Closing connection for example.
}
Website reference in french
A try cannot be used without a catch. the idea there is lets try this piece of code and if we run into any problems stop and execute the content of whatever is in the catch. the finally is used for executing code that you want to run regardless of whether the try or catch gets executed.
in the first error:
you are just missing a catch. also maybe include some code into the try statement, otherwise its pointless to use.
example:
try
{
//try to feed my dog
feedDog();
}
//if some error occurs in feedDog() then the catch will be called
//if you want to catch specific exceptions
//then specify its type instead of Exception
catch (Exception e)
{
trace("unable to feed dog");
}
//this will execute whether the dog was fed successfully or not
finally
{
trace("leave");
}
with the second error: you are probably missing a '}' somewhere in that function. Indent your code so that these will become clearly visible to you and you can match every '{' with its corresponding '}'