You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Justin Mclean <ju...@classsoftware.com> on 2017/02/22 04:12:08 UTC
[FlexJS] resize event not working?
Hi,
This code doesn’t seem to work - anyone have any ideas why?
I tried with and with out the bead and also tried “this.” instead of “view.”
<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:js="library://ns.apache.org/flexjs/basic" initialize="init()">
<js:beads>
<js:BrowserResizeHandler />
</js:beads>
<fx:Script><![CDATA[
import flash.events.Event;
public function init():void {
view.addEventListener("resize", resized);
}
public function resized(event:flash.events.Event):void {
trace("resized to " + view.x + " " + view.y);
}
]]></fx:Script>
<js:valuesImpl>
<js:SimpleCSSValuesImpl/>
</js:valuesImpl>
<js:initialView>
<js:View id="view" percentWidth="100" percentHeight="100">
<js:Label text="Resize Me" />
</js:View>
</js:initialView>
</js:Application>
BTW this:
public function init():void {
this.addEventListener(flash.events.Event.RESIZE, resized);
}
Also gives this warning when compiling:
WARNING - variable flash is undeclared
this.addEventListener(flash.events.Event.RESIZE, org.apache.flex.utils.Language.closure(this.resized, this, 'resized'));
Thanks,
Justin
Re: [FlexJS] resize event not working?
Posted by Alex Harui <ah...@adobe.com>.
"Resize" seemed to be reserved by the browser. Plus, IMO, events should
have more explicit names. When the width changes, then dispatch
"widthChange" because it may or may not guarantee a "resize" in response.
"sizeChanged" means that someone called an API which set width and height
in the same call.
Of course, this stuff can all be changed if there is a better way.
My 2 cents,
-Alex
On 2/22/17, 5:53 AM, "Peter Ent" <pe...@adobe.com> wrote:
>Alex will need to chime in here, but I believe his philosophy has been to
>keep the number of specialized events to a minimum. I'm not 100% sure I
>agree with that since it can be a lot easier to write code when you are
>responding to specific events, but it does expand the final footprint of
>the app having all the code for those classes.
>
>I think FlexJS will always be a challenge between convenient and
>size/performance.
>
>
>‹peter
>
>On 2/22/17, 3:42 AM, "Harbs" <ha...@gmail.com> wrote:
>
>>I think it¹s to be consistent with widthChanged and heightChanged. There
>>is no ³resize² event anywhere in FlexJS. It¹s probably a good idea to not
>>use the browser names for events.
>>
>>I do believe there should be a ResizeEvent with consts for SIZE_CHANGED,
>>WIDTH_CHANGED and HEIGHT_CHANGED. This does not yet exist.
>>
>>> On Feb 22, 2017, at 9:20 AM, Justin Mclean <ju...@classsoftware.com>
>>>wrote:
>>>
>>> Hi,
>>>
>>>> Looks like you¹re using a flash event instead of the flexjs one.
>>>
>>> Thanks for that I tried that as well, but still doesn¹t work.
>>>
>>> I can see the Resize bead is doing this:
>>> window.addEventListener('resize',
>>>org.apache.flex.utils.Language.closure(this.resizeHandler, this,
>>>'resizeHandler'), false);
>>>
>>> And dispatches a ³sizeChanged² event like so:
>>> initialView.dispatchEvent('sizeChanged¹);
>>>
>>> Any reason for the event name change?
>>>
>>> So this code below will work. But it seems a rather roundabout way of
>>>doing it.
>>>
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
>>> xmlns:js="library://ns.apache.org/flexjs/basic"
>>>initialize="init()">
>>>
>>> <js:beads>
>>> <js:BrowserResizeHandler />
>>> </js:beads>
>>>
>>> <fx:Script><![CDATA[
>>> public function init():void {
>>> initialView.addEventListener("sizeChanged", resized);
>>> }
>>>
>>> public function resized(event:Event):void {
>>> trace("resized to " + initialView.width + " x " +
>>>initialView.height);
>>> }
>>> ]]></fx:Script>
>>> <js:valuesImpl>
>>> <js:SimpleCSSValuesImpl/>
>>> </js:valuesImpl>
>>>
>>> <js:initialView>
>>> <js:View percentWidth="100" percentHeight="100">
>>> <js:Label text="Resize Me" />
>>> </js:View>
>>> </js:initialView>
>>>
>>> </js:Application>
>>>
>>>
>>>
>>>
>>> Thanks,
>>> Justin
>>
>
Re: [FlexJS] resize event not working?
Posted by Peter Ent <pe...@adobe.com>.
Alex will need to chime in here, but I believe his philosophy has been to
keep the number of specialized events to a minimum. I'm not 100% sure I
agree with that since it can be a lot easier to write code when you are
responding to specific events, but it does expand the final footprint of
the app having all the code for those classes.
I think FlexJS will always be a challenge between convenient and
size/performance.
‹peter
On 2/22/17, 3:42 AM, "Harbs" <ha...@gmail.com> wrote:
>I think it¹s to be consistent with widthChanged and heightChanged. There
>is no ³resize² event anywhere in FlexJS. It¹s probably a good idea to not
>use the browser names for events.
>
>I do believe there should be a ResizeEvent with consts for SIZE_CHANGED,
>WIDTH_CHANGED and HEIGHT_CHANGED. This does not yet exist.
>
>> On Feb 22, 2017, at 9:20 AM, Justin Mclean <ju...@classsoftware.com>
>>wrote:
>>
>> Hi,
>>
>>> Looks like you¹re using a flash event instead of the flexjs one.
>>
>> Thanks for that I tried that as well, but still doesn¹t work.
>>
>> I can see the Resize bead is doing this:
>> window.addEventListener('resize',
>>org.apache.flex.utils.Language.closure(this.resizeHandler, this,
>>'resizeHandler'), false);
>>
>> And dispatches a ³sizeChanged² event like so:
>> initialView.dispatchEvent('sizeChanged¹);
>>
>> Any reason for the event name change?
>>
>> So this code below will work. But it seems a rather roundabout way of
>>doing it.
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
>> xmlns:js="library://ns.apache.org/flexjs/basic"
>>initialize="init()">
>>
>> <js:beads>
>> <js:BrowserResizeHandler />
>> </js:beads>
>>
>> <fx:Script><![CDATA[
>> public function init():void {
>> initialView.addEventListener("sizeChanged", resized);
>> }
>>
>> public function resized(event:Event):void {
>> trace("resized to " + initialView.width + " x " +
>>initialView.height);
>> }
>> ]]></fx:Script>
>> <js:valuesImpl>
>> <js:SimpleCSSValuesImpl/>
>> </js:valuesImpl>
>>
>> <js:initialView>
>> <js:View percentWidth="100" percentHeight="100">
>> <js:Label text="Resize Me" />
>> </js:View>
>> </js:initialView>
>>
>> </js:Application>
>>
>>
>>
>>
>> Thanks,
>> Justin
>
Re: [FlexJS] resize event not working?
Posted by Harbs <ha...@gmail.com>.
I think it’s to be consistent with widthChanged and heightChanged. There is no “resize” event anywhere in FlexJS. It’s probably a good idea to not use the browser names for events.
I do believe there should be a ResizeEvent with consts for SIZE_CHANGED, WIDTH_CHANGED and HEIGHT_CHANGED. This does not yet exist.
> On Feb 22, 2017, at 9:20 AM, Justin Mclean <ju...@classsoftware.com> wrote:
>
> Hi,
>
>> Looks like you’re using a flash event instead of the flexjs one.
>
> Thanks for that I tried that as well, but still doesn’t work.
>
> I can see the Resize bead is doing this:
> window.addEventListener('resize', org.apache.flex.utils.Language.closure(this.resizeHandler, this, 'resizeHandler'), false);
>
> And dispatches a “sizeChanged” event like so:
> initialView.dispatchEvent('sizeChanged’);
>
> Any reason for the event name change?
>
> So this code below will work. But it seems a rather roundabout way of doing it.
>
> <?xml version="1.0" encoding="utf-8"?>
> <js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
> xmlns:js="library://ns.apache.org/flexjs/basic" initialize="init()">
>
> <js:beads>
> <js:BrowserResizeHandler />
> </js:beads>
>
> <fx:Script><![CDATA[
> public function init():void {
> initialView.addEventListener("sizeChanged", resized);
> }
>
> public function resized(event:Event):void {
> trace("resized to " + initialView.width + " x " + initialView.height);
> }
> ]]></fx:Script>
> <js:valuesImpl>
> <js:SimpleCSSValuesImpl/>
> </js:valuesImpl>
>
> <js:initialView>
> <js:View percentWidth="100" percentHeight="100">
> <js:Label text="Resize Me" />
> </js:View>
> </js:initialView>
>
> </js:Application>
>
>
>
>
> Thanks,
> Justin
Re: [FlexJS] resize event not working?
Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,
> Looks like you’re using a flash event instead of the flexjs one.
Thanks for that I tried that as well, but still doesn’t work.
I can see the Resize bead is doing this:
window.addEventListener('resize', org.apache.flex.utils.Language.closure(this.resizeHandler, this, 'resizeHandler'), false);
And dispatches a “sizeChanged” event like so:
initialView.dispatchEvent('sizeChanged’);
Any reason for the event name change?
So this code below will work. But it seems a rather roundabout way of doing it.
<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:js="library://ns.apache.org/flexjs/basic" initialize="init()">
<js:beads>
<js:BrowserResizeHandler />
</js:beads>
<fx:Script><![CDATA[
public function init():void {
initialView.addEventListener("sizeChanged", resized);
}
public function resized(event:Event):void {
trace("resized to " + initialView.width + " x " + initialView.height);
}
]]></fx:Script>
<js:valuesImpl>
<js:SimpleCSSValuesImpl/>
</js:valuesImpl>
<js:initialView>
<js:View percentWidth="100" percentHeight="100">
<js:Label text="Resize Me" />
</js:View>
</js:initialView>
</js:Application>
Thanks,
Justin
FW: [FlexJS] resize event not working?
Posted by Yishay Weiss <yi...@hotmail.com>.
From: Yishay Weiss<ma...@hotmail.com>
Sent: Wednesday, February 22, 2017 8:07 AM
To: Justin Mclean<ma...@classsoftware.com>
Subject: RE: [FlexJS] resize event not working?
Looks like you’re using a flash event instead of the flexjs one.
From: Justin Mclean<ma...@classsoftware.com>
Sent: Wednesday, February 22, 2017 6:12 AM
To: dev@flex.apache.org<ma...@flex.apache.org>
Subject: [FlexJS] resize event not working?
Hi,
This code doesn’t seem to work - anyone have any ideas why?
I tried with and with out the bead and also tried “this.” instead of “view.”
<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:js="library://ns.apache.org/flexjs/basic" initialize="init()">
<js:beads>
<js:BrowserResizeHandler />
</js:beads>
<fx:Script><![CDATA[
import flash.events.Event;
public function init():void {
view.addEventListener("resize", resized);
}
public function resized(event:flash.events.Event):void {
trace("resized to " + view.x + " " + view.y);
}
]]></fx:Script>
<js:valuesImpl>
<js:SimpleCSSValuesImpl/>
</js:valuesImpl>
<js:initialView>
<js:View id="view" percentWidth="100" percentHeight="100">
<js:Label text="Resize Me" />
</js:View>
</js:initialView>
</js:Application>
BTW this:
public function init():void {
this.addEventListener(flash.events.Event.RESIZE, resized);
}
Also gives this warning when compiling:
WARNING - variable flash is undeclared
this.addEventListener(flash.events.Event.RESIZE, org.apache.flex.utils.Language.closure(this.resized, this, 'resized'));
Thanks,
Justin