Drawing on screen from a non-sprite object in Actionscript3 - actionscript-3

I'm trying to debug AS3 code on production. I have no access to trace(), can't write to disk or open a socket. What I want is to display something on screen.
With AS2 I could just access _root and create a text field with my trace data.
Any ideas how I can pull this off with AS3? My class extends Object, it is not a sprite and is never added to a parent display object.
Thanks! :)

Why can you not use trace?
You could download the Flex SDK ( http://opensource.adobe.com/wiki/display/flexsdk/Downloads ) and in the "bin/" folder is a program called "fdb" (Flex DeBugger) which is a command line tool for debugging .swfs.
Once downloaded, open up a terminal/cli, navigate to the "bin/" folder, and issue the command fdb http://example.com/index.html (./fdb http://example.com/index.html on a Mac) and the debugger will connect, assuming it's a debug .swf you've uploaded.
Fdb will also allow you insert break-points, watch/print/change variables etc. It's a very handy tool.

Related

how to share a component in as3

I have a custom component(eg. MyButton) used in several swfs. I'd like to share the component in runtime, thus once our designer change the button's visual effect, we need not publish all flas that uses this button.
In as2, I can put this button in an asset fla(eg. lib.swf) and check the "export for runtime share" in symbol property. Then copy the button to a fla(eg. main.swf) and check the "import for runtime share", this works fine. However in as3, after doing above, if I put a button instance on stage and modify its inspectable property, i'll get a compile error "1046:Type was not found or was not a compile-time constant".
I searched the web and found this http://www.kirupa.com/forum/showthread.php?317257-Runtime-Shared-Library-woes. Then I tried the swc approach, but it seems swc will be compiled into swf, it doesn't share at all.
the shared component must be put on the stage, because all fla will be modified by our designer while he knows nothing about programing.
we can not use flex, all operation must be done in Flash CS5.
1: Placed on Library all of your components to .fla as follows: my fla names BrushClip.fla the components wrapped a MovieClip. and be ActionScript Linking export to ActionScript Class.
2: File - Publish Settings check SWC format and publish as follows:
3: check, created swc file in your project. now you can using a swc other project you must linking to SWC library in File-ActionScript Settings-Library Path. and later if you change a components design, re-publish. and copy and paste swc file. automatically will change restart swf file. BrushClip.swc has a all components.
you can access as follows:
var brushClip0:MovieClip = new BrushClip0();
addChild(brushClip0);
var brushClip10:MovieClip = new BrushClip10();
addChild(brushClip10);
I've found the solution.
Give the Sprite that holds the imported components a binding class
Edit the class file, declare the components yourself regardless of whether checked the "auto declare instance on stage"

ZIP Embedding throws error

I want to embed a ZIP-file into my AS3/Air-application (with Flash Builder) and open it via FZip. For embedding, I use this code:
[Embed(source='../bin/art/resources.zip', mimeType="application/octet-stream")]
public static const rsClass:Class;
When I try to save the project the program chrashes and throws an error:
"Workspace is being build" has encountered a problem. During "Workspace is being build" an internal error has occured. (this is just a bad translation, not original) Java heap space
I click OK, the internal error appears:
The error "Disc space too low" has appeared. Look into the Readme-File at "Run Eclipse" you will find information [...] It is recommended to end the workbench. Do you want to end the workbench? yes/no
In an earlier version of this post I said, that the program doesnt start. That is not true. Only saving causes this error. Because of the saving errors, an earlier version of the program is started, but without errors. When I try to make a bytearray out of the zip, it causes an error (initial content not found), but I suppose the zip doesnt load, so this is not unusual.
you should NOT embed this ZIP but load it instead, you can add to the AIR package any files/folders.
To do it:
in Flash IDE go to "AIR for Android Settings" or "AIR for iOS Settings" and at the bottom of the dialogue box you have "Included files:" field then add folder or file you need,
for FlashDevelop what ever will be in bin folder will be packaged in air as described here
In Flex it will be the src folder and in the export wizzard you can select which files to include like described here.
Edit also you should consider for very large files following idea:
don't include big files (or just basic elements) and download big files and save on user device e.g. on sdcard, and then load it from there.
best regards

Can you debug swc in flash builder

Can you debug and step through the code of a swc files in flash builder?
Let's say you even have access to source code (coming from flex library project or flash professional project)! If how?
Thanks
Yes you can, though there are some limitations (as FlashBuilder will tell you when you do it), but simple stepping is no problem.
If you have the source code in a project in FlashBuilder, FB should find the associated code automatically. If you don't you can associate the source code to the swc manually. Go to the Flex Build Path window; click on the arrow next to the swc; double click the row that says "Source attachment" and enter the path to the source code.

flash cs5: compiling fla with huge internal library takes YEARS !

by using flash cs5 with a huge internal image library (over 300+ small png-files) i need more than 90seconds for each compiling action! the as code is pretty well, also my computer (quad core, 4gigs of ram). i've found out, that by exporting the files to "stage 1" (bild 1 in my screenshot) flash starts to hang around, but i don't know why...
.
how to speed this process up ?
__________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________
my solution did not work:
so i've played around and ended up creating *.as-files for each single bitmap, but the speed-result is the same (maybe 10% - 15% faster than before)...
package
{
import flash.display.*;
dynamic public class MY_BITMAP_NAME extends BitmapData
{
public function MY_BITMAP_NAME(width:int = 500, height:int = 135)
{
super(width, height);
return;
}
}
}
i can not work fast enough to debug my project files :-(
The solution would be to move your assets inside a precompiled SWC library that you will only recompile when they change.
Building the library:
create a new FLA and move in your Bitmaps,
each image needs to have a linkage class name and be exported in first frame; you don't have to create an AS class, Flash will generate them,
in the publish settings, "Flash" tab, check "Export SWC",
this SWC library will be published in the same location as the SWF; in CS4-5 you can't prevent the SWF creation.
Using the library
in your main FLA publish settings, "Flash" tab, open the Advanced Actionscript 3 settings dialog,
in the "Library path" tab you can add the assets library SWC; make sure the "Link Type" is "Merged into code",
SWC content will be available in your main FLA as if they were in the library.
It is worth noting that:
you must instantiate these assets by code (ie. new AssetName): they will not appear in your main FLA's Library panel and you can not drop them on the timeline,
only assets you explicitly reference in your code will be available at run time; if you are using getDefinitionByName() you must still import the assets somewhere in your code. For instance you can declare an Array containing all your assets classes (ex: var assets:Array = [AssetClass1, AssetClass2,...]).
if these 300+ images don't change too often, you could create a second .fla, where you only put the images in the library. Then you publish that .fla as a swc file (You can set this in the publish settings).
And you use that swc in your original .fla (that now has no images anymore), where you have your code (using the swc means, in the publish settings -> actionscript settings, you set the swc as a library reference).
This way, Flash only has to compile your code and simply takes the already compiled images from the swc. It then should compile much faster.
ctrl+enter, that will compile all things in library and the AS code.
most situation that use just change little things, and then compile it.
it would waste much time that no need to waste.
you can export some thing that would not always be changed to SWC file, and to to publish setting,
add SWC file into your Fla. or move you Fla project to Flash build, compile use less time more than in flash ide.

Problems transferring Flash project from Mac to Windows

I have a .fla on my Mac that I created in Flash cs5. I saved it as a cs4 file and sent it to a friend who has a Windows machine.
I have a symbol linked to an AS class which has symbols inside of it which have instance names. The constructor of the class refers to these instance names. When I compile, everything works as expected. When my friend compiles, he gets compiler errors telling him that the instances mentioned above are undefined.
I'm at a complete loss. Any ideas why this is happening?
Things we've tried:
Checked to make sure that we had the same source path
Made sure that the symbol in the Flash IDE has the correct linkage
Tried compiling the .fla with cs4 on my machine. It works, which is what makes me think it's a Mac/Windows issue.
Try going to publish settings -> flash -> [settings button next to "as3] - the same place you go to set your classpath. There is a checkbox there that says declare stage instances - it sounds like its unchecked on the cs4 windows version... it should be checked if you don't want to have to write things like :
public var myClip:MovieClip;
for every instance that you've placed using the flash ide.