Select to view content in your preferred language

Importing Customized Widget Failure!  Plz Help!

2833
9
Jump to solution
01-27-2013 11:34 PM
BrentSlone1
Emerging Contributor
Hello All!

So I have created my first widget in Flash Builder 4.7.  I am running Arcgis Viewer for Flex 3.1.  When I attempt to bring my new widget into a viewer it just doesn't work.  However, when I run from within Flash Builder the viewer comes up and widget works without a hitch.  Here are the steps I took.  Please advise me on what Im doing wrong.  I assume that something is happening when creating the swf file. 

Created new widget under the src-->widget folder.   Named folder, xml and mxml "XYWidget".  Added desired coding.  I then went under Properties--> Flex Modules and added XYWidget.mxml to the directory.  Finally I ran the "Export Release Build" to my designated output folder.  I used the default location which is "bin-release" folder.  Once it complied and completed I went to the bin-release folder and zipped up the XYWidget folder that included the swf and xml file.  I opened the flexviewer and imported the customized widget zip file.  It imports successfully.  I then go into the config.xml file for both the flexviewer and flexviewers folders where the web server is running (again this is default locations C:\inetpub\wwwroot\flexviewer and C:\inetpub\wwwroot\flexviewers\xxxxexampleviewer) and I add the widget to the widgetcontainer

<widget url="widgets/XY/XYWidget.swf" config="widgets/XY/XYWidget.xml" label="XY" icon="assets/images/i_nav.png"/> 

I then have tried opening existing project and adding widget in or creating a new one.  Everything goes according to plan and then when I open viewer in browser the widget appears but it will not open.  Ever...

What am I doing wrong?  Thanks in advance for any assistance. 

Sloney
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AnthonyGiles
Honored Contributor
Brent,

I have just taken your code and placed it in my project, added the module then exported the release build. I then added the widget to one of my pre existing projects and it works fine.

Are you sure that your project that your are trying to add it to is built on 3.1?

I have attached the compiled widget to see if it works within your application

Regards

Anthony

View solution in original post

0 Kudos
9 Replies
AnthonyGiles
Honored Contributor
Brent,

Instead of trying to load your widget using application builder try just copying your compiled widget folder (folder XY from the bin-release folder) to your widgets folder on your web server (C:\inetpub\wwwroot\flexviewer\widgets). Do not zip the folder. Add your widget tag to your main config:

<widget url="widgets/XY/XYWidget.swf" config="widgets/XY/XYWidget.xml" label="XY" icon="assets/images/i_nav.png"/>

Then ensure you have closed all your browsers down completley then open your application again.

See if that works

Regards

Anthony
0 Kudos
BrentSlone1
Emerging Contributor
Hey Anthony,

Thanks for responded.  I have tried that as well and no luck.  I have created the widget a few different times from scratch.  Same results.  It works within Flash Builder when I run but nothing from web server when I copy OR import data over.  Anything else that I may be doing wrong?  Here is the .mxml code....  thanks for your help!!!


<?xml version="1.0" encoding="utf-8"?>
<!--
///////////////////////////////////////////////////////////////////////////
// Copyright (c) 2010-2011 Esri. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////
-->
<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/mx"
       xmlns:viewer="com.esri.viewer.*"
       widgetConfigLoaded="init()">
<fx:Script>
  <![CDATA[
   import com.esri.ags.events.MapMouseEvent;
   //this function called when the widget's configuration is loaded
   private function init():void
   {
    if (configXML) // checking for valid content in the configuration file
   {
     lbl.text = configXML.content || getDefaultString("helloContent");
    }
   }
  
   protected function helloWorld_openHandler(event:Event):void
   {
    map.addEventListener(MapMouseEvent.MAP_CLICK, mapClicked);
   }
  
   private function mapClicked (event:MapMouseEvent) : void
   {
    lbl.text = "X: " + event.mapPoint.x + "\nY: " + event.mapPoint.y;
   }
  
   protected function helloworld_closedHandler (event:Event) : void
   {
    map.removeEventListener (MapMouseEvent.MAP_CLICK, mapClicked);
   }
  ]]>
</fx:Script>
<viewer:WidgetTemplate id="helloWorld"
         width="400" height="100" open="helloWorld_openHandler(event)" closed="map.addEventListener(MapMouseEvent.MAP_CLICK, mapClicked);">
  <viewer:layout>
   <s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
  </viewer:layout>
 
  <s:Label id="lbl"
     width="100%"
     fontSize="16"
     fontStyle="italic"
     fontWeight="bold"
     color="#FFD700"/>
</viewer:WidgetTemplate>
</viewer:BaseWidget>

------------------------------

Here is the portion of the config.xml

<widget label="XY" left="390" top="400"
                icon="assets/images/i_nav.png"
                config="widgets/XYWidget/XYWidget.xml"
                url="widgets/XYWidget/XYWidget.swf"/>
0 Kudos
AnthonyGiles
Honored Contributor
Brent,

I have just taken your code and placed it in my project, added the module then exported the release build. I then added the widget to one of my pre existing projects and it works fine.

Are you sure that your project that your are trying to add it to is built on 3.1?

I have attached the compiled widget to see if it works within your application

Regards

Anthony
0 Kudos
BrentSlone1
Emerging Contributor
Anthony,

So this has me curious.  I was able to successfully add the zip file you sent and it works fine.  I changed the "Some text" to what I wanted and it didnt show up.  More importantly though I noticed that your swf is 78kb and mine is 80kb.  I feel like there is an issue with my Flash Builder actually building the swf file.  I am using FB 4.7 (64 Bit).  What version are you using if you dont mind me asking? 

Thanks,

Brent
0 Kudos
AnthonyGiles
Honored Contributor
Brent,

I am still using flash builder 4.0, sdk 4.6 targetting flash player 11.1.0. Under the flex build path I have the framework linkage as 'Merged into code'.

Regards

Anthony
0 Kudos
RhettZufelt
MVP Notable Contributor
Brent,

Often when something works from Flashbuilder, but not from the browser is a localhost/path issue.

Have you set the Output folder URL in the flashbuilder properties to the http://servername/fvapp?  If you run it from Flashbuilder without it set properly, it will either run as http://localhost/ or C:\inetpub\wwwroot\flexviewer\ (which will work through FlashBuilder, but not the browser).

If you see the c:\ path in your browser URL, this is what is causing the issue as the broswer should say http://servername/fvapp regardless of whether lauched from FlashBuilder or directly in browser.

Just a thought,

R_
0 Kudos
BrentSlone1
Emerging Contributor
Brent,

I am still using flash builder 4.0, sdk 4.6 targetting flash player 11.1.0. Under the flex build path I have the framework linkage as 'Merged into code'.

Regards

Anthony


Thanks Anthony, so I altered my framework linkage to "Merged into code" and the browser would not run at all.  When I use the default SDK (runtime shared library), it works fine.  I appreciate all your help! 

Brent
0 Kudos
BrentSlone1
Emerging Contributor
Brent,

Often when something works from Flashbuilder, but not from the browser is a localhost/path issue.

Have you set the Output folder URL in the flashbuilder properties to the http://servername/fvapp?  If you run it from Flashbuilder without it set properly, it will either run as http://localhost/ or C:\inetpub\wwwroot\flexviewer\ (which will work through FlashBuilder, but not the browser).

If you see the c:\ path in your browser URL, this is what is causing the issue as the broswer should say http://servername/fvapp regardless of whether lauched from FlashBuilder or directly in browser.

Just a thought,

R_


Hey Rhett,

So currently I do not have the output folder URL set.  So I have a Flexviewer named NTMA.  Would I point this path directly into this folder; so http://KAB1-AS2.global.amec.com/flexviewers/NTMA ?

Thanks for your response!

Brent
0 Kudos
RhettZufelt
MVP Notable Contributor
Yes, if you have your NTMA project within a flexviewers folder in the server root folder.  Using IIS, I have my FV projects directly in the inetpub/wwwroot/ folder as I don't like the extra "flexviewers" in the path.

I set mine so that the output folder would be

U:\inetpub\wwwroot\NTMA           (I have my server C:\ mapped to the local U:\ drive)

and the Output folder URL would be:

http://KAB1-AS2.global.amec.com/NTMA

Don't know if most output directly to the server folder, but this is what I had to do to get it to behave the same running from the browser vs within flex (I don't have a web server running on my FlashBuilder box).

I actually develop as something like http://KAB1-AS2.global.amec.com/NTMA_tmp, then when done, my release build would be without the _tmp.

R_
0 Kudos