View unanswered posts | View active topics



Reply to topic  [ 10 posts ] 
Old project samples & tutorials (FD 2.x, AS2) 
Author Message
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 11548
Location: Paris, France
We will add sample projects and tutorials here.

:idea: Your contributions are welcome - if you send us some stuff we will be happy to host them!


Spanish tutorials:
- FlashDevelop: HolaMundo en 5 sencillos pasos.
- FlashDevelop y AsWing
- FlashDevelop y MM Components
- Desarrollando Aplicaciones con Adobe Apollo, FlashDevelop


1. Sample "FlashDevelop-only" project
Download the project, unzip and open "DemoProject.fdp" in FlashDevelop.

Notes:
- The folders "classes" and "sampleclasspath" have been added to the project's classpath (Project properties: Classpaths, Add Classpath..).

- The main class "classes/DemoClass.as" has been tagged for compilation (right-click on the file: Always Compile..). The other class "sampleclasspath/SampleClass.as" is used in the DemoClass so it will be compiled automatically.

- Assets "FlashDevelop Logo.png" and "kroe0656.ttf" in the "library" folders have been tagged for compilation too (right-click: Add to Library). They have automatically received a default library ID ("library.FlashDevelop Logo.png" and "library.kroe0656.ttf") that you can change in the asset options (right-click on the file: Options..). You can double-click an asset to paste it's ID in the code at cursor position.

Play:
Press F8 to build or F5 to build and play the generated SWF. Looks at the Project properties for output/version configuration.

Trace:
In Project properties, you can set the TraceMode.

- The default mode is "FlashOut" so the trace() calls will appear in the Output panel if you play the SWF in the integrated player.

- If you want that the trace() calls are always displayed in the Output panel, select the "FlashConnect" mode (socket connection).

- If you want that the trace() calls are always displayed in the Results panel, select the "FlashConnectExtended" mode.

- You can also disable traces or define a custom trace function.


Last edited by Philippe on Fri Nov 09, 2007 4:55 pm, edited 5 times in total.



Wed Mar 08, 2006 3:00 pm
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 11548
Location: Paris, France
Post 
2. Sample "FlashDevelop + Macromedia V2 Components" project
Download the project, unzip and open "MMComponentsDemo.fdp" in FlashDevelop.

Legal note: I didn't check the EULA but I guess you have to own the Macromedia Flash IDE to use these components in your projects.

Notes:
- the project is based on the "Standart project" template which creates a "classes" folder (added the classpath) and a "library" folder to organize your assets.

- there is a "Components.fla" file in the library folder. This FLA contains the MM V2 Button and Alert components we need for this demo. The resulting SWF doesn't contain anything on stage, everything is in the library. The SWF's library will be included in your project SWF.

- the main class "classes/Main.as" was also created and tagged for compilation automatically. This class has a "main()" method which is called once your whole SWF is loaded to start your application. Explore this class to see how to attach MM V2 components on stage at runtime.

Detailed steps on using external component in a FlashDevelop project:

1. Drop the components you need on stage and remove them. They will be included in the SWF library.
2. Publish the SWF and in FlashDevelop: right-click on the file and select "Add to Library".
3a. If you are using MM components, make sure you select "Use MX" in the project compiler options.
3b. If you are using a third party SWC, you need to add the component's intrinsic classes to your project classpath.
4. Now you can use the components in your FlashDevelop project

How to attach MM V2 components at runtime?
1. make sure you include the components in the library,
2. use UIObject.createClassObject() method (apparently added to the MovieClip prototype during MM framework initialization):
Quote:
In MM LiveDocs:
componentInstance.createClassObject(className, instanceName, depth, initObject):UIObject

Code:
// sample Button creation
var myButton = parentMc.createClassObject(mx.controls.Button, "myButton", parentMc.getNextHighestDepth(), {
   label:"Hello world!",
   _x:10,
   _y:10,
   _width:150
});


Last edited by Philippe on Fri Oct 20, 2006 11:20 pm, edited 1 time in total.



Sat Apr 01, 2006 10:10 pm
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 11548
Location: Paris, France
Post 
3. Streaming FLV videos (FlashDevelop/SWFMILL only)
Download the project, unzip and open "VideoSample.fdp" in FlashDevelop.

Notes:
- this project shows how to use SWFMILL to create a video object and integrate it in a FlashDevelop project,

- the video object is generated in a "video.swf" library asset which is included in the project,

- a custom class is included (util/VideoDisplay.as) to hide the implementation details (attaching and using the video object),

- in Main.as, a VideoDisplay object is used to play a FLV very easily.


Sat Jun 10, 2006 9:51 pm
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 11548
Location: Paris, France
Post 
4. Webcam video sample (FlashDevelop/SWFMILL only)
Download the project, unzip and open "WebcamSample.fdp" in FlashDevelop.

Notes:
- this project shows how to use SWFMILL to create a video object and integrate it in a FlashDevelop project,

- the video object is generated in a "video.swf" library asset which is included in the project,

- a custom class is included (util/WebcamDisplay.as) to hide the implementation details (attaching and using the video object),

- in Main.as, a WebcamDisplay object is used to attach a webcam video stream very easily.


Mon Jun 12, 2006 7:27 am
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 11548
Location: Paris, France
Post 
5. Code library and Runtime Shared Library (RSL) sample.
Download the project, unzip and open each project in FlashDevelop.

This sample project shows how to use the loader and library templates.

This technique allows to circumvent the difficulty to split a project into several SWFs:
- the classes must be included only in the library SWF,
- you want to attach a symbol from a loaded SWF into a parent SWF (which it is not possible using a simple loadMovie).

FlashDevelop can handle all the details for you:
- Code library: FD will generate intrinsic classes for the main SWF so the classes will only be included in the library SWF,
- RSL: using this technique, the main SWF will be able to attach symbols from the library SWF as if they were part of the main SWF.

This sample is composed of 3 projects:

1. The main project
Your application main SWF.

2. The library project
Created using the Library template:
- has your library code & assets,
- FD will generate intrinsic classes in the "include" directory,
- this "include" directory has to be added to the classpath of the main project.
- the generated SWF has to be added to the main project library (right-click: Add to Library) as a RSL (again right-click: Options.. and check: Load at runtime).

3. The preloader project
Created using the Custom Preloader template:
- it takes care of preloading the main SWF and the library SWFs (automatically),
- the generated SWF has to be added to the main project library (right-click: Add to Library) as the preloader (again right-click: Options.. and check: Add as preloader).

Deployment:
Be very careful when deploying the project online:
- the loader SWF doesn't need to be put online,
- the main SWF and library SWF must be put online with following the same relative path as when building the project:
/index.html
/TutProject.swf
/library/TutLibrary.swf


This is where it can get confusing: /library/ is the path of the library SWF relative to the main project root directory when you built the main SWF.


Sun Mar 18, 2007 9:46 am
Profile WWW
Member

Joined: Sat Jul 05, 2008 4:18 pm
Posts: 1
Location: Austria
Philippe wrote:
3. Streaming FLV videos (FlashDevelop/SWFMILL only)


- in Main.as, a VideoDisplay object is used to play a FLV very easily.


Hi I'm sorry but I have a stupid question.
Where does the flv go?
Do I click on the library and add it as a resource?
Do I have to change any of the code? For example in Main.as

I hope someone can help?

_________________
Did that work?


Sat Jul 05, 2008 4:41 pm
Profile WWW
Member

Joined: Tue Jan 27, 2009 12:36 pm
Posts: 1
Hello there. I'm having lots of trouble getting the sample AS2 MM V2 project to build (and getting MM V2 components to work at all). With FlashDevelop, I get the following error (verbose output below):

classes/Main.as:18: characters 2-14 : type error class not found : mx.controls.Button
Build halted with errors (mtasc).


I also cannot build MM V2 components from scratch in MTASC, but I believe that is because the components source (included in Flex 2 and Flex 3 SDKs) is actually ActionScript 3.0, so MTASC chokes on syntax surrounding packages.

I would appreciate any advice you can give. Thanks much.

---

Running process: C:\Program Files (x86)\Flash\FlashDevelop\Tools\fdbuild\fdbuild.exe "C:\MMComponentsDemo\MMComponentsDemo.fdp" -ipc b1300f93-a7c4-4287-aceb-48dcf085e424 -compiler "C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc" -library "C:\Program Files (x86)\Flash\FlashDevelop\Library"
Building MMComponentsDemo
mtasc "classes\Main.as" -swf "C:\MMComponentsDemo\MMComponentsDemo.swf" -cp "C:\MMComponentsDemo\classes" -cp "C:\Program Files (x86)\Flash\FlashDevelop\Library\AS2\classes" -version 7 -mx -strict -main -v -wimp -trace org.flashdevelop.utils.FlashViewer.trace org/flashdevelop/utils/FlashViewer.as -frame 1 -keep
Classpath : C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/;C:\Program Files (x86)\Flash\FlashDevelop\Library\AS2\classes/;C:\MMComponentsDemo\classes/;C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/;;/
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/StdPresent.as
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/Object.as
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/Boolean.as
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/String.as
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/Number.as
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/Array.as
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/Function.as
Parsed classes/Main.as
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/MovieClip.as
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/ContextMenu.as
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Tools\mtasc/std/TextSnapshot.as
Parsed C:\Program Files (x86)\Flash\FlashDevelop\Library\AS2\classes/org/flashdevelop/utils/FlashViewer.as
Typing Main.Main
classes/Main.as:18: characters 2-14 : type error class not found : mx.controls.Button
Build halted with errors (mtasc).
Done (1)


Tue Jan 27, 2009 12:54 pm
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 11548
Location: Paris, France
DutchboyUS wrote:
I also cannot build MM V2 components from scratch in MTASC, but I believe that is because the components source (included in Flex 2 and Flex 3 SDKs) is actually ActionScript 3.0, so MTASC chokes on syntax surrounding packages.

MM V2 components is for AS2 and their code in included with the Flash IDE, not the Flex SDK.
Anyway you can not build them with MTASC - but only with Flash IDE. The sample projects explains how to do that, but you need the Flash IDE in all cases.

You may want to look for an alternative set of GUI components. And make sure you get the right version: AS2 and AS3 are not compatible.


Tue Jan 27, 2009 5:32 pm
Profile WWW
Member

Joined: Tue Nov 17, 2009 8:14 pm
Posts: 2
That post --> 3. Streaming FLV videos (FlashDevelop/SWFMILL only) was just what I was looking for. I don't have much trouble understanding the logic behind the code I just need to get better at formulating code myself. So far it's been mostly taking bits and pieces from various places putting it together by method of "poke n' hope". Anyhow. Flashdevelop has been awesome so far. Thanks for the tutorials! 8)


Tue Dec 08, 2009 12:30 am
Profile
Member

Joined: Tue Jul 17, 2012 8:22 am
Posts: 1
That post --> 3. Streaming FLV videos (FlashDevelop/SWFMILL only)
was an excellent lesson for me

I would like .. to .. thank ..
by .. writing .. two functions .. into the class .. VideoDisplay

First function is:

Code:
   /**
   * Get time in video
   */
   
   public function pos():Number
    {
      return ns.time;
   }


and the second function is:

Code:
   public function setVolume(vol:Number):Void
   
      audio_sound.setVolume(vol);
   }


Observations:

After the line below ..

Code:
display = parent.attachMovie("VideoDisplay", name, depth, initObj);


I wrote

Code:
   //  attach audio
   display.attachAudio(ns);
   audio_sound = new Sound(display);


and after:

Code:
   //{ PRIVATE MEMBERS


I wrote

Code:
   private var audio_sound:Sound;


before

Code:
   //}


I think like this .. some details .. will be very helpful .. for ,, some one

FAG = FREE ACADEMIC GAMES

I use the fallowing .. preBuildCommand ..

into .. my project .. FAG EXPLORER FLV.fdp

Code:
   <preBuildCommand>"$(ToolsDir)\swfmill\swfmill.exe" simple "library/video.xml" "library/video.swf"</preBuildCommand>


The file .. FAG EXPLORER FLV.fdp .. contains the lines below:

Code:
   <library>
      <asset path="library\video.swf" />
   </library>


Observations:

swfmill.exe .. uses the file .. video.xml .. to create .. the file .. video.swf

into the directory .. library (placed next to the project file)

The code of the file .. video.swf .. is

Code:
   <?xml version="1.0" encoding="utf-8" ?>
   <movie version="7">
   <frame>
      <library>
         <clip id="VideoDisplay">
            <frame>
               <video id="VideoSurface" width="854" height="480"/>
               <place id="VideoSurface" name="video"/>
            </frame>
         </clip>
      </library>
   </frame>
   </movie>


I wrote the .. class util.Instances ..
to create .. an instance .. of VideoDisplay;

Code:
   import util.VideoDisplay;

   class util.Instances
   {
   function Instances() {
   
   //  create .. the instance .. _root.Fdisplay_MC
   
   _root.createEmptyMovieClip ("Fdisplay_MC", _root.getNextHighestDepth());
      
   _root.Fdisplay_MC._alpha = 50;

   //
   var
      
    Fdisplay:VideoDisplay = new VideoDisplay(null, _root.Fdisplay_MC, "Fdisplay", 1);
   
   _root.Fdisplay = Fdisplay;

   _root.Fdisplay._x = 5; _root.Fdisplay._y = 0;
      
   _root.Fdisplay.setVolume(100);
      
   //
   _root.Fdisplay_MC.onPress = function()
   
   {
      if (_root.b_pause) _root.b_pause = 0 else _root.b_pause = 1;
   
      _root.Fdisplay.pause();
   
   }// _root.Fdisplay_MC.onPress = function()
   
   }// function Instances() {

   }// class util.Instances
   

   class util.VideoDisplay
   {
   //{ PUBLIC MEMBERS
   
   /**
   * Create a new video display surface
   */
   
   function VideoDisplay(targetURI:String, parent:MovieClip, name:String, depth:Number, initObj)
   
   {
      display = parent.attachMovie("VideoDisplay", name, depth, initObj);
      
      // create video stream
      
      nc = new NetConnection();
      nc.connect(targetURI);
      
      ns = new NetStream(nc);
      
      // attach the video stream to the video object
      display.video.attachVideo(ns);
      
      // attach audio
      display.attachAudio(ns);
      
      audio_sound = new Sound(display);

   } // VideoDisplay(targetURI:String, parent:MovieClip, name:String, depth:Number, initObj)
   
   /**
   * Video surface dimensions
   */
   function setSize(width:Number, heigth:Number):Void
   {
      display.video._width = width;
      display.video._height = heigth;
   }
   /**
   * Video clip position
   */
   function setLocation(x:Number, y:Number):Void
   {
      display._x = x;
      display._y = y;
   }

   /**
   * Start streaming
   * @param   url   FLV file
   * @param   bufferTime   Buffer size (optional)
   */
   public function play(url:String, bufferTime:Number):Void
   {
      if (bufferTime != undefined) ns.setBufferTime(bufferTime);
      ns.play(url);
   }

   /**
   * Pause streaming
   */
   public function pause():Void
   {
      ns.pause();
   }

   /**
   * Seek position in video
   */
   public function seek(offset:Number):Void
   {
      ns.seek(offset);
   }   
   
   /**
   * Get time in video
   */
   
   public function pos():Number
   
   {
      return ns.time;
   }

   /**
   * Close the video
   */
      
   public function close():Void
   {
      ns.close();
   }
   
   public function setVolume(vol:Number):Void
   {
      audio_sound.setVolume(vol);
   }
   
   //}
   
   //{ PRIVATE MEMBERS
   
   private var display:MovieClip;
   private var nc:NetConnection;
   private var ns:NetStream;
   
   private var audio_sound:Sound;
   
   //}

   } // function VideoDisplay(targetURI:String, parent:MovieClip, name:String, depth:Number, initObj)


Tue Jul 17, 2012 5:52 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.