Actionscript to haxe

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

Actionscript to haxe

Jesse Wood
Hello!

Wondering how to replicate this actionscript in haxe?:

myMC['childMC' + n].property = value

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

Re: Actionscript to haxe

Tony Polinelli
There is a formalized Reflection API in haxe called 'Reflect' :

Reflect.field(myMC, 'childMC' + n).property = value



On Tue, Aug 2, 2011 at 9:26 PM, Jesse Wood <jess.nz@gmail.com> wrote:
Hello!

Wondering how to replicate this actionscript in haxe?:

myMC['childMC' + n].property = value

cheers,
J
--
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: Actionscript to haxe

fintan boyle
In reply to this post by Jesse Wood
Hi Jesse,

check out Reflect.setField()
http://haxe.org/api/reflect


Fintan

On Tue, Aug 2, 2011 at 12:26 PM, Jesse Wood <jess.nz@gmail.com> wrote:
Hello!

Wondering how to replicate this actionscript in haxe?:

myMC['childMC' + n].property = value

cheers,
J
--
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: Actionscript to haxe

bubblebenj
In reply to this post by Jesse Wood
maybe
Reflect.setField( myMC'childMC' + n, value );
?

Ben

On Tue, Aug 2, 2011 at 1:26 PM, Jesse Wood <jess.nz@gmail.com> wrote:
Hello!

Wondering how to replicate this actionscript in haxe?:

myMC['childMC' + n].property = value

cheers,
J
--
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: Actionscript to haxe

bubblebenj
Don't follow mine, Tony's is the good one.

On Tue, Aug 2, 2011 at 1:35 PM, benjamin Dubois <[hidden email]> wrote:
maybe
Reflect.setField( myMC'childMC' + n, value );
?

Ben

On Tue, Aug 2, 2011 at 1:26 PM, Jesse Wood <jess.nz@gmail.com> wrote:
Hello!

Wondering how to replicate this actionscript in haxe?:

myMC['childMC' + n].property = value

cheers,
J
--
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: Actionscript to haxe

Jesse Wood
Thanks guys! will try that out. I had a feeling it was the reflect api, just could not connect the dots...

J


On Tuesday, August 2, 2011, benjamin Dubois <[hidden email]> wrote:
> Don't follow mine, Tony's is the good one.
>
> On Tue, Aug 2, 2011 at 1:35 PM, benjamin Dubois <[hidden email]> wrote:
>>
>> maybe
>> Reflect.setField( myMC, 'childMC' + n, value );
>> ?
>> Ben
>>
>> On Tue, Aug 2, 2011 at 1:26 PM, Jesse Wood <jess.nz@gmail.com> wrote:
>>>
>>> Hello!
>>>
>>> Wondering how to replicate this actionscript in haxe?:
>>>
>>> myMC['childMC' + n].property = value
>>>
>>> cheers,
>>> J
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org <http://haxe.org>
>>
>
>
--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Actionscript to haxe

Pimm Hogeling
Except for what Tony said, the real answer would be putting the children in an array and doing:
children[n].property = value;

2011/8/2 Jesse Wood <jess.nz@gmail.com>
Thanks guys! will try that out. I had a feeling it was the reflect api, just could not connect the dots...

J



On Tuesday, August 2, 2011, benjamin Dubois <[hidden email]> wrote:
> Don't follow mine, Tony's is the good one.
>
> On Tue, Aug 2, 2011 at 1:35 PM, benjamin Dubois <[hidden email]> wrote:
>>
>> maybe
>> Reflect.setField( myMC, 'childMC' + n, value );
>> ?
>> Ben
>>
>> On Tue, Aug 2, 2011 at 1:26 PM, Jesse Wood <jess.nz@gmail.com> wrote:
>>>
>>> Hello!
>>>
>>> Wondering how to replicate this actionscript in haxe?:
>>>
>>> myMC['childMC' + n].property = value
>>>
>>> cheers,
>>> J
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org <http://haxe.org>
>>
>
>
--
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: Actionscript to haxe

Jesse Wood
Brilliant!

I am used to doing that with Actionscript. I actually used both approaches:

names[0].text = Reflect.field(obj,'text');

Alternatively, the reflect object could also be an array - text[0]



On Wed, Aug 3, 2011 at 8:34 AM, Pimm Hogeling <[hidden email]> wrote:
Except for what Tony said, the real answer would be putting the children in an array and doing:
children[n].property = value;


2011/8/2 Jesse Wood <jess.nz@gmail.com>
Thanks guys! will try that out. I had a feeling it was the reflect api, just could not connect the dots...

J



On Tuesday, August 2, 2011, benjamin Dubois <[hidden email]> wrote:
> Don't follow mine, Tony's is the good one.
>
> On Tue, Aug 2, 2011 at 1:35 PM, benjamin Dubois <[hidden email]> wrote:
>>
>> maybe
>> Reflect.setField( myMC, 'childMC' + n, value );
>> ?
>> Ben
>>
>> On Tue, Aug 2, 2011 at 1:26 PM, Jesse Wood <jess.nz@gmail.com> wrote:
>>>
>>> Hello!
>>>
>>> Wondering how to replicate this actionscript in haxe?:
>>>
>>> myMC['childMC' + n].property = value
>>>
>>> cheers,
>>> J
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org <http://haxe.org>
>>
>
>
--
haXe - an open source web programming language
http://haxe.org


--
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: Actionscript to haxe

Bruno Garcia
In reply to this post by Jesse Wood
Rather than reflection, you can also use the more typesafe/greppable
myMC.getChildByName("childMC" + n).

Bruno

On 08/02/2011 04:26 AM, Jesse Wood wrote:
> Hello!
>
> Wondering how to replicate this actionscript in haxe?:
>
> myMC['childMC' + n].property = value
>
> cheers,
> J

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

Re: Actionscript to haxe

Jesse Wood
Great, thanks for the help. How do you fire a function in a haxe swf that is loaded into a Flash swf at runtime?

haxe swf => public static function doSomething() {

Flash swf => onComplete => loadedSwf.doSomething()



On Wed, Aug 3, 2011 at 9:43 AM, Bruno Garcia <[hidden email]> wrote:
Rather than reflection, you can also use the more typesafe/greppable myMC.getChildByName("childMC" + n).

Bruno


On 08/02/2011 04:26 AM, Jesse Wood wrote:
Hello!

Wondering how to replicate this actionscript in haxe?:

myMC['childMC' + n].property = value

cheers,
J

--
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: Actionscript to haxe

Baluta Cristian
I have something like this: untyped loader.contentLoaderInfo.content.methodName();
But you can do something cooler, you can load the swf in the same app domain and you just instantiate classes you know are in the second swf.
https://ralcr.googlecode.com/svn/trunk/Network/RCPluginLoader.hx

On Wed, Aug 3, 2011 at 11:41 AM, Jesse Wood <jess.nz@gmail.com> wrote:
Great, thanks for the help. How do you fire a function in a haxe swf that is loaded into a Flash swf at runtime?

haxe swf => public static function doSomething() {

Flash swf => onComplete => loadedSwf.doSomething()



On Wed, Aug 3, 2011 at 9:43 AM, Bruno Garcia <[hidden email]> wrote:
Rather than reflection, you can also use the more typesafe/greppable myMC.getChildByName("childMC" + n).

Bruno


On 08/02/2011 04:26 AM, Jesse Wood wrote:
Hello!

Wondering how to replicate this actionscript in haxe?:

myMC['childMC' + n].property = value

cheers,
J

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


--
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: Actionscript to haxe

Jesse Wood
Thanks, I appreciate that. it may come in handy one day... the format I need help with is as2.

On Wednesday, August 3, 2011, Baluta Cristian <[hidden email]> wrote:
> I have something like this: untyped loader.contentLoaderInfo.content.methodName();
> But you can do something cooler, you can load the swf in the same app domain and you just instantiate classes you know are in the second swf.
> https://ralcr.googlecode.com/svn/trunk/Network/RCPluginLoader.hx
>
> On Wed, Aug 3, 2011 at 11:41 AM, Jesse Wood <jess.nz@gmail.com> wrote:
>>
>> Great, thanks for the help. How do you fire a function in a haxe swf that is loaded into a Flash swf at runtime?
>> haxe swf => public static function doSomething() {
>> Flash swf => onComplete => loadedSwf.doSomething()
>>
>>
>> On Wed, Aug 3, 2011 at 9:43 AM, Bruno Garcia <[hidden email]> wrote:
>>>
>>> Rather than reflection, you can also use the more typesafe/greppable myMC.getChildByName("childMC" + n).
>>>
>>> Bruno
>>>
>>> On 08/02/2011 04:26 AM, Jesse Wood wrote:
>>>>
>>>> Hello!
>>>>
>>>> Wondering how to replicate this actionscript in haxe?:
>>>>
>>>> myMC['childMC' + n].property = value
>>>>
>>>> cheers,
>>>> J
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org <http://haxe.org>
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org <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: Actionscript to haxe

jlm@justinfront.net
In reply to this post by Baluta Cristian
Baluta

Jesse is working with as2 swf ( as posted in forum ), so this does not apply.

On 3 Aug 2011, at 11:32, Baluta Cristian wrote:

u can load the swf in the same app domain and you just instantiate classes you know are in the second swf.


Jesse

I suggested that Jesse use as2 haXe as as2/as3 communication is messy as you can't load as2 into the same application domain, and would have to modify the as2 swf significantly, one trick if you want to start moving your project into modern flash might be to load a haXe as2 swf into a as3 swf with communication setup, and then load the as2 swf into the haXe as2 swf... although it sounds complex it may be the simplest compromise, well unless you just accept as2 all the way both haXe and regular.

Anyway as I suggested but maybe I was not clear, when loading into as2 haXe although you can probably use a loader class of some sort I forget all the details as it varies with player in regular as2, but going back to basics... from flash 6 onwards... basically if you know is when the _width of the loaded movie is not undefined ( null ? ) and not == to 0 then you know the movie has loaded and parameters, and its actionscript has been initialized.  

There maybe better ways but checking _width seems reliable and indicates code in the loaded movie has been initialized, It should be fairly easy to set up a check for _width with a haxe.Timer... I suggest a timer because you have to be-careful with trying to use enterframe as if you attach it to the loading movie, on load it gets destroyed... you can obviously put the code in the as2 swf if you can recompile, or create a movieclip just for the onenterframe... but Timer maybe simpler.

I can look at creating an example if you get stuck but suggest you give it a go first.

Cheers

;j



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

Re: Actionscript to haxe

Jesse Wood
Thanks Justin.

(I have read your replies on the forum. It's easier to read replies on his mailer due to the formatting!).

I have made some progress...  Let me elaborate a little more on what I am trying to accomplish. 
I am fairly adept with as2 and as3 yet HaXe is new to me. I can use MovieClipLoader class to load a swf
and fire a function onLoadComplete (after code on first frame has loaded). Using 2 as2 swfs it is very commonplace to load one into another and access functions/variables etc. So, for instance I can load swf2 into swf1 and call playFunction() on swf2 from swf1 after load is complete, easy. I have never been able to figure out how to do this with HaXe, or mtasc for that matter. But... I can pass in variables. 

eg. I create an asset/library swf with swfmill. Then I compile the library swf with haxe. Inside the class.hx
file I attach the MC from the library to stage and do something like mc.text = 'hello'. This text var gets picked up in the loaded swf fine. I just can't seem to do mc.callFunction(). 

The as2 classes I was referring to I have found another way to do it. I am in the process of porting part of it to haxe, which hasn't actually been too difficult and not as scary as I originally thought. I then compile this with the library swf made by swfmill, which contains the as2 swf. The haxe class attaches the as2 swf to the stage and controls various properties within it.

This newly create haxe swf needs to be loaded into and controlled by an as2  wrapper swf at runtime. The whole project is as2. I have used as3-as2 communication through local connection and external interface/js before but is not needed here.

so eg. once haxe swf is loaded I need to fire some functions in the haxe swf from the wrapper swf - which in turn, controls the original as2 swf that was compile with it. Easy huh... :)

So far it is going well, I am just stuck on calling functions, both from the haxe class to the as2 swf and from the wrapping swf to the haxe swf.

J.
















On Wed, Aug 3, 2011 at 9:24 PM, [hidden email] <[hidden email]> wrote:
Baluta

Jesse is working with as2 swf ( as posted in forum ), so this does not apply.

On 3 Aug 2011, at 11:32, Baluta Cristian wrote:

u can load the swf in the same app domain and you just instantiate classes you know are in the second swf.


Jesse

I suggested that Jesse use as2 haXe as as2/as3 communication is messy as you can't load as2 into the same application domain, and would have to modify the as2 swf significantly, one trick if you want to start moving your project into modern flash might be to load a haXe as2 swf into a as3 swf with communication setup, and then load the as2 swf into the haXe as2 swf... although it sounds complex it may be the simplest compromise, well unless you just accept as2 all the way both haXe and regular.

Anyway as I suggested but maybe I was not clear, when loading into as2 haXe although you can probably use a loader class of some sort I forget all the details as it varies with player in regular as2, but going back to basics... from flash 6 onwards... basically if you know is when the _width of the loaded movie is not undefined ( null ? ) and not == to 0 then you know the movie has loaded and parameters, and its actionscript has been initialized.  

There maybe better ways but checking _width seems reliable and indicates code in the loaded movie has been initialized, It should be fairly easy to set up a check for _width with a haxe.Timer... I suggest a timer because you have to be-careful with trying to use enterframe as if you attach it to the loading movie, on load it gets destroyed... you can obviously put the code in the as2 swf if you can recompile, or create a movieclip just for the onenterframe... but Timer maybe simpler.

I can look at creating an example if you get stuck but suggest you give it a go first.

Cheers

;j



--
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: Actionscript to haxe

jlm@justinfront.net
If you have time to throw together a test system then I am sure I or someone else will have a quick look at a zip, ( prefer if the fla is cs3 flash, although can do cs4 or flex sdk ).

Cheers ;j

On 3 Aug 2011, at 13:58, Jesse Wood wrote:

Thanks Justin.

(I have read your replies on the forum. It's easier to read replies on his mailer due to the formatting!).

I have made some progress...  Let me elaborate a little more on what I am trying to accomplish. 
I am fairly adept with as2 and as3 yet HaXe is new to me. I can use MovieClipLoader class to load a swf
and fire a function onLoadComplete (after code on first frame has loaded). Using 2 as2 swfs it is very commonplace to load one into another and access functions/variables etc. So, for instance I can load swf2 into swf1 and call playFunction() on swf2 from swf1 after load is complete, easy. I have never been able to figure out how to do this with HaXe, or mtasc for that matter. But... I can pass in variables. 

eg. I create an asset/library swf with swfmill. Then I compile the library swf with haxe. Inside the class.hx
file I attach the MC from the library to stage and do something like mc.text = 'hello'. This text var gets picked up in the loaded swf fine. I just can't seem to do mc.callFunction(). 

The as2 classes I was referring to I have found another way to do it. I am in the process of porting part of it to haxe, which hasn't actually been too difficult and not as scary as I originally thought. I then compile this with the library swf made by swfmill, which contains the as2 swf. The haxe class attaches the as2 swf to the stage and controls various properties within it.

This newly create haxe swf needs to be loaded into and controlled by an as2  wrapper swf at runtime. The whole project is as2. I have used as3-as2 communication through local connection and external interface/js before but is not needed here.

so eg. once haxe swf is loaded I need to fire some functions in the haxe swf from the wrapper swf - which in turn, controls the original as2 swf that was compile with it. Easy huh... :)

So far it is going well, I am just stuck on calling functions, both from the haxe class to the as2 swf and from the wrapping swf to the haxe swf.

J.
















On Wed, Aug 3, 2011 at 9:24 PM, [hidden email] <[hidden email]> wrote:
Baluta

Jesse is working with as2 swf ( as posted in forum ), so this does not apply.

On 3 Aug 2011, at 11:32, Baluta Cristian wrote:

u can load the swf in the same app domain and you just instantiate classes you know are in the second swf.


Jesse

I suggested that Jesse use as2 haXe as as2/as3 communication is messy as you can't load as2 into the same application domain, and would have to modify the as2 swf significantly, one trick if you want to start moving your project into modern flash might be to load a haXe as2 swf into a as3 swf with communication setup, and then load the as2 swf into the haXe as2 swf... although it sounds complex it may be the simplest compromise, well unless you just accept as2 all the way both haXe and regular.

Anyway as I suggested but maybe I was not clear, when loading into as2 haXe although you can probably use a loader class of some sort I forget all the details as it varies with player in regular as2, but going back to basics... from flash 6 onwards... basically if you know is when the _width of the loaded movie is not undefined ( null ? ) and not == to 0 then you know the movie has loaded and parameters, and its actionscript has been initialized.  

There maybe better ways but checking _width seems reliable and indicates code in the loaded movie has been initialized, It should be fairly easy to set up a check for _width with a haxe.Timer... I suggest a timer because you have to be-careful with trying to use enterframe as if you attach it to the loading movie, on load it gets destroyed... you can obviously put the code in the as2 swf if you can recompile, or create a movieclip just for the onenterframe... but Timer maybe simpler.

I can look at creating an example if you get stuck but suggest you give it a go first.

Cheers

;j



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

--
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: Actionscript to haxe

Jesse Wood
Sure thing!

I am heading away tonight for a couple of days but will post an example when I get back!

Cheers,
J

On Wed, Aug 3, 2011 at 11:38 PM, [hidden email] <[hidden email]> wrote:
If you have time to throw together a test system then I am sure I or someone else will have a quick look at a zip, ( prefer if the fla is cs3 flash, although can do cs4 or flex sdk ).

Cheers ;j

On 3 Aug 2011, at 13:58, Jesse Wood wrote:

Thanks Justin.

(I have read your replies on the forum. It's easier to read replies on his mailer due to the formatting!).

I have made some progress...  Let me elaborate a little more on what I am trying to accomplish. 
I am fairly adept with as2 and as3 yet HaXe is new to me. I can use MovieClipLoader class to load a swf
and fire a function onLoadComplete (after code on first frame has loaded). Using 2 as2 swfs it is very commonplace to load one into another and access functions/variables etc. So, for instance I can load swf2 into swf1 and call playFunction() on swf2 from swf1 after load is complete, easy. I have never been able to figure out how to do this with HaXe, or mtasc for that matter. But... I can pass in variables. 

eg. I create an asset/library swf with swfmill. Then I compile the library swf with haxe. Inside the class.hx
file I attach the MC from the library to stage and do something like mc.text = 'hello'. This text var gets picked up in the loaded swf fine. I just can't seem to do mc.callFunction(). 

The as2 classes I was referring to I have found another way to do it. I am in the process of porting part of it to haxe, which hasn't actually been too difficult and not as scary as I originally thought. I then compile this with the library swf made by swfmill, which contains the as2 swf. The haxe class attaches the as2 swf to the stage and controls various properties within it.

This newly create haxe swf needs to be loaded into and controlled by an as2  wrapper swf at runtime. The whole project is as2. I have used as3-as2 communication through local connection and external interface/js before but is not needed here.

so eg. once haxe swf is loaded I need to fire some functions in the haxe swf from the wrapper swf - which in turn, controls the original as2 swf that was compile with it. Easy huh... :)

So far it is going well, I am just stuck on calling functions, both from the haxe class to the as2 swf and from the wrapping swf to the haxe swf.

J.
















On Wed, Aug 3, 2011 at 9:24 PM, [hidden email] <[hidden email]> wrote:
Baluta

Jesse is working with as2 swf ( as posted in forum ), so this does not apply.

On 3 Aug 2011, at 11:32, Baluta Cristian wrote:

u can load the swf in the same app domain and you just instantiate classes you know are in the second swf.


Jesse

I suggested that Jesse use as2 haXe as as2/as3 communication is messy as you can't load as2 into the same application domain, and would have to modify the as2 swf significantly, one trick if you want to start moving your project into modern flash might be to load a haXe as2 swf into a as3 swf with communication setup, and then load the as2 swf into the haXe as2 swf... although it sounds complex it may be the simplest compromise, well unless you just accept as2 all the way both haXe and regular.

Anyway as I suggested but maybe I was not clear, when loading into as2 haXe although you can probably use a loader class of some sort I forget all the details as it varies with player in regular as2, but going back to basics... from flash 6 onwards... basically if you know is when the _width of the loaded movie is not undefined ( null ? ) and not == to 0 then you know the movie has loaded and parameters, and its actionscript has been initialized.  

There maybe better ways but checking _width seems reliable and indicates code in the loaded movie has been initialized, It should be fairly easy to set up a check for _width with a haxe.Timer... I suggest a timer because you have to be-careful with trying to use enterframe as if you attach it to the loading movie, on load it gets destroyed... you can obviously put the code in the as2 swf if you can recompile, or create a movieclip just for the onenterframe... but Timer maybe simpler.

I can look at creating an example if you get stuck but suggest you give it a go first.

Cheers

;j



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

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


--
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: Actionscript to haxe

Jesse Wood
Hey,

I have managed to throw put together a test example (cs4) for anyone interested - example.zip (attached) Here are a few notes to help explain the setup: 

1) Check out the deploy => Flash folder first. This contains 2 swfs, both created with Flash IDE. 

- Launch the original.swf and you will see some text.
- Launch the wrapper.swf which will load the original.swf and change the text by executing a function inside original.swf
- source is found in source => flash.

2) Next, deploy => haxe. This contains 2 swfs - 
   1_ haxe.swf (Which is the original.swf compiled again with haxe and Test.hx class)
    2_ The wrapper.swf with a slight path change to target the original.swf inside the haxe.swf

- Launch haxe.swf and you get the same message as original.swf because the haxe class is placing original.swf on the stage.
- Launch wrapper.swf and you will see the text change because it is firing the function inside original.swf to change the text.


OK, so what does this mean:

I can control functions within externally loaded swfs that are created via Flash IDE, but I can't seem to control functions created with haxe. In the haxe example,
the wrapper swf controls the original swf INSIDE the haxe swf. What I want to be able to do is:

A) execute the function inside original.swf from the class compiled in haxe.swf (no need for wrapper.swf)
B) execute a function inside the haxe class from the wrapper.swf.

You can look at soure => haxe => haxe source for the Test.hx class and the various things I have tried, but can't seem to make the magic happen!.

Good luck!!
J.









On Thu, Aug 4, 2011 at 6:40 PM, Jesse Wood <[hidden email]> wrote:
Sure thing!

I am heading away tonight for a couple of days but will post an example when I get back!

Cheers,
J


On Wed, Aug 3, 2011 at 11:38 PM, [hidden email] <[hidden email]> wrote:
If you have time to throw together a test system then I am sure I or someone else will have a quick look at a zip, ( prefer if the fla is cs3 flash, although can do cs4 or flex sdk ).

Cheers ;j

On 3 Aug 2011, at 13:58, Jesse Wood wrote:

Thanks Justin.

(I have read your replies on the forum. It's easier to read replies on his mailer due to the formatting!).

I have made some progress...  Let me elaborate a little more on what I am trying to accomplish. 
I am fairly adept with as2 and as3 yet HaXe is new to me. I can use MovieClipLoader class to load a swf
and fire a function onLoadComplete (after code on first frame has loaded). Using 2 as2 swfs it is very commonplace to load one into another and access functions/variables etc. So, for instance I can load swf2 into swf1 and call playFunction() on swf2 from swf1 after load is complete, easy. I have never been able to figure out how to do this with HaXe, or mtasc for that matter. But... I can pass in variables. 

eg. I create an asset/library swf with swfmill. Then I compile the library swf with haxe. Inside the class.hx
file I attach the MC from the library to stage and do something like mc.text = 'hello'. This text var gets picked up in the loaded swf fine. I just can't seem to do mc.callFunction(). 

The as2 classes I was referring to I have found another way to do it. I am in the process of porting part of it to haxe, which hasn't actually been too difficult and not as scary as I originally thought. I then compile this with the library swf made by swfmill, which contains the as2 swf. The haxe class attaches the as2 swf to the stage and controls various properties within it.

This newly create haxe swf needs to be loaded into and controlled by an as2  wrapper swf at runtime. The whole project is as2. I have used as3-as2 communication through local connection and external interface/js before but is not needed here.

so eg. once haxe swf is loaded I need to fire some functions in the haxe swf from the wrapper swf - which in turn, controls the original as2 swf that was compile with it. Easy huh... :)

So far it is going well, I am just stuck on calling functions, both from the haxe class to the as2 swf and from the wrapping swf to the haxe swf.

J.
















On Wed, Aug 3, 2011 at 9:24 PM, [hidden email] <[hidden email]> wrote:
Baluta

Jesse is working with as2 swf ( as posted in forum ), so this does not apply.

On 3 Aug 2011, at 11:32, Baluta Cristian wrote:

u can load the swf in the same app domain and you just instantiate classes you know are in the second swf.


Jesse

I suggested that Jesse use as2 haXe as as2/as3 communication is messy as you can't load as2 into the same application domain, and would have to modify the as2 swf significantly, one trick if you want to start moving your project into modern flash might be to load a haXe as2 swf into a as3 swf with communication setup, and then load the as2 swf into the haXe as2 swf... although it sounds complex it may be the simplest compromise, well unless you just accept as2 all the way both haXe and regular.

Anyway as I suggested but maybe I was not clear, when loading into as2 haXe although you can probably use a loader class of some sort I forget all the details as it varies with player in regular as2, but going back to basics... from flash 6 onwards... basically if you know is when the _width of the loaded movie is not undefined ( null ? ) and not == to 0 then you know the movie has loaded and parameters, and its actionscript has been initialized.  

There maybe better ways but checking _width seems reliable and indicates code in the loaded movie has been initialized, It should be fairly easy to set up a check for _width with a haxe.Timer... I suggest a timer because you have to be-careful with trying to use enterframe as if you attach it to the loading movie, on load it gets destroyed... you can obviously put the code in the as2 swf if you can recompile, or create a movieclip just for the onenterframe... but Timer maybe simpler.

I can look at creating an example if you get stuck but suggest you give it a go first.

Cheers

;j



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

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


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



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

example.zip (121K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Actionscript to haxe

Jesse Wood
I think I may have just found what i need, will try it out:

http://old.haxe.org/manual/3/interop



On Tuesday, August 9, 2011, Jesse Wood <[hidden email]> wrote:
> Hey,
> I have managed to throw put together a test example (cs4) for anyone interested - example.zip (attached) Here are a few notes to help explain the setup: 
> 1) Check out the deploy => Flash folder first. This contains 2 swfs, both created with Flash IDE. 
> - Launch the original.swf and you will see some text.
> - Launch the wrapper.swf which will load the original.swf and change the text by executing a function inside original.swf
> - source is found in source => flash.
> 2) Next, deploy => haxe. This contains 2 swfs - 
>    1_ haxe.swf (Which is the original.swf compiled again with haxe and Test.hx class)
>     2_ The wrapper.swf with a slight path change to target the original.swf inside the haxe.swf
> - Launch haxe.swf and you get the same message as original.swf because the haxe class is placing original.swf on the stage.
> - Launch wrapper.swf and you will see the text change because it is firing the function inside original.swf to change the text.
>
> OK, so what does this mean:
> I can control functions within externally loaded swfs that are created via Flash IDE, but I can't seem to control functions created with haxe. In the haxe example,
> the wrapper swf controls the original swf INSIDE the haxe swf. What I want to be able to do is:
> A) execute the function inside original.swf from the class compiled in haxe.swf (no need for wrapper.swf)
> B) execute a function inside the haxe class from the wrapper.swf.
> You can look at soure => haxe => haxe source for the Test.hx class and the various things I have tried, but can't seem to make the magic happen!.
> Good luck!!

> J.
>
>
>
>
>
>
>
>
> On Thu, Aug 4, 2011 at 6:40 PM, Jesse Wood <[hidden email]> wrote:
>
> Sure thing!
> I am heading away tonight for a couple of days but will post an example when I get back!
> Cheers,
> J
>
> On Wed, Aug 3, 2011 at 11:38 PM, [hidden email] <[hidden email]> wrote:
>
> If you have time to throw together a test system then I am sure I or someone else will have a quick look at a zip, ( prefer if the fla is cs3 flash, although can do cs4 or flex sdk ).
> Cheers ;j
>
> On 3 Aug 2011, at 13:58, Jesse Wood wrote:
>
> Thanks Justin.
> (I have read your replies on the forum. It's easier to read replies on his mailer due to the formatting!).
> I have made some progress...  Let me elaborate a little more on what I am trying to accomplish. 
> I am fairly adept with as2 and as3 yet HaXe is new to me. I can use MovieClipLoader class to load a swf
> and fire a function onLoadComplete (after code on first frame has loaded). Using 2 as2 swfs it is very commonplace to load one into another and access functions/variables etc. So, for instance I can load swf2 into swf1 and call playFunction() on swf2 from swf1 after load is complete, easy. I have never been able to figure out how to do this with HaXe, or mtasc for that matter. But... I can pass in variables. 
> eg. I create an asset/library swf with swfmill. Then I compile the library swf with haxe. Inside the class.hx
> file I attach the MC from the library to stage and do something like mc.text = 'hello'. This text var gets picked up in the loaded swf fine. I just can't seem to do mc.callFunction(). 
> The as2 classes I was referring to I have found another way to do it. I am in the process of porting part of it to haxe, which hasn't actually been too difficult and not as scary as I originally thought. I then compile this with the library swf made by swfmill, which contains the as2 swf. The haxe class attaches the as2 swf to the stage and controls various properties within it.
> This newly create haxe swf needs to be loaded into and controlled by an as2  wrapper swf at runtime. The whole project is as2. I have used as3-as2 communication through local connection and external interface/js before but is not needed here.
> so eg. once haxe swf is loaded I need to fire some functions in the haxe swf from the wrapper swf - which in turn, controls the original as2 swf that was compile with it. Easy huh... :)
> So far it is going well, I am just stuck on calling functions, both from the haxe class to the as2 swf and from the wrapping swf to the haxe swf.
> J.

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Wed, Aug 3, 2011 at 9:24 PM, [hidden email] <[hidden email]> wrote:
>
> Baluta
> Jesse is working with as2 swf ( as posted in forum ), so this does not apply.
> On 3 Aug 2011, at 11:32, Baluta Cristian wrote:
>
> u can load the swf in the same app domain and you just instantiate classes you know are in the second swf.
>
> <https://ralcr.googlecode.com/svn/trunk/Network/RCPluginLoader.hx>
--
haXe - an open source web programming language
http://haxe.org