Using Squiggly in Flash CS5 - actionscript-3

This is going to seem quite a lame question - basically we have downloaded a package called Squiggly - http://labs.adobe.com/technologies/squiggly/ - and we are trying to implement it into Flash (using AS3, CS5). And none of us are very good at flash, and have no clue how to do it, the actionscript in the .as is as follows:
package
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import com.adobe.linguistics.spelling.SpellUIForTLF;
public class SquigglyTLFExample extends Sprite
{
public function SquigglyTLFExample()
{
var markup:XML = <TextFlow xmlns='http://ns.adobe.com/textLayout/2008'><p><span>I know </span><span fontStyle='italic'>Enlish</span><span>. Use the context menu to see the suggestions of the missbelled word.</span></p></TextFlow>;
var textFlow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT);
textFlow.flowComposer.addController(new ContainerController(this, 500, 600));
textFlow.flowComposer.updateAllControllers();
textFlow.interactionManager = new EditManager();
SpellUIForTLF.enableSpelling(textFlow, "en_US");
}
}
}
I have a blank swf, and just want to know how to implement it to a text area. Why do people still use flash? :(

Here's how I got it running in a new FLA file in Flash CS 5:
1) In Flash, go into 'Advanced Actionscript 3.0 Settings' and change to the Librarys path tab on the middle of that pane.
2) Add the AdobeSpellingUITLF.swc.
3) When the SWC has been added, select it in the list and click the little 'I'-icon(when you hover it, it should say: 'Set linkage options for a library').
Change the link type to 'Merged into code'.
4) Add the code you posted (SquigglyTLFExample) as your Document class.
5) Remember to copy the 'AdobeSpellingConfig.xml' and the 'dictionaries'-folder to the same folder as the generated SWF-file.
The configuration in Flash should look something like this:

i have built a class based on squiggle a while ago: http://apdevblog.com/actionscript-spell-checking-with-squiggly-as3-only-and-flash-9-compatible/
it's very easy to use and compatible with normal textfields >flash9.
cheers

Related

ActionScript3 DataGrid how to display content on browser

Thanks very much for being the most answered community on the web.
I have this small problem:
I want to read a database using Tomcat Servlets into a ActionScript DataGrid.
Please mind that I want it to be pure ActionScript; no mix with MXML.
I have already done a exercise with MXML and DataGrid but it is not meeting my requirement.
I want to understand how to use ActionScript libraries.
thanks for listening
Here is the code:
package {
import flash.display.*;
import spark.components.DataGrid;
import mx.collections.ArrayList;
public class EmpDBDebug extends Sprite {
public var empDG:DataGrid;
public var DGArray:Array = [
{Album:'Slanted and Enchanted'},
{Album:'Brighten the Corners'}];
public var DGArrayList:ArrayList;
public function EmpDBDebug() {
empDG = new DataGrid();
DGArrayList = new ArrayList(DGArray);
empDG.dataProvider = DGArrayList;
addChild(empDG);
}
}
}
This is a simplified version of what I want to do. I have replace Servlet with Array. All I want to do is display the DataGrid content on browser. I am not able to do that. It is refreshing but everything is blank. Hope I am doing something wrong. I tried everything. I replace Sprite with Stage but still nothing works.
Since I want to do it in pure ActionScript without using MXML, are there any other libraries which I should be using. And again I am mostly using Notepad++ and MonsterDebugger. I do not have access to fl.data.DataProvider libraries. Let us rule it for the time being. I am bit confused with Flash Licensing. Can I do it with Apache Flex?
Can you throw some light.
thanks again
RR23850

Action script adding a background

First of all I've just a couple hours experience with Flash and AS3 therefore, I'm sorry if it is a bit easy question.
What I want do to is a simple space war games to learn basics of AS3 and flash. Altough I dont know much things about layers, I think my game should contain two layers, one for background and the second one is for enemies spaceships and our spaceship.
I added a jpeg format file to library to use it as a background. (as you can see from the link :http://prntscr.com/2pe6zb and http://prntscr.com/2pe733 )
And I create a as3 documentFile which is called Arkaplan.as and content of it is:
package{
import flash .display.*;
public class Arkaplan extends MovieClip{
public function Arkaplan(){
var hero:backGround =new backGround();
addChild(hero);
}
}
}
However, I got an error which says that : "1180: Call to a possibly undefined method BackGround."
Is there anyone to help me to solve what is wrong ?
EDIT
When I changed the code above lilke :
package{
import flash .display.*;
public class Arkaplan extends MovieClip{
public function Arkaplan(){
var myBitmap:Bitmap = new Bitmap(new backGround(500, 500));
var myMovieclip:MovieClip=new MovieClip();
myMovieclip.addChild(myBitmap);
addChild(myMovieclip);
trace("deneme 1-2");
}
}
}
Problem is solved but I dont know why it runs correctly know ? To be able to use Bitmap Do I have to add it as a child to movieClip ?
Any time you use the word 'new' you are creating a new object. The word after new will be the name of a Class that Flash will try to locate. You must either have an external .as file that matches that name or have a library item set to 'export for ActionScript' with a Class name that matches that name.
You can access a library item's properties by right-clicking on it in the library and clicking 'properties'. With the 'advanced' option open, check the 'export for ActionScript' box and enter a Class name that matches the one you want to create.

How To Create a Preloader to a Flash Game

I'm just beginning to get into flash game programming. I know enough to make a functioning project, but not how to make it efficient or do specific tasks, in this case how to add a preloader. I've found several tutorials online, but none that go along with how I've seen is the best method to program. From what I've seen, it is best to program all of my code into one .as file and link this file to the main document. This makes it easy for me to make all of my variables global in scope, which lets me addChild/removeChild in various different functions. The only problem is that I can't find a tutorial on creating a preloader with this method in mind. All tutorials that I've found generally have two frames in the timeline, one with the preloader and one with the content, but I've been told this is not a good way to program. If anyone could help I'd appreciate it a lot. I can paste the source code of one of my learning projects if it would help to provide an answer to my question.
I wouldn't go with the 2 Frame approach. Instead just make your game with your Document Class, like you said you would like to do.
Then when your done, load your compiled game swf into a loader swf.
Here is a simple example on how your loaderSwf should look like:
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
function startLoad()
{
var mLoader:Loader = new Loader();//Or use ProLoader
var mRequest:URLRequest = new URLRequest(“Game.swf”);
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
}
function onCompleteHandler(loadEvent:Event)
{
addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent)
{
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
trace(percent);
}
startLoad();
(needs to be wraped in a package and Class if you are using it as Document Class)

How to create an Alert Dialog in Actionscript 3 without the Flex Framework in a standalone AIR application designed to run on Windows

I've got a project, written in Actionscript 3, built using Flash CS5. In it, there are sections that require a microphone to be plugged in and the programmer who preceded me notified the user of the lack of microphone by throwing an Error. This causes the program to stop running, a behavior which in undesirable.
The question: How to create a popup alert dialog in as pure as possible Actionscript. I've found the Alert class in mx.controls, but I can't find a way to add it to the project. I found the Yahoo AlertManager class, but couldn't get it to work properly and it looks like the framework around it is larger than I need.
This is deployed on touchscreens as a standalone application on a Windows 7 Environment using AIR 2.5, Flash CS5, Actionscript 3.0. I use FlashDevelop as the AS editor.
You'll have to make your own alert box, either by making NativeWindow instance and editing it, or (what I would recommend) making your own custom class that extends NativeWindow.
This is a simple generalized version of one that I made for one of my apps:
package
{
import flash.display.*;
import flash.geom.*;
public class AlertWindow extends NativeWindow
{
public function AlertWindow(owningWindow:NativeWindow, windowTitle:String)
{
var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
initOptions.maximizable = false;
initOptions.minimizable = false;
initOptions.resizable = false;
initOptions.owner = owningWindow;
initOptions.type = NativeWindowType.UTILITY;
super(initOptions);
title = windowTitle;
alwaysInFront = true;
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
bounds = new Rectangle(owner.x + owner.width - (owner.width / 2) - 125, owner.y + owner.height - (owner.height / 2) - 75, 250, 150);
}
}
}
I whipped it up fairly quickly so it might not be as clean or efficient as it could be but it should be a good base to start on. Obviously you can add stuff like messages, buttons, event listeners, and anything else.
If you don't understand all of the code you should check out the NativeWindow and NativeWindowInitOptions documentation.

Why the actionscript 3.0 snippet below failed to import Button and TextInput?

package
{
import fl.controls.Button;
import fl.controls.TextInput;
public class MinRecord extends Sprite
{
private var recordBtn:Button;
private var stopBtn:Button;
private var textInput:TextInput;
...
When I run it reports:
Type was not found or was not a compile-time constant: Button.
Type was not found or was not a compile-time constant: TextInput.
Can someone point out what's wrong here?
Did you add the TextInput and Button components to the library ?
Drag a TextInput component from the
Components panel to the Library
panel.
Drag a Button component from the
Components panel to the Library
panel.
Make sure that there are in your library.
These should be GUI components of Flash CS5.
Edit: I see you have not also set a document class or maybe not properly
The document class is the top level class that associates with your FLA when it is published as a SWF. When you click Test Movie or Publish and instance of this class is produced to the object on the highest level in your swf, allowing properties and methods to be accessed.
You want to deselect all objects on the main stage and click on a blank area. Then you will see the Property window with the Document Properties (width ,framerate etc) . You will be looking for the Document class box and inserting the name of your actionscript file. Say you had all your main code in Main.as you want to insert Main (no .as extenstion)