I am trying to build a ActionScript side library for my SIP library Adobe AIR native extension following this blog from Adobe, in FlashDevelop IDE. When I build the project I get the following compile time error:
C:\Users\Osama
Mohammed\Documents\AndroidSIPManager\src\in\innovative\androidsipmanager\AndroidSIPManager.as(1):
col: 9 Error: Syntax error: expecting identifier before in.
I don't know why am I getting that error, although my syntax is right. I get this error when I write package name after package keyword in any ActionScript 3 project in ActionScript file, Eg. package my.package { ..., but don't get it when no package name is written after package keyword. Following is my AndroidSIPManager.as code:
package in.innovative.androidsipmanager //getting error here
{
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
/**
* ...
* #author Osama Mohammed Shaikh
*/
public class AndroidSIPManager extends EventDispatcher
{
private var extContext:ExtensionContext;
public function AndroidSIPManager(target:IEventDispatcher=null)
{
super(target);
extContext = ExtensionContext.createExtensionContext("in.innovative.SIPLibExtension", "sip");
if (!extContext)
{
throw new Error("SIP Library extension is not supported on this platform");
}
}
public function initialize(enum_transport:int, agent:String, STUNServer:String, STUNServerPort:int):int
{
return int (extContext.call("initialize", enum_transport, agent, STUNServer, STUNServerPort));
}
public function setUserInfo(userName:String, displayName:String, authName:String, password:String, localSIPPort:int, userDomain:String, SIPServer:String, SIPServerPort:int, outboundServer:String, outboundServerPort:int):int
{
return int (extContext.call("setUserInfo", userName, displayName, authName, password, localSIPPort, userDomain, SIPServer, SIPServerPort, outboundServer, outboundServerPort));
}
public function portSipCall(callee:String, enum_mediaType:int):Number
{
return Number (extContext.call("portSipCall", callee, enum_mediaType));
}
}
}
Please help me solve the problem.
Problem is that in is reserved word. This is the reason, why you're able to compile project after removing the package name completely.
Related
So im trying to understand how I can call a function from one class from another class. Im getting a few errors and am wondering if someone can explain what im doing wrong here.
Main file:
package code {
import flash.display.MovieClip;
import flash.events.*;
import code.*;
import code.functions.*;
public class Main extends MovieClip {
public var _playerHP:Number;
public var _enemyYellow:EnemyYellow;
public function Main() {
_enemyYellow = new EnemyYellow;
_playerHP = 10;
_playerHPdisplay.text = _playerHP.toString();
trace("loaded")
}
public function lowerHP ():void
{
_playerHP -= 1;
_playerHPdisplay.text = _playerHP.toString();
trace(_playerHP)
}
}
}
Second File:
package code.functions {
import flash.display.MovieClip;
import flash.events.*;
import code.Main;
public class EnemyYellow extends MovieClip {
public var _main:Main;
public function EnemyYellow() {
_main = new Main;
_main.lowerHP();
trace ("test")
}
}
}
It will then load with a blackscreen and the following error:
Error: Error #2136: The SWF file file:///test/Main.swf contains invalid data.
at code.functions::EnemyYellow()[test\code\functions\EnemyYellow.as:15]
at code::Main()[test\code\Main.as:16]
Error opening URL 'file:///test/Main.swf'
However, If I remove _enemyYellow = new EnemyYellow; from the Main file it loads but the second file is not loaded.
If I remove _main = new Main; from the Second file, the game again loads but it does not call the lower HP function, and I get the following error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at code.functions::EnemyYellow()[test\code\functions\EnemyYellow.as:16]
at code::Main()[test\code\Main.as:16]
If anyone could help me it would be appreciated. Im just trying to get my head around how to call a function from another file..
_playerHPdisplay.text is also a text box on the stage when the game loads.
If you do not assign a value to _main, it is null. That's why you receive the #1009 if you do not assign new Main() to it.
However, you do not want to create a new Main object either.
The main class represents the application and generally speaking you do no explicitly instantiate it in your project.
To make your code work, you have to pass a reference of Main to the enemy class.
A better approach to this is to let the enemy class dispatch events, so that the Main class can be notified "some damage was dealt". This however will not work from within the constructor of enemy.
Think about whether your package names make sense. Pretty much all packages contain code, which makes "code" a not very informative name. The package "functions" contains the class EnemyYellow, which doesn't seem to be a good fit.
HelloWorld.ceylon
import java.util { HashMap } //Error:(1, 8) ceylon: package not found in imported modules: java.util (define a module and add module import to its module descriptor)
void run() {
print("test");
}
module.properties
module CeylonHelloWorld "1.0" {
import java.base "8";
}
I get an exception in HelloWord.ceylon file
When I try that code, I get:
Incorrect syntax: mismatched token CeylonHelloWorld expecting initial-lowercase identifier
In module.ceylon.
The name of a module is supposed to be of form foo.bar.baz (initial-lowercase identifiers separated by periods).
Like mentioned by Gavin you will have to use a legal module name, when I change your code to use the module name "java8test" I get the following output when compiling:
$ ceylon compile java8test
warning: It looks like you are using class files from a Java newer than 1.7.
Everything should work well, but if not, let us know at https://github.com/ceylon/ceylon-compiler/issues.
In the near future, the Ceylon compiler will be upgraded to handle Java 1.8.
./source/java8test/run.ceylon:1: warning: import is never used: 'HashMap'
import java.util { HashMap }
^
2 warnings
Note: Created module java8test/1.0.0
Which is all as expected.
module.ceylon
module holaCeylon "1.0.0"{
import java.base "7"; // versiĆ³n 7 JDK
}
package.ceylon
shared package holaCeylon;
Now we go back to the run.ceylon file and import the java.util.HashMap Java library.
run.ceylon
import java.util { HashMap }
shared void run(){
print("Importando librerias de Java en Ceylon");
value romanos = HashMap<String,Integer>();
romanos.put("I", 1);
romanos.put("V", 5);
romanos.put("X", 10);
romanos.put("L", 50);
romanos.put("C", 100);
romanos.put("D", 500);
romanos.put("M", 1000);
print(romanos.values());
print(romanos.keySet());
}
Output:
salida
Code:
http://codemonkeyjunior.blogspot.mx/2015/03/ceylon-interoperabilidad-con-java.html
I've a class file named PlayerClass.as which is in the same directory with my .fla file.
PlayerClass.as starts with:package PlayerClass {
.fla file starts with: import PlayerClass;
My function is: PlayerClass.SimplePlayer(Sound1);
But I'm getting errors 5001 and 5008. How can I fix these errors?
ActionScript Error #5001: The name of package does not reflect the location of this file
ActionScript Error #5008: Means you're trying to use a class but the class is in a subdirectory that should be reflected in the package name. An example:-
c:\PackageTest\com\ayumilove\Game.as
package com.ayumilove
{
import flash.display.MovieClip;
public class Game extends MovieClip
{
public function Game()
{
trace("Game Created");
}
}
}
//An example to instantiate the class
import com.ayumilove.Game;
var game:Game = new Game();
Hope this helps. Just check your directories and make sure they are all spelled correctly.
Exactly what Rachel said.
In your case, the PlayerClass should have a empty package
package {
//... your class definition here
}
I'm trying to include a Facebook app in a section of a Flash website developed in GAIA Framework. I've followed many examples and tutorials and I've tried to do a simple login on the Nav Page.
My imported classes (ALL of the facebook api?):
import com.adobe.serialization.json.JSON;
import com.facebook.graph.Facebook;
import com.facebook.graph.controls.*;
import com.facebook.graph.core.*;
import com.facebook.graph.data.*;
import com.facebook.graph.net.*;
import com.facebook.graph.utils.*;
My var with facebook id:
private var FB_app_id:String = 'my app id goes here :)';
My constructor:
public function NavPage()
{
super();
alpha = 0;
init();
Facebook.init(FB_app_id);
}
So, every time I try to publish, the following error appears:
C:\PROJECT ZERO\1 - Proyectos\2p -
WEB\src\com\facebook\graph\data\FQLMultiQuery.as, Line 80 1061: Call
to a possibly undefined method encode through a reference with static
type Class.
Line 80 of FQLMultiQuery.as refers to the following code:
public function toString():String {
return JSON.encode(queries);
}
What could be wrong? What am I doing wrong? I'm starting to think it might be an incompatibility issue between GAIA and the Facebook API.
It seems like you have a conflict with native JSON (since flash player 11) and the JSON from com.adobe.serialization.json package.
My solution for this is to rename the second one. Or start using the new JSON instead and exclude com.adobe.serialization.* from project.
reference:
http://www.pippoflash.com/index.php/2012/06/20/flash-player-10-and-flash-player-11-json-json-conflict-solved/
I've written a swc lib using flash pro cs6. Among others the swc contains "LPChat" class:
package {
import com.adobe.serialization.json.JSON;
import flash.display.Sprite;
import flash.net.URLRequestHeader;
import flash.utils.setInterval;
public class LPChat extends Sprite {
private var _sessionKey:String;
private var chatEvents:ChatEvents;
private var links:Object;
private var info:Object;
public function LPChat(chatObj:Object) {
.....
}
}
when included in a flash pro projects all works fine, but when included in a flex project I get the following error:
Error #1063: Argument count mismatch on LPChat(). Expected 0, got 1.
which is strange because the constructor does expect 1 and not 0 arguments. I can see the same behavior inside the flash builder IDEA:
any help would be appreciated
It seems that the default package caused the problem. when I moved it to com.lp all issues where solved.