Return to Cocos2dx Playback Library

SWF event dispatch issue

Questions related to Cocos2dx playback library should be asked here.

SWF event dispatch issue

Postby Gao Kun » December 9th, 2015, 3:01 am

I have converted some swfs with events on timeline to GAF file. Some worked fine but some didn't.

as3 in my swf:

import flash.events.Event;
var event:Event = new Event("hit",true);
dispatchEvent(event);


cocos2dx c++:
_eventDispatcher->addCustomEventListener("hit", CC_CALLBACK_1(TestDWBattleScene::onHitEvent, this));

Then in my cocos2dx project I failed to catch the event in some gaf objects. It seems the event in the gaf objects didn't fire.

I did this by following the examples.I'm sure my swfs are converted correctly with events dispatched. These swfs are similar . I attached the as3 codes in the same way.
User avatar
Gao Kun
 
Posts: 8
Joined: December 7th, 2015, 9:59 pm

Re: SWF event dispatch issue

Postby Dmitry Bushtets » December 9th, 2015, 5:32 am

Hi!
So, you have many gaf objects, and only in several no event is dispatched. Am I correct?
Please check, if these objects are playing. They shouldn't be paused or something else.
P.S. events are dispatched in GAFObject::realizeFrame
P.P.S. What gaf branch do you use?
User avatar
Dmitry Bushtets
 
Posts: 86
Joined: August 11th, 2014, 1:31 am

Re: SWF event dispatch issue

Postby Gao Kun » December 9th, 2015, 6:56 pm

Thank you for your reply.

My GAF branch is 5.5 with cocos2dx v3.4.


I rechecked my swf and found out that this may caused by swf runtime WARNINGs. Issue solved when I removed the duplicated frame labels on timeline in the swf and converted into GAF format.
User avatar
Gao Kun
 
Posts: 8
Joined: December 7th, 2015, 9:59 pm

Re: SWF event dispatch issue

Postby Gao Kun » December 9th, 2015, 10:27 pm

P.S I still cannot fire two or more events with same eventname.
User avatar
Gao Kun
 
Posts: 8
Joined: December 7th, 2015, 9:59 pm

Re: SWF event dispatch issue

Postby vadym.mitin » December 10th, 2015, 2:07 am

Hi,

You can't dispatch more than one event from one frame. If you dispatch two or more events from one frame - GAF Converter skip them. Also you need to initialize Event in the same frame where you dispatch it.

This code needs to be placed in each keyframe where you need to dispatch an event, otherwise GAF Converter may skip it:
import flash.events.Event;
var event:Event = new Event("hit",true);
dispatchEvent(event);


If you still unable to fix the problem please send me a FLA file (attach to post or use Contact Us form https://gafmedia.com/contact Request type: Report issue). I'll modify it and send it back to you.
User avatar
vadym.mitin
 
Posts: 254
Joined: December 4th, 2013, 8:00 am

Re: SWF event dispatch issue

Postby Gao Kun » December 10th, 2015, 6:57 pm

Vadym Mitin wrote:Hi,

You can't dispatch more than one event from one frame. If you dispatch two or more events from one frame - GAF Converter skip them. Also you need to initialize Event in the same frame where you dispatch it.

This code needs to be placed in each keyframe where you need to dispatch an event, otherwise GAF Converter may skip it:
import flash.events.Event;
var event:Event = new Event("hit",true);
dispatchEvent(event);


If you still unable to fix the problem please send me a FLA file (attach to post or use Contact Us form https://gafmedia.com/contact Request type: Report issue). I'll modify it and send it back to you.




Thank you for your reply.
Actually, I had placed the as3 code on each frame I want to dispatch an event.

I didn't work. Code like this on each frame:
import flash.events.Event;
var event:Event = new Event("hit",true);
dispatchEvent(event);

I fixed my issue by changing the Event variable name. For example:

Frame 10:
import flash.events.Event;
var event:Event = new Event("hit",true);
dispatchEvent(event);

Frame 20:
import flash.events.Event;
var event1:Event = new Event("hit",true);
dispatchEvent(event1);
User avatar
Gao Kun
 
Posts: 8
Joined: December 7th, 2015, 9:59 pm

Re: SWF event dispatch issue

Postby vadym.mitin » December 11th, 2015, 2:02 am

Looks like when you are using one name for two different variables in the different frames Flash publish SWF in the other way than GAF Converter expect. We will have a look on this case. Thanks for reporting the issue!
User avatar
vadym.mitin
 
Posts: 254
Joined: December 4th, 2013, 8:00 am

Return to Cocos2dx Playback Library

Who is online

Users browsing this forum: No registered users and 3 guests