Global AS3 File - FDT - actionscript-3

I'm trying create a global file in AS3 with FTD.
It's a file that is imported by this code
<fx:Script source="../../../framework/util/util.as"/>
and is acessible by all classes in project.
Just like this without package or class.
import flash.events.MouseEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.core.FlexGlobals;
import mx.core.UIComponent;
import mx.formatters.DateFormatter;
import mx.managers.ToolTipManager;
import mx.messaging.Channel;
import mx.messaging.events.ChannelEvent;
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.mxml.RemoteObject;
import mx.utils.ObjectUtil;
import spark.components.TitleWindow;
import spark.events.TitleWindowBoundsEvent;
private var channelSet:ChannelSet = new ChannelSet();
private var customChannel:Channel;
public function showErrorImmediately(target:UIComponent):void
{
// we have to callLater this to avoid other fields that send events
// that reset the timers and prevent the errorTip ever showing up.
target.callLater(showDeferred, [target]);
}
....
In FB this file works fine but when i migrate to FDT a lot of errors occurs.
Can anyone help me?

FDT does not support the source attribute for MXML script tags:
<fx:Script source="../../../framework/util/util.as"/>
Your code in file util.as is valid if you consider it as contents of a script block.
I assume you put the file util.as in some package in your source folder.
In this case FDT assumes it is a normal compilation unit. A normal compilation unit
has to start with a package and so FDT complains about that.
In general it is a bad practice to use the include statement or the source attribute and this is why FDT does not support that.
In your case I would consider defining your own abstract mxml component as base class of all your components containing the method and the fields.

Related

Avoid using web-only libraries outside Flutter web plugin packages

I'm building a Flutter app that I am trying to make work on the web. Part of it contains some web specific code:
import 'dart:html' as html;
import 'package:flutter/foundation.dart';
class DownloadViewModel extends ChangeNotifier {
static const String url = 'https://example.com/api/v1/app/myapp_1.0.0.apk';
void onAndroidDownloadPressed() {
html.window.open(url, 'AndroidApp');
}
}
However the dart:html import gives the following error:
Avoid using web-only libraries outside Flutter web plugin packages
The longer version of the warning looks like this:
Avoid using web libraries, dart:html, dart:js and dart:js_util in
Flutter packages that are not web plugins. These libraries are not
supported outside a web context; functionality that depends on them
will fail at runtime in Flutter mobile, and their use is generally
discouraged in Flutter web.
Web library access is allowed in:
plugin packages that declare web as a supported context
otherwise, imports of dart:html, dart:js and dart:js_util are disallowed.
And it's not just a warning. This actually prevents building an Android or iOS app (even though this method isn't accessible from non-Web Flutter apps).
The only solution I've figured out is to comment out the import when I am building for Android and iOS and then uncomment it when I am building for the web. Is there a better solution?
Use the universal_html package. It supports the browser, Dart VM, and Flutter and is a stand-in replacement for dart:html and other web related libraries.
dependencies:
universal_html: ^1.2.1
Then instead of using import 'dart:html' as html; you can use the following import:
import 'package:universal_html/html.dart' as html;
For those who came to this page for other related web import problems (like dart:js), this plugin also supports the following imports:
import 'package:universal_html/driver.dart';
import 'package:universal_html/html.dart';
import 'package:universal_html/indexed_db.dart';
import 'package:universal_html/js.dart';
import 'package:universal_html/js_util.dart';
import 'package:universal_html/prefer_sdk/html.dart';
import 'package:universal_html/prefer_sdk/indexed_db.dart';
import 'package:universal_html/prefer_sdk/js.dart';
import 'package:universal_html/prefer_sdk/js_util.dart';
import 'package:universal_html/prefer_sdk/svg.dart';
import 'package:universal_html/prefer_sdk/web_gl.dart';
import 'package:universal_html/prefer_universal/html.dart';
import 'package:universal_html/prefer_universal/indexed_db.dart';
import 'package:universal_html/prefer_universal/js.dart';
import 'package:universal_html/prefer_universal/js_util.dart';
import 'package:universal_html/prefer_universal/svg.dart';
import 'package:universal_html/prefer_universal/web_gl.dart';
import 'package:universal_html/svg.dart';
import 'package:universal_html/web_gl.dart';
Since the merge of Flutter-web into the main Flutter repository, it's no longer possible to directly add imports for web libraries (e.g. dart:html, or dart:js) in a Flutter project on the main channel when targeting Web, Android and iOS.
Use the universal html package which provides extensive support for multiple platforms and web libraries.
From the root level of your project, command
flutter pub add universal_html
import 'package:universal_html/html.dart' as html
This package isn't required to run some web files (e.g. dart:js). In my case, I just had to remove the import 'dart:js' import statement.

Trying to select a files location + file name in AS3

I am creating a file testing program in actionscript 3. I have the URL loader to load the file path + name typed in the textbox. However I am looking to upgrade the experience. I am trying to find a way to choose a file location and name from a function like browseforDirectory(). If anyone could help with providing me either a link to documentation on how to do this or if anyone could help me out that would be awesome. For an example of how its set up currently.
public var TestPath:string = this.TestTxt.txt;
..
this.ldr.load(new URLRequest(TestPath));
This is pretty much a simple example of what would be going on. I am just looking for a way to find a file via browsing for it in a file select window and save the complete path of the file. Sorry if I sound repetitive and all help is appreciate. Couldn't find any documentation towards this specific topic.
I have figured out how to do it. Thank you for pointing me to browse Organis. I think explaining the use of browse a little more, or even providing a quick sample, would have proved to create an excellent answer that others who might view this topic would find helpful. Here is what I have used. It is quite crude and I will refine it later.
package {
import flash.events.MouseEvent;
import flash.net.FileReference;
import flash.net.FileFilter;
import flash.utils.ByteArray;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.display.MovieClip;
import flash.filesystem.File;
public class Browse extends MovieClip
{
var File1:File = new File();
public function Browse()
{
//Adds an event listener for the selected file.
File1.addEventListener(Event.SELECT, FileSelected);
//Narrows down the file selection
var swfTypeFilter:FileFilter = new FileFilter("Text Files","*.txt; *.png;*.as");
var allTypeFilter:FileFilter = new FileFilter("All Files (*.*)","*.*");
//Calls the browse function to pop up a file selection window
File1.browse([swfTypeFilter, allTypeFilter]);
}
function FileSelected(event:Event):void
{
trace(File1.nativePath);
}
}
}
Hopefully anyone looking for a way just to get a file path of a file selected can find it here.

How to recompile a decompiled swf?

I decompiled a swf file to customize it.
I used this site http://www.showmycode.com/ which gave me some code:
package {
import mx.core.*;
import mx.events.*;
import flash.geom.*;
//...
public class LoadSchedule extends Player {
//...
How can I recompile this code to turn it back into SWF?
I found out it is action scritp and i can use the eclipse fdt plugin to compile back the code as swf
http://fdt.powerflasher.com/docs/Basic_AS3_Tutorial#Source_Files
this works.
Or this too :http://edutechwiki.unige.ch/en/Adobe_Flex#Installing_the_free_Flex_SDK

Scala NoClassDefFoundError related to Swing

I have a GUI class named Gui.scala and Eclipse does not show any errors directly in the scala file. My Scala version is 2.11 and I have manually added scala-swing-2.10.4.jar to my build path in Eclipse. If I don't do this, Eclipse complains that it does not find the Swing library.
First lines of my source code look like this:
package filmreviews
import scala.swing._
import event._
import javax.imageio.ImageIO
import javax.swing.ImageIcon
import java.io.File
import java.awt.image.BufferedImage
import java.net.URI
import java.net.URL
import java.awt.Desktop
import java.awt.Cursor
import java.awt.Color
import javax.swing.border
import javax.swing.BorderFactory
import javax.swing.UIManager
object Gui extends SimpleSwingApplication {
def top = new MainFrame {
...more code here...
I get the following error:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce$class
Also, there is a long list telling where in code the error happened. Only lines referring to my own code are:
at filmreviews.Gui$$anon$3.<init>(Gui.scala:17)
at filmreviews.Gui$.top(Gui.scala:17)
at filmreviews.Gui$.top(Gui.scala:16)
This is why I think it is related to the creation of the MainFrame object. It can also be related to how I have manually added the Swing library to the build path. However, I don't know what causes the error or how to fix it.
If you're using Scala 2.11, you will need a version of scala-swing built for 2.11. 2.10.4 is binary incompatible with 2.11.
You can find the jar for a 2.11-compatible version on maven central.
Or for those using sbt:
libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "1.0.1"

Slow export in Flash Professional CS6

I have linked an external library to my fla from the advanced publish settings. (It is away3d library)
There is nothing on the stage and nothing on the timeline either, I have just added some code in the Document Class(look below).
Whenever I run the code below without the line: private _view:View3D it exports fast in about a few seconds, but when I keep that line, it exports very slowly, in about 1 minute.
How can I make the export fast while using external libraries.
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.geom.Vector3D;
import away3d.primitives.PlaneGeometry;
import away3d.containers.View3D;
import away3d.entities.Mesh;
import flash.events.Event;
public class Main extends Sprite
{
private var _view:View3D;
//whenever I comment this line out, it exports fast
public function Main()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
}
}
}
EDIT: Here is the image of the way I linked the away3d library to my fla - http://i.imgur.com/HLxZXPi.png?1
When you link source path Flash IDE compiles all classes each time you publish your application, to prevent this link swc file (that contains away3d classes) in the Library path section.