Howto translate this flash event listener to HaXe ?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Howto translate this flash event listener to HaXe ?

MarcWeber
Hi,

How to translate this simple application into a .hx file?
I've trouble with this event listener.


package {
  import flash.display.*;
  import flash.net.*;
  import flash.events.*;

  public class Main extends Sprite {
    public function Main (  ) {
      trace("start");
      stage.scaleMode = StageScaleMode.NO_SCALE;
      stage.addEventListener(Event.RESIZE, resizeListener);
    }

    private function resizeListener (e:Event):void {
      trace("The application window changed size!");
      trace("New width:  " + stage.stageWidth);
      trace("New height: " + stage.stageHeight);
    }
  }

}

Marc Weber

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Howto translate this flash event listener to HaXe ?

Viktor Hesselbom
hi Marc,

off the top of my head, something like this should work,

import flash.display.Sprite;
import flash.events.Event;

class Main extends Sprite {

static function main (  ) {
trace("start");
flash.Lib.current.stage.scaleMode = StageScaleMode.NO_SCALE;
flash.Lib.current.stage.addEventListener(Event.RESIZE, resizeListener);
}

static function resizeListener (e:Event) {
trace("The application window changed size!");
trace("New width:  " + flash.Lib.current.stage.stageWidth);
trace("New height: " + flash.Lib.current.stage.stageHeight);
}
}

2010/1/1 Marc Weber <[hidden email]>
Hi,

How to translate this simple application into a .hx file?
I've trouble with this event listener.


package {
 import flash.display.*;
 import flash.net.*;
 import flash.events.*;

 public class Main extends Sprite {
   public function Main (  ) {
     trace("start");
     stage.scaleMode = StageScaleMode.NO_SCALE;
     stage.addEventListener(Event.RESIZE, resizeListener);
   }

   private function resizeListener (e:Event):void {
     trace("The application window changed size!");
     trace("New width:  " + stage.stageWidth);
     trace("New height: " + stage.stageHeight);
   }
 }

}

Marc Weber

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Howto translate this flash event listener to HaXe ?

Lee Sylvester
In reply to this post by MarcWeber
Your main method isn't static, which would mean it won't get called if
you're using it as your entry point. Other than that, it looks okay.
Didn't try it, though ;-)

Lee



Marc Weber wrote:

> Hi,
>
> How to translate this simple application into a .hx file?
> I've trouble with this event listener.
>
>
> package {
>   import flash.display.*;
>   import flash.net.*;
>   import flash.events.*;
>
>   public class Main extends Sprite {
>     public function Main (  ) {
>       trace("start");
>       stage.scaleMode = StageScaleMode.NO_SCALE;
>       stage.addEventListener(Event.RESIZE, resizeListener);
>     }
>
>     private function resizeListener (e:Event):void {
>       trace("The application window changed size!");
>       trace("New width:  " + stage.stageWidth);
>       trace("New height: " + stage.stageHeight);
>     }
>   }
>
> }
>
> Marc Weber
>
>  


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Howto translate this flash event listener to HaXe ?

Tony Polinelli
Once you instantiate your Main (in flash terms 'Document') Class and
add it to the stage, you can access stage normally. You need to make
sure that it is attached to the stage however. (same as any class that
wants to access stage)


package {
 import flash.display.*;
 import flash.net.*;
 import flash.events.*;

 public class Main extends Sprite {
   public static function Main (  ) {
     flash.Lib.stage.addChild(new Main());
   }

   public static function new(  ) {
      addEventListener(flash.events.Event.ADDED_TO_STAGE, added);
   }

   public function added(e) {
     removeEventListener(flash.events.Event.ADDED_TO_STAGE, added);
     stage.scaleMode = StageScaleMode.NO_SCALE;
     stage.addEventListener(Event.RESIZE, resizeListener);
   }

   private function resizeListener (e:Event):void {
     trace("The application window changed size!");
     trace("New width:  " + stage.stageWidth);
     trace("New height: " + stage.stageHeight);
   }
 }

}


On Sat, Jan 2, 2010 at 4:09 AM, Lee McColl Sylvester
<[hidden email]> wrote:

> Your main method isn't static, which would mean it won't get called if
> you're using it as your entry point. Other than that, it looks okay. Didn't
> try it, though ;-)
>
> Lee
>
>
>
> Marc Weber wrote:
>>
>> Hi,
>>
>> How to translate this simple application into a .hx file?
>> I've trouble with this event listener.
>>
>>
>> package {
>>  import flash.display.*;
>>  import flash.net.*;
>>  import flash.events.*;
>>
>>  public class Main extends Sprite {
>>    public function Main (  ) {
>>      trace("start");
>>      stage.scaleMode = StageScaleMode.NO_SCALE;
>>      stage.addEventListener(Event.RESIZE, resizeListener);
>>    }
>>
>>    private function resizeListener (e:Event):void {
>>      trace("The application window changed size!");
>>      trace("New width:  " + stage.stageWidth);
>>      trace("New height: " + stage.stageHeight);
>>    }
>>  }
>>
>> }
>>
>> Marc Weber
>>
>>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>



--
Tony Polinelli
http://touchmypixel.com

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Howto translate this flash event listener to HaXe ?

MarcWeber
Hi,

Thank you all.

You show me that you know much more about HaXe and Flash than I do.

Which source would you read today to learn about Flash and how to use
HaXe with flash fast?

If you help me I'm willing to create a repository containing many
examples.

Maybe I should start translating the examples found in flex-sdk and ask
here on the mailinglist if I encounter more trouble?

How did you learn this all?

Marc Weber

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Howto translate this flash event listener to HaXe ?

Baluta Cristian
- from adobe documentation
- googling for flash specific questions
- learn haxe differences, including asking here.
- and a lot of practice.


On Sat, Jan 2, 2010 at 2:02 PM, Marc Weber <[hidden email]> wrote:
Hi,

Thank you all.

You show me that you know much more about HaXe and Flash than I do.

Which source would you read today to learn about Flash and how to use
HaXe with flash fast?

If you help me I'm willing to create a repository containing many
examples.

Maybe I should start translating the examples found in flex-sdk and ask
here on the mailinglist if I encounter more trouble?

How did you learn this all?

Marc Weber

--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Howto translate this flash event listener to HaXe ?

Martijn Loots
In reply to this post by MarcWeber
On Sat, 2 Jan 2010, Marc Weber wrote:

> Which source would you read today to learn about Flash and how to use
> HaXe with flash fast?
>
To learn about ActionScript 3 & Flash:

   Essential ActionScript 3.0, by Colin Mook, from O'Reilly
     This book has helped me a lot, because it describes Flash & AS3
     from a programmers perspective and from the ground up. It is a
     great reference too.

As a reference on ActionScript, during development:

   http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/index.html?all-index-Symbols.html&index-list.html

And to help with the haXe specifics:

   API documentation: http://haxe.org/api

   This mailinglist

> How did you learn this all?
>
Speaking for myself: just by doing it. Jump of the cliff. The
mailinglist will help you land softly..

Grtz,
--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Howto translate this flash event listener to HaXe ?

tong-2
In reply to this post by MarcWeber
On Sat, 2010-01-02 at 13:02 +0100, Marc Weber wrote:

> Hi,
>
> Thank you all.
>
> You show me that you know much more about HaXe and Flash than I do.
>
> Which source would you read today to learn about Flash and how to use
> HaXe with flash fast?
>
> If you help me I'm willing to create a repository containing many
> examples.
>
> Maybe I should start translating the examples found in flex-sdk and ask
> here on the mailinglist if I encounter more trouble?
>
> How did you learn this all?


get the book:
http://haxe.org/doc/book?lang=en

/t


--
[)   |   5   |<   †   |2   3   3


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Howto translate this flash event listener to HaXe ?

Ron Wheeler
tong wrote:

> On Sat, 2010-01-02 at 13:02 +0100, Marc Weber wrote:
>  
>> Hi,
>>
>> Thank you all.
>>
>> You show me that you know much more about HaXe and Flash than I do.
>>
>> Which source would you read today to learn about Flash and how to use
>> HaXe with flash fast?
>>
>> If you help me I'm willing to create a repository containing many
>> examples.
>>
>> Maybe I should start translating the examples found in flex-sdk and ask
>> here on the mailinglist if I encounter more trouble?
>>
>> How did you learn this all?
>>    
>
>
> get the book:
> http://haxe.org/doc/book?lang=en
>
> /t
>
>  
+ 1 for the book
This will save you hours of screwing about. It is a bit out of date for
the code examples but it will get you started in the right direction.

Read the tutorials at http://haxe.org/doc and code snippets at
http://haxe.org/doc/snip

Ron


--
haXe - an open source web programming language
http://haxe.org