我是GIS分析師,被轉移到Analyst Programmer職位。對我來說這是一個艱難的過渡,因爲我沒有太多的編程背景,但我被拋棄了。Flex應用程序中的多個titleWindow
我正在處理jsp頁面內的Flex應用程序。基本上它是一個3x2的網格,包含圖像和文本。我想要做的是在這個頁面中有多個titleWindow引用,這樣當一個圖像被點擊時,一個titleWindow被打開。 (如果任何人有更好的主意,特別是如果它與懸停有關,我對此非常開放!)目前,我有一個圖像工作。但是,當我嘗試添加第二個函數時,它會出現錯誤。 「錯誤1021:重複函數定義」以下是調用titleWindow的主頁的完整代碼。下面的代碼是什麼讓錯誤1021
<?xml version="1.0" encoding="utf-8"?>
<![CDATA[
import flash.geom.Point;
import mx.containers.TitleWindow;
import mx.core.IFlexDisplayObject;
import mx.managers.PopUpManager;
import windows.SimplePopupWindow;
private var point1:Point = new Point();
private function showWindow():void {
var login:SimpleTitleWindowExample=SimpleTitleWindowExample(PopUpManager.createPopUp(this, SimpleTitleWindowExample , true));
point1.x=131;
point1.y=119;
point1=roadStatus.localToGlobal(point1);
}
private var point2:Point = new Point();
private function showWindow():void {
var login:SimpleTitleWindowExampleFlood=SimpleTitleWindowExampleFlood(PopUpManager.createPopUp(this, SimpleTitleWindowExampleFlood , true));
point2.x=289;
point2.y=119;
point2=floodplain.localToGlobal(point2);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:BorderContainer x="10" y="0" width="750" height="600" backgroundColor="#BBB082" backgroundAlpha="1.0" cornerRadius="20" borderColor="#E8DBA7">
<s:Panel x="10" y="10" width="728" height="578" cornerRadius="20" chromeColor="#983D3A" borderColor="#F1EFE7" backgroundColor="#BBB082">
<mx:Image x="131" y="119" width="150" height="115" source="file://GIS Map Portal/images/Map Images/SJCRoadStatus2_small.jpg" id="roadStatus" click="showWindow();"/>
<mx:Image x="289" y="119" width="150" height="115" source="file://GIS Map Portal/images/Map Images/SJCRoadStatus_small.jpg" id="floodplain" click="showWindow();"/>
<mx:Image x="447" y="119" width="150" height="115" source="file://GIS Map Portal/images/Map Images/SJCRoadStatus2_small.jpg"/>
<s:Label x="131" y="242" text="SJC Road Status"/>
<s:Label x="289" y="242" text="SJC Floodplain"/>
<s:Label x="447" y="242" text="Assessor's Parcels"/>
<mx:Image x="131" y="262" width="150" height="115" source="file://GIS Map Portal/images/Map Images/SJCRoadStatus_small.jpg"/>
<mx:Image x="289" y="262" width="149" height="115" source="file://GIS Map Portal/images/Map Images/SJCRoadStatus2_small.jpg"/>
<mx:Image x="446" y="262" width="151" height="115" source="file://GIS Map Portal/images/Map Images/SJCRoadStatus_small.jpg"/>
<s:Label x="131" y="385" text="Label"/>
<s:Label x="289" y="385" text="Label"/>
<s:Label x="446" y="385" text="Label"/>
<s:Label x="229" y="24" text="San Juan County Web Maps" fontFamily="Calvin and Hobbes" fontSize="25"/>
</s:Panel>
</s:BorderContainer>
下面是TitleWindow代碼。此代碼迄今爲止工作!
<?xml version="1.0" encoding="utf-8"?>
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.controls.Text;
// A reference to the TextInput control in which to put the result.
public var loginName:Text;
// Event handler for the OK button.
private function returnName():void {
//loginName.text="Name entered: " + userName.text;
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:HBox width="323" height="147" borderColor="#E8DBA7" dropShadowVisible="true">
<mx:Text text="The San Juan County GIS Department maintains aninteractive web map dedicated for researching county roads, but also includes city limits, lakes and rivers, and other geographic data.
" width="319" height="76" textAlign="center" color="#FFFFFF"/>
</mx:HBox>
<mx:HBox>
<mx:Button label="Go" click="navigateToURL(new URLRequest(''), 'quote')"/>
<mx:Button label="Back" click="PopUpManager.removePopUp(this);"/>
</mx:HBox>
問:什麼代碼,我需要上述改變能夠添加多個titleWindow正在(最多6個),或者什麼碼我可以使用懸停來打開「窗口」或工具提示嗎?
如果任何人有任何想法或可以指導我,那將是偉大的。我很感激!
謝謝,我會通過這些鏈接。我更新了原始文章中的代碼以包含所有內容。再次感謝! – Evan 2011-03-30 21:05:58
真棒謝謝!我只是認爲showWindow函數是成立的,所以我甚至沒有嘗試改變它。我有很多要學習的!我發現編碼和基準很相似,在那裏有很多,你需要找到一個並堅持下去。我使用ESRI軟件,因此我不會太惹惹Google地圖。謝謝你讓我直立,我開始瘋了!不確定你是否看過它,但GIS Stack Exchange也是一個很好的地方。 – Evan 2011-03-30 22:18:21
@Evan沒問題,很高興我能幫忙,我會檢查一下Stack Exchange以及謝謝你的提示。這也是一個更清晰的解釋,我正在試圖闡明關於面向對象編程和程序編程http://en.wikipedia.org/wiki/Object-oriented_programming它的好處是這些事情現在正在提出,我是試圖讓我的一個好朋友(他不是一個真正的技術人員)自己做一些彈性工作(主要是爲了他的樂隊網站),所以如果我發佈了一些資源,這將是一件好事。他們在我的網站上我也會在這裏下載鏈接。 – shaunhusain 2011-03-30 23:35:45