Flex bug trying to import actionscript files - apache-flex

The "import "Player.as" line throws the error: 1084: Syntax error: expecting rightbrace before semicolon.
package {
import "Player.as"; //ERROR
import "Card.as";
public class Game {
I was going great with Flex, until I tried to split up my code into separate files. Now I'm struggling.
Here are my files and their dependencies:
**poker.mxml**
include "fb.as";
<mx:Script source="Game.as"/>
**Game.as**
import "Player.as";
import "Card.as";
**fb.as**
**Card.as**
**Player.as**

I'm guessing Player.as and Card.as are in the same package as Game.as?
If they're in the same package, you don't need to import them. Also, import statements don't usually have the .as extension.

When importing, you don't use the file name, but the package and class, and no quotes needed:
package
{
import Player;
import Card;
public class Game {}
}
You don't actually have to import them if they're in the top level or the same package as the class you're editing, though. If your Player and Card classes are in packages other than the top level, then you need to include the package. Here's an example with some arbitrary package names that came off the top of my head:
package
{
import com.example.Player;
import com.example.deck.Card;
public class Game {}
}
In MXML, you don't include classes using the element's source parameter. You can import them in the same way, actually.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
applicationComplete="applicationCompleteHandler(event)">
<mx:Script><![CDATA[
import com.example.Player;
import mx.events.FlexEvent;
private var _player:Player;
//this event handler is called once the application is fully created
//and drawn for the first time.
private function applicationCompleteHandler(event:FlexEvent):void
{
_player = new Player();
}
]]></mx:Script>
</mx:Application>

import declarations come before the package, IIRC.

Related

Vuejs3 import into composable

I want to use the functionally of the vue-papa-parse in a composable file. I have tested and found vue-papa-parse to work as described when I import it into a vue component. But I can't figure out how to import it into my JavaScript composable function.
main.js
import { createApp } from 'vue'
import App from './App.vue'
import VuePapaParse from 'vue-papa-parse'
const app = createApp(App)
app.use(VuePapaParse)
app.mount('#app')
usePapaParse.js
import VuePapaParse from 'vue-papa-parse'
export default function usePapaParse(){
function csvToJson(){
this.$papa.parse('name,address,city,state,zip') // error, can't read parse of undefined
console.log(this.$papa.data)
}
}
I think your problem is because you are not in the scope of a .vue file and thus do not have injected defaults.
I suspect this library exposes some export that you can use directly.
try to call some function directly on the imported object
import VuePapaParse from 'vue-papa-parse'
//maybe VuePapaParse.parse
VuePapaParse.someFunc
second approach
import * as papa from 'vue-papa-parse'
//check what intellisense shows here
papa.<something>

Import .stories file into another .stories file with Storybook?

Can you import one .stories file into another .stories with Storybook?
Eg I have
/component1/component1.tsx
/component1/component1.stories.tsx
/component2/component2.tsx
/component2/component2.stories.tsx
I would like to also have a story for all of my components:
In /all-components/all-components.stories.tsx
import * as React from 'react';
import Component1Story from '../component1/component1.stories.tsx';
import Component2Story from '../component2/component2.stories.tsx';
export const Test = () => {
return (
<div>
<Component1Story />
<Component2Story />
</div>
);
};
export default {
title: 'Components',
};
I get this error:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of storyFn.
this should be doable as your stories are just React components. Your problem is happening because you're trying to import the default from your module, which is actually just an object:
export default {
title: 'Components',
};
All stories are named exports, and you should import them with destructuring:
import { Component1Story } from '../component1/component1.stories';
import { Component2Story } from '../component2/component2.stories';
I created an example for you which shows a working scenario here.
p.s. It's interesting to know that starting with Storybook 6 there's a new mechanism to simplify the creation and reuse of stories so stay tuned! It's called Args.

Missing observable methods RxJS 5.0.0-beta.0

I'm having a problem using RxJS with Angular 2. Most of methods suggested from Typescript definition file are not defined on my Observable object like...
then I figured out, that methods does not exists on the Observable prototype.
I know a lot of things changed from version 4 to 5,so do I miss something?
Browserify added it for me...
Without seeing your actual code, I can't tell you exactly what to add to fix it.
But the general problem is this: RxJS 5 is not included with Angular 2 any longer now that it has entered the Beta stage. You will need to import either the operator(s) you want, or import them all. The import statements looks like this:
import 'rxjs/add/operator/map'; // imports just map
import 'rxjs/add/operator/mergeMap'; // just mergeMap
import 'rxjs/add/operator/switchMap'; // just switchMap
import {delay} from 'rxjs/operator/delay'; // just delay
or like
import 'rxjs/Rx'; // import everything
To determine the path to your desired module, look at the source tree. Every import with add will add properties to Observable or Observable.prototype. Without add, you'd need to do import {foo} from 'rxjs/path/to/foo'.
You will also need to make sure that RxJS is being brought into the project correctly. Something like this would go into your index.html file:
System.config({
map: {
'rxjs': 'node_modules/rxjs' // this tells the app where to find the above import statement code
},
packages: {
'app': {defaultExtension: 'js'}, // if your app in the `app` folder
'rxjs': {defaultExtension: 'js'}
}
});
System.import('app/app'); // main file is `app/app.ts`
If you use Webpack to build the Angular 2 app like in this Github project (like I did), then you don't need that System stuff and the imports should do it.
Yes, in Angular 2.0 you have to include the operators/observables you need.
I do it like this:
import 'rxjs/operator/map';
import 'rxjs/operator/delay';
import 'rxjs/operator/mergeMap';
import 'rxjs/operator/switchMap';
import 'rxjs/observable/interval';
import 'rxjs/observable/forkJoin';
import 'rxjs/observable/fromEvent';
However, you also need to configure this in System.js
System.config({
defaultJSExtensions: true,
paths: {
'rxjs/observable/*' : './node_modules/rxjs/add/observable/*.js',
'rxjs/operator/*' : './node_modules/rxjs/add/operator/*.js',
'rxjs/*' : './node_modules/rxjs/*.js'
}
});
Here is working code: https://github.com/thelgevold/angular-2-samples
I have a JSPM setup in my project, so adding rxjs to the path section was not enough.
jspm added the following to my SystemJS configuration (map section):
"npm:angular2#2.0.0-beta.6": {
"crypto": "github:jspm/nodelibs-crypto#0.1.0",
"es6-promise": "npm:es6-promise#3.1.2",
"es6-shim": "npm:es6-shim#0.33.13",
"process": "github:jspm/nodelibs-process#0.1.2",
"reflect-metadata": "npm:reflect-metadata#0.1.2",
"rxjs": "npm:rxjs#5.0.0-beta.0",
"zone.js": "npm:zone.js#0.5.14"
},
So if you use jspm make sure you remove the rxjs mapping above, otherwise some rxjs files will be loaded twice, once via jspm_packages and once via node_modules.

Vaadin Responsive layout not working

Im using new Version of Vaadin which is 7.4.5+
package com.example.projnew;
import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.data.util.PropertysetItem;
import com.vaadin.server.Responsive;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Form;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
#SuppressWarnings("serial")
#Theme("projnew")
public class ProjnewUI extends UI {
#WebServlet(value = "/*", asyncSupported = true)
#VaadinServletConfiguration(productionMode = false, ui = ProjnewUI.class)
public static class Servlet extends VaadinServlet {
}
#Override
protected void init(VaadinRequest request) {
CssLayout layout = new CssLayout();
layout.setSizeFull();
layout.setStyleName("flexwrap");
setContent(layout);
Responsive.makeResponsive(layout);
Label title = new Label("Space is big, Really big");
title.addStyleName("title");
layout.addComponent(title);
Label description = new Label("This is a "
+ "long description of the image shown "
+ "on the right or below, depending on the "
+ "screen width. The text here could continue long.");
description.addStyleName("itembox");
description.setSizeUndefined();
layout.addComponent(description);
}
}
My style
#import "addons.scss";
#import "projnew.scss";
/* This file prefixes all rules with the theme name to avoid causing conflicts with other themes. */
/* The actual styles should be defined in projnew.scss */
.projnew {
#include addons;
#include projnew;
.flexwrap {
background: black;
&[width-range~="0-300px"] {
background: red;
}
}
}
Why does my design cant respond to the width I supposed to..
I tried many examples at vaadin but it doesnt work also.
And why is it that some examples they use com.vaadin.addon.responsive.Responsive but in my Vaadin version which is already in the utility and I imported com.vaadin.server.Responsive
What I supposed to do ?
I know this is a bit late and you probably already solved it, but...
The reason why they use com.vaadin.addon.responsive.Responsive is because Responsive used to be an extension and later they integrated it in the framework.
Are you sure the component is getting the width-range attribute? Open your browser's inspector, look at the component and see if it's there. If it is, then you have an issue with your CSS. If it isn't, or it is somewhere else, be sure you have applied it to the proper element.

Flex - Changing component states through main

i'm trying to change components states through a control bar button (id=btn) in main... so i add an event listener to it ... the code goes like this
import flash.events.EventDispatcher;
import flash.events.MouseEvent;
import mx.core.FlexGlobals;
FlexGlobals.topLevelApplication.btn.addEventListener
(MouseEvent.MOUSE_DOWN, change_state, true, 0, false);
public function change_state(e:MouseEvent):void{this.currentState="wait";}
but i get an "1120-access of undefined property change_state" error... can someone help me !?
I have a feeling that the underscore in change_state is causing issues and I feel there might be a scope issue, when you reference it. Try rewriting your code like this:
import flash.events.EventDispatcher;
import flash.events.MouseEvent;
import mx.core.FlexGlobals;
FlexGlobals.topLevelApplication.btn.addEventListener(MouseEvent.MOUSE_DOWN,this.changeState, true, 0, false);
public function changeState(e:MouseEvent):void{this.currentState="wait";}
Does this make a big difference?

Resources