Slow export in Flash Professional CS6 - actionscript-3

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.

Related

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

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.

Explicit reference to actionscript class in top level package

If you define a class in actionscript that has the same name as a class in the top level package (e.g. Array) there seems to be no way of explicitly referencing the class in the top level package.
UPDATE: This issue is only appearing in Flash Builder 4.7 with the new ASC 2.0 compiler, using Flash Builder 4.6 with an 'old' Flex SDK it works.
Example:
package
{
import flash.display.Sprite;
import mypackage.Array;
public class AS3Problem extends Sprite
{
public function AS3Problem()
{
var myOwnArray:mypackage.Array = new mypackage.Array();
// The line below will cause a compile error
// 'Ambiguous reference to Array'
var flashArray:Array = new Array();
}
}
}
I know the simple solution to this problem is to not create classes with a name that is the same as an as3 top level package class/function, but I'm intrigued as to how this could be 'fixed' in some way by explicitly referring to this package or some other means.
For those interested, I happened to accidentally import 'Array' from hamcrest-as3 while writing tests which caused a problem like this.
Try removing this line
import mypackage.Array;
so you do not import this custom Array and you always use the fully qualified name, I did not tested it but this should fix it.
EDIT:
I tested this and yes you have to add this import line, it will not work , but I can't reproduce the error, I can use and custom Array and the global Array fine with no issue/error or warrning.
EDIT2:
This also worked for me, can you test this too?
var globalArray:Class=(getDefinitionByName('Array') as Class);
var arr2:*=new globalArray();
arr2.push("test");
trace(arr2);

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/