How to recompile a decompiled swf? - actionscript-3

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

Related

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"

Global AS3 File - FDT

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.

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.

Flash 11.2 sdk definition of base class Sprite was not found

I'm trying to build a simple sample project using FlashDevelop using Flash 11.2. For some reason it wont let me extend Sprite. When I try to compile it just says:
col: 31 Error: The definition of base class Sprite was not found.
All I have in my code is:
public class Game extends Sprite
{
}
Make sure that you have the following setup in your Flex SDK installation correctly:
\frameworks\libs\player\11.2\playerglobal.swc
and that you have a compiler constant called "swf-version=15" set in FD.
If that doesn't solve it, you have an ambiguous path to your libs. May they have spaces or special characters in them.
Did you import the right package? flash.display.Sprite
You put starling-framework as a tag so if you're using Starling it should be:
import starling.display.Sprite;

Flash saves in Windows, not in Linux, FileReference.save()

The code below compiles fine on the Flex 4 SDK on Fedora 15. Mouse-click opens the dialog box, I click okay, and a file is saved, but the file is empty. I run the same SWF file (that was compiled on the Linux machine) on a Windows machine, and the created file contains the expected data.
Then I broke the FileReference declaration out of the function into the class level, hoping to avoid a known bug, but the same problem persists.
Hoping to set up a workaround, I added the debug Flash player to my path and ran the file from Flash without the benefit of the browser, and it works. So now a Flex problem has become a Firefox problem, maybe owing to a shady procedure I used to install the plugin without really understanding what was happening. I am running Firefox 5.0.
In essence my workflow is fixed, but perhaps people who performed the above will not be able to use projects with FileReference.save()? Should I be worried about this edge case?
/*
WriteTheFile.as
Original code by Brian Hodge (brian#hodgedev.com)
Test to see if ActionScript/Flash can write files
*/
package{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.ByteArray;
import flash.net.FileReference;
public class WriteTheFile extends Sprite
{
private var _xml:String;
private var fr:FileReference;
public function WriteTheFile():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
//Calling the save method requires user interaction and Flash Player 10
stage.addEventListener(MouseEvent.MOUSE_DOWN, _onMouseDown);
}
private function _onMouseDown(e:MouseEvent):void
{
fr = new FileReference()
fr.save("<xml><test>data</test></xml>", "filename.txt");
}
}
}
EDIT: was missing a line, fixed above
EDIT: addressed answer in code above, but the same problem exists.
EDIT: This works on the same system when the standalone player is invoked. Therefore this is a browser (FF 5.0) plugin problem.
Try putting the line
var fr:FileReference = new FileReference();
at class level (outside the function). Apparently this is a known bug:
http://www.techper.net/2007/12/30/flash-filereferencebrowse-problems-on-linux/