diff --git a/PopMenu1.as b/PopMenu1.as index da8e1e9b..bcc8cc15 100644 --- a/PopMenu1.as +++ b/PopMenu1.as @@ -35,7 +35,7 @@ package staticStageHeight = applicationStageSize ; } - public static function popUp(title:String='' , type:PopMenuTypes=null , content:PopMenuContent=null,closeOnTime:uint=0,onButtonSelects:Function = null,onClosedByTimer:Function=null,onClose:Function=null) + public static function popUp(title:String='' , type:PopMenuTypes=null , content:PopMenuContent=null,closeOnTime:uint=0,onButtonSelects:Function = null,onClosedByTimer:Function=null,onClose:Function=null):void { //SaffronLogger.log('POP 1 MENU OPENED '+Math.random()); //ME1.popUp2(title, type, content,closeOnTime,onButtonSelects); @@ -89,7 +89,7 @@ package { return ME1.popDispatcher ; } - public static function close() + public static function close():void { if(ME1) { diff --git a/PopMenu2.as b/PopMenu2.as index 56b29deb..b5e4ec43 100644 --- a/PopMenu2.as +++ b/PopMenu2.as @@ -15,7 +15,7 @@ ME2 = this; } - public static function popUp(title:String='' , type:PopMenuTypes=null , content:PopMenuContent=null,closeOnTime:uint=0,onButtonSelects:Function = null) + public static function popUp(title:String='' , type:PopMenuTypes=null , content:PopMenuContent=null,closeOnTime:uint=0,onButtonSelects:Function = null):void { //SaffronLogger.log('POP 2 MENU OPENED '+Math.random()); ME2.popUp2(title, type, content,closeOnTime,onButtonSelects); @@ -25,7 +25,7 @@ { return ME2.popDispatcher ; } - public static function close() + public static function close():void { if(ME2) ME2.close(); diff --git a/README.md b/README.md index bfb50584..34230840 100644 --- a/README.md +++ b/README.md @@ -13,19 +13,21 @@ SaffronCode is a collection of codes & libraries for producing powerful and flex ## You can be an app developer by using Adobe Animate & SaffronCode SDK -• You do not need programming knowledge to be a software developer, you can build a variety of software and brochures without having to write a line of code. You can easily prepare graphical and animated pages in Adobe Animate’s graphic environment for the production of mobile software. -• To use the extensive and diverse libraries in this set, you should only be familiar with Ecma Script 6 or Action Script so you can add calendars, lists, dynamic images and ... to your software. With a higher level of software knowledge, you can easily create a variety of software that connects to a lot of different web services without any hassle of managing Internet access and cache storage. +• You do not need programming knowledge to be a software developer, you can build a variety of software and brochures without having to write a line of code. You can easily prepare graphical and animated pages in Adobe Animate’s graphic environment for the production of mobile software.
+• To use the extensive and diverse libraries in this set, you should only be familiar with Ecma Script 6 or Action Script so you can add calendars, lists, dynamic images and ... to your software. With a higher level of software knowledge, you can easily create a variety of software that connects to a lot of different web services without any hassle of managing Internet access and cache storage.
• Do not worry about managing hardware resources. SaffronCode will optimize your software code to run on mobile devices by using GPU resources. ## How To Start? SaffronCode is adding to the Adobe Animate environment to build mobile applications output. To get ready the environment, follow these steps: -• Install the appropriate version of Adobe Animate -• Download SaffronCode SDK -• ASPack (Collection of key libraries) -• Flex and other general swc libraries (if you need soap web services) -• Download the latest version of the Air SDK -• JDK +• Install the appropriate version of Adobe Animate
+• Download SaffronCode SDK
+• Download our ASPack libraries to. you need these libraries to be able to use all features on SaffronCode.
+• Download ASPack
+• Flex and other general swc libraries (if you need soap web services)
+• Download the latest version of the Air SDK
+• JDK
+• Download the sample project here
## Contact Us diff --git a/SaffronLogger.as b/SaffronLogger.as index 02ece41d..7a326dc1 100644 --- a/SaffronLogger.as +++ b/SaffronLogger.as @@ -120,7 +120,7 @@ package trace("Log file located on "+todayFile.nativePath); todayFileStream = new FileStream(); todayFileStream.openAsync(todayFile,FileMode.WRITE); - todayFileStream.writeShort(-2); + // todayFileStream.writeShort(-2); } } diff --git a/animation/Anim_alpha_shine.as b/animation/Anim_alpha_shine.as index 7d49a6e6..81efa638 100644 --- a/animation/Anim_alpha_shine.as +++ b/animation/Anim_alpha_shine.as @@ -10,9 +10,11 @@ import flash.events.EventDispatcher; public class Anim_alpha_shine extends Sprite{ - var object:Object ; + private var object:Object ; - var I:Number ; + private var I:Number ; + + private var _paused:Boolean = false ; public function Anim_alpha_shine(displayObject:Object) { this.addEventListener(Event.ENTER_FRAME,animate); @@ -37,8 +39,19 @@ public class Anim_alpha_shine extends Sprite{ object.alpha = 1 ; } + public function pauseShine():void + { + _paused = true ; + } + + public function playShine():void + { + _paused = false ; + } + private function animate(e:Event):void { + if(_paused)return; object.alpha = 1-(Math.cos(I)+1)/4 ; I+=0.1; } diff --git a/appManager/animatedPages/Intro.as b/appManager/animatedPages/Intro.as index d90f2f58..9873151e 100644 --- a/appManager/animatedPages/Intro.as +++ b/appManager/animatedPages/Intro.as @@ -2,6 +2,8 @@ package appManager.animatedPages {//appManager.animatedPages.Intro import flash.display.MovieClip; import flash.events.Event; + import stageManager.StageManager; + import contents.alert.Alert; [Event(name="imFinished", type="flash.events.Event")] public class Intro extends MovieClip @@ -13,12 +15,22 @@ package appManager.animatedPages stop(); this.addFrameScript(this.totalFrames-1,introIsOver); + this.addFrameScript(Math.ceil((this.totalFrames/3)*2),controlStage); } - private function introIsOver() + private function introIsOver():void { this.stop(); this.dispatchEvent(new Event(EVENT_FINISHED)); + controlStage(); + } + + private function controlStage():void + { + if(StageManager.isSatUp()) + { + StageManager.controllStageSizes(null,false,true); + } } } } \ No newline at end of file diff --git a/appManager/animatedPages/MainAnim.as b/appManager/animatedPages/MainAnim.as index faca401c..b66dff24 100644 --- a/appManager/animatedPages/MainAnim.as +++ b/appManager/animatedPages/MainAnim.as @@ -39,7 +39,7 @@ package appManager.animatedPages } /**animate the frames*/ - private function anim(e:Event,instantMove:Boolean=false) + private function anim(e:Event,instantMove:Boolean=false):void { if(App.skipAnimations || instantMove) { @@ -67,7 +67,7 @@ package appManager.animatedPages } /**take main animation to home frame*/ - public function goHome() + public function goHome():void { currentPage = frame_home ; eventDispatched = false ; @@ -75,7 +75,7 @@ package appManager.animatedPages /**take main menu animation to internal pages frame , it will dispatch app event after animation gone to currect frame
* if you pass true, it will show the page instantly*/ - public function goInternalPage(instantMove:Boolean=false) + public function goInternalPage(instantMove:Boolean=false):void { currentPage = frame_internal ; eventDispatched = false ; diff --git a/appManager/animatedPages/Shiner.as b/appManager/animatedPages/Shiner.as index 7d49399a..b9e183c4 100644 --- a/appManager/animatedPages/Shiner.as +++ b/appManager/animatedPages/Shiner.as @@ -21,7 +21,7 @@ /**Update shine positions and animation*/ protected function updateShines(event:Event):void { - for(var i = 0 ; i< position had bug, if you set it true, the scroll will lock anyway - scrollerMC = new ScrollMT(currentPage,AppWithContent.contentRect,targetArea,autoSizeDetector,false/*autoSizeDetector*/,currentPageData.scrollEffect,false); + scrollerMC = new ScrollMT(currentPage,Contents.config.pageRectXY0,targetArea,autoSizeDetector,false/*autoSizeDetector*/,currentPageData.scrollEffect,false); } if(myEvent is AppEventContent) diff --git a/appManager/animatedPages/pageManager/PageManager.as b/appManager/animatedPages/pageManager/PageManager.as index 41d8eccb..79eacc58 100644 --- a/appManager/animatedPages/pageManager/PageManager.as +++ b/appManager/animatedPages/pageManager/PageManager.as @@ -49,7 +49,7 @@ package appManager.animatedPages.pageManager } /**change the page event*/ - public function setUp(newEvent:AppEvent) + public function setUp(newEvent:AppEvent):void { toEvent = newEvent ; } diff --git a/appManager/animatedPages/pageManager/TitleManager.as b/appManager/animatedPages/pageManager/TitleManager.as index afb498af..2ee6d46d 100644 --- a/appManager/animatedPages/pageManager/TitleManager.as +++ b/appManager/animatedPages/pageManager/TitleManager.as @@ -49,7 +49,7 @@ } /**change the page event*/ - public function setUp(newEvent:AppEvent,forceToRefresh:Boolean=false) + public function setUp(newEvent:AppEvent,forceToRefresh:Boolean=false):void { if(toEvent!=null) { @@ -113,6 +113,7 @@ /**Set the title both for parags and titletexts*/ public function setTitle(text:String):void { + this.visible = text!=''; if(myTitle!=null) { if(myTitle.text != text) diff --git a/appManager/displayContentElemets/Image.as b/appManager/displayContentElemets/Image.as index 3cc78565..8e901f88 100644 --- a/appManager/displayContentElemets/Image.as +++ b/appManager/displayContentElemets/Image.as @@ -26,7 +26,7 @@ package appManager.displayContentElemets this.dispatchEvent(new ImageEvent(ImageEvent.IMAGE_SELECTED,URL)); } - public function setUp(imageURL:String,loadInThisArea:Boolean = false ,imageW:Number=0,imageH:Number=0,X:Number=0,Y:Number=0,keepRatio:Boolean=true) + public function setUp(imageURL:String,loadInThisArea:Boolean = false ,imageW:Number=0,imageH:Number=0,X:Number=0,Y:Number=0,keepRatio:Boolean=true):void { } } diff --git a/appManager/displayContentElemets/LightImage.as b/appManager/displayContentElemets/LightImage.as index 77824cff..4939fe59 100644 --- a/appManager/displayContentElemets/LightImage.as +++ b/appManager/displayContentElemets/LightImage.as @@ -168,7 +168,7 @@ } /**Second setting up the LightImage class*/ - public function setUp2(doAnimation:Boolean = true) + public function setUp2(doAnimation:Boolean = true):void { animated = doAnimation ; } @@ -229,7 +229,7 @@ /**This class will resize the loaded image to its size to prevent gpu process and also it will crop the image to.
* pass -1 for each dimention to make the original value to use on that side*/ - override public function setUp(imageURL:String, loadInThisArea:Boolean=false, imageW:Number=0, imageH:Number=0, X:Number=0, Y:Number=0,keepRatio:Boolean=true):* + override public function setUp(imageURL:String, loadInThisArea:Boolean=false, imageW:Number=0, imageH:Number=0, X:Number=0, Y:Number=0,keepRatio:Boolean=true):void { //PerformanceTest.traceDelay(1); //SaffronLogger.log("Load this image : "+imageURL); diff --git a/appManager/displayContentElemets/TitleText.as b/appManager/displayContentElemets/TitleText.as index bf037e3b..15d725df 100644 --- a/appManager/displayContentElemets/TitleText.as +++ b/appManager/displayContentElemets/TitleText.as @@ -32,7 +32,7 @@ package appManager.displayContentElemets myText.text = ''; } - public function setUp(title:String,arabicText:Boolean = true,splitIfToLong:Boolean=false,resolution:uint=0,replaceWithBitmap:Boolean=true,dynamicWidth:Boolean=false) + public function setUp(title:String,arabicText:Boolean = true,splitIfToLong:Boolean=false,resolution:uint=0,replaceWithBitmap:Boolean=true,dynamicWidth:Boolean=false):void { this.title = title; this.arabicText = arabicText ; @@ -49,7 +49,7 @@ package appManager.displayContentElemets TextPutter.OnButton(myText,title,arabicText,replaceWithBitmap,true,false,resolution,splitIfToLong,dynamicWidth); } /**setup and split text by any car*/ - public function setUp2(title:String,arabicText:Boolean = true,splitIfToLong:Boolean=false,resolution:uint=0,replaceWithBitmap:Boolean=true,splitRange_p:int=0,car_p:String=',',direction_p:String=TitleText.RIGHT,reverse_p:Boolean=false) + public function setUp2(title:String,arabicText:Boolean = true,splitIfToLong:Boolean=false,resolution:uint=0,replaceWithBitmap:Boolean=true,splitRange_p:int=0,car_p:String=',',direction_p:String=TitleText.RIGHT,reverse_p:Boolean=false):void { if(splitRange_p>0) { diff --git a/appManager/displayContentElemets/VersionTracer.as b/appManager/displayContentElemets/VersionTracer.as index cbee477b..27a10f0a 100644 --- a/appManager/displayContentElemets/VersionTracer.as +++ b/appManager/displayContentElemets/VersionTracer.as @@ -31,7 +31,7 @@ package appManager.displayContentElemets { if(this.stage!=null) { - intervalId = setInterval(updateVersionLabel,2000); + intervalId = setInterval(updateVersionLabel,10000); this.addEventListener(Event.REMOVED_FROM_STAGE,unLoad); } else diff --git a/appManager/displayObjects/SwitchButtonAnimated.as b/appManager/displayObjects/SwitchButtonAnimated.as index 1984c8d0..808100c4 100644 --- a/appManager/displayObjects/SwitchButtonAnimated.as +++ b/appManager/displayObjects/SwitchButtonAnimated.as @@ -11,6 +11,8 @@ { private var _status:Boolean = false ; + private var onChangeFunction:Function ; + public function SwitchButtonAnimated(status:Boolean = false) { _status = status ; @@ -23,6 +25,11 @@ this.addEventListener(Event.REMOVED_FROM_STAGE,unLoad); } + public function onChanged(func:Function):void + { + onChangeFunction = func ; + } + private function unLoad(e:Event):void { this.removeEventListener(MouseEvent.MOUSE_DOWN,switchMe); @@ -35,6 +42,7 @@ _status = !_status ; this.dispatchEvent(new Event(Event.CHANGE)); SaffronLogger.log(_status); + if(onChangeFunction!=null)onChangeFunction(); } public function get status():Boolean @@ -50,6 +58,13 @@ } } + public function setInstantStaut(status:Boolean):void + { + _status = status; + if(status)this.gotoAndStop(this.totalFrames); + else this.gotoAndStop(1); + } + private function anim(event:Event):void { if(_status) diff --git a/appManager/event/PageControllEvent.as b/appManager/event/PageControllEvent.as index c6b3d296..1bb4af59 100644 --- a/appManager/event/PageControllEvent.as +++ b/appManager/event/PageControllEvent.as @@ -23,14 +23,17 @@ package appManager.event public var preventerPage:DisplayObject ; public var let_cashed_requested_page_activate:Boolean = true ; + + public var ignorelastCalledPage:Boolean = false ; /**Feel the getPermition and preventerDisplayObject on PREVENT_PAGE_CHANGING event*/ - public function PageControllEvent(type:String,getPermition:Function=null,preventerDisplayObject:DisplayObject=null,let_requested_page_to_open:Boolean=true) + public function PageControllEvent(type:String,getPermition:Function=null,preventerDisplayObject:DisplayObject=null,let_requested_page_to_open:Boolean=true,ignorelastCalledPage:Boolean=false) { super(type,true); let_cashed_requested_page_activate = let_requested_page_to_open; permitionReceiver = getPermition ; preventerPage = preventerDisplayObject ; + this.ignorelastCalledPage = ignorelastCalledPage ; } } } \ No newline at end of file diff --git a/appManager/mains/App.as b/appManager/mains/App.as index 1e60411e..b26a0089 100644 --- a/appManager/mains/App.as +++ b/appManager/mains/App.as @@ -78,9 +78,9 @@ ME.dispatchEvent(new AppEventContent(link,false,forceToRefreshPage)); } - public static function changePageByLink(pageLink:LinkData):void + public static function changePageByLink(pageLink:LinkData,forceToReload:Boolean=false):void { - ME.dispatchEvent(new AppEventContent(pageLink)); + ME.dispatchEvent(new AppEventContent(pageLink,false,forceToReload)); } //replaced with TitleManager.ME @@ -299,7 +299,7 @@ /**this function will dispatches whenever intro is over*/ - protected function intoIsOver(e=null):void + protected function intoIsOver(e:*=null):void { introMC.removeEventListener(Intro.EVENT_FINISHED,intoIsOver); Obj.remove(introMC); @@ -381,6 +381,10 @@ { ContentSoundManager.changeMainMusic((event as AppEventContent).pageData.musicURL,(event as AppEventContent).pageData.musicVolume); } + else + { + ContentSoundManager.changeVolume((event as AppEventContent).pageData.musicVolume); + } if(mainAnim == null) diff --git a/appManager/mains/AppWithContent.as b/appManager/mains/AppWithContent.as index b87abdf3..d4211407 100644 --- a/appManager/mains/AppWithContent.as +++ b/appManager/mains/AppWithContent.as @@ -61,6 +61,8 @@ import flash.display.DisplayObjectContainer; import com.mteamapp.BlackStageDebugger; import nativeClasses.distriqtApplication.DistriqtApplication; + import flash.net.URLLoader; + import flash.events.IOErrorEvent; public class AppWithContent extends App { @@ -68,6 +70,8 @@ private static var _contentRect:Rectangle = new Rectangle() ; private static var ME:AppWithContent ; + + private static var showTheOptionalUpateWarning:Boolean = true ; /**Preventor variables*/ private var preventorFunction:Function, @@ -87,6 +91,8 @@ /**StageMask is using to cover the bottom of the page, when a keboard moves stage to up */ private var stageMask:Sprite ; + + private var pageLoggerRequest:URLRequest,pageLoggerLoader:URLLoader; /**This is the contentManager rectangle size. it will generate from the content w and h on the home xml tag*/ public static function get contentRect():Rectangle @@ -117,7 +123,7 @@ //Solving Back button on Android 28 DistriqtApplication.solveBackButton(); - stage.addEventListener(MouseEvent.MOUSE_DOWN, function(e):*{ + stage.addEventListener(MouseEvent.MOUSE_DOWN, function(e:*):*{ mouseClickCounter++; }) @@ -197,7 +203,7 @@ NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, URICalled); } - NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE,function(e){ + NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE,function(e:*):void{ SliderManager.hide(true); }) if(!DevicePrefrence.isAndroid() && appDescriptorString.indexOf("NSAllowsArbitraryLoads")==-1) @@ -366,7 +372,7 @@ } prventedPageWasLastPage = false ; - if(preventedEventCash!=null) + if(preventedEventCash!=null && !event.ignorelastCalledPage) { SaffronLogger.log("Prevented page event is released"); managePages(preventedEventCash); @@ -459,6 +465,13 @@ { SaffronLogger.log("History changed"); History.pushHistory((event as AppEventContent).linkData); + + + } + + if(event2!=null) + { + logPageChange(event2.myID); } if((!DevicePrefrence.isItPC) && mouseClickCounter>0) @@ -469,6 +482,26 @@ return duplicatePageController ; } + + /**Save teh page ID to Analytic server */ + private function logPageChange(pageId:String):void + { + //GOODBY Saffron Logger... we will miss you + // if(pageLoggerRequest==null) + // { + // pageLoggerRequest = new URLRequest(Contents.config.version_controll_url); + // pageLoggerRequest.contentType = 'application/json'; + // pageLoggerRequest.method = URLRequestMethod.POST ; + // } + // pageLoggerRequest.data = JSON.stringify({AppId:DevicePrefrence.appID,PageName:pageId,Enter:true}) ; + // if(pageLoggerLoader==null) + // { + // pageLoggerLoader = new URLLoader(); + // pageLoggerLoader.addEventListener(IOErrorEvent.IO_ERROR,function():void{}) + // } + // pageLoggerLoader.load(pageLoggerRequest); + + } /**Contents are load now*/ protected function startApp():void @@ -477,16 +510,28 @@ playIntro(); if(!(skipAnimations || Contents.config.skipAnimations)) { - var versionContrllURL:String = Contents.config.version_controll_url ; - SaffronLogger.log("Version controll : "+versionContrllURL); - var versionRequest:URLRequest = new URLRequest(versionContrllURL); - versionRequest.contentType = 'application/json'; - versionRequest.method = URLRequestMethod.POST ; - versionRequest.data = JSON.stringify({AppId:DevicePrefrence.appID}) ; - - VersionController.controllVersion(currentVersionIsOk,stopThisVersion,versionRequest,DevicePrefrence.appVersion,true); + controlCurrentVersion(); } } + + public static function checkVersion():void + { + showTheOptionalUpateWarning = true ; + ME.controlCurrentVersion(true); + } + + private function controlCurrentVersion(useOfflineVersion:Boolean=false):void + { + //GOODBY Saffron analytics, we will miss you + // var versionContrllURL:String = Contents.config.version_controll_url ; + // SaffronLogger.log("Version controll : "+versionContrllURL); + // var versionRequest:URLRequest = new URLRequest(versionContrllURL); + // versionRequest.contentType = 'application/json'; + // versionRequest.method = URLRequestMethod.POST ; + // versionRequest.data = JSON.stringify({AppId:DevicePrefrence.appID}) ; + + // VersionController.controllVersion(currentVersionIsOk,stopThisVersion,versionRequest,DevicePrefrence.appVersion,true,useOfflineVersion); + } /**The application version is ok*/ private function currentVersionIsOk():void @@ -508,29 +553,28 @@ } /**The application is expired*/ - private function stopThisVersion(theHint:String,appURL:String):void + private function stopThisVersion(theHint:String,appURL:String,forceToUpdate:Boolean=true):void { - if(isExpired(theHint,appURL)) + if(forceToUpdate) { + Alert.show(theHint.replace("ID","ID ("+DevicePrefrence.appID+")")); SaffronLogger.log("Switch to the download url instantly"); resetIntro(); stage.removeEventListener(MouseEvent.CLICK,openDownloadLink); stage.addEventListener(MouseEvent.CLICK,openDownloadLink); setTimeout(openDownloadLink,3000); } + else if(showTheOptionalUpateWarning) + { + Alert.show(theHint.replace("ID","ID ("+DevicePrefrence.appID+")")); + showTheOptionalUpateWarning = false ; + setTimeout(openDownloadLink,3000); + } } private function openDownloadLink(event:MouseEvent=null):void { navigateToURL(new URLRequest(VersionController.appStoreURL)); } - - - /**Returns true if there is no listener on this function, so the application have to redirect to the server*/ - protected function isExpired(hint:String,link:String):Boolean - { - Alert.show(hint.replace("ID","ID ("+DevicePrefrence.appID+")")); - return true ; - } } } \ No newline at end of file diff --git a/contents/Config.as b/contents/Config.as index f5922e5b..b822c17a 100644 --- a/contents/Config.as +++ b/contents/Config.as @@ -116,7 +116,7 @@ var loadedXMLString:String = TextFile.load(File.applicationDirectory.resolvePath(configURLFile)); var xml:XML = XML(loadedXMLString); - for(var i = 0 ; i * if your application is supporting multilanguages, you have to use language.xml standart near the content.xml file. and also * you have to set application stage here for the Language class to help it to find added elements to stage.*/ - public static function setUp(OnLoaded:Function=null,supportsMultiLanguage:Boolean=false,autoConvertFontsAndContentTextsByLanguage:Boolean=true,stage:Stage=null,loadConfigFile:Boolean=false) + public static function setUp(OnLoaded:Function=null,supportsMultiLanguage:Boolean=false,autoConvertFontsAndContentTextsByLanguage:Boolean=true,stage:Stage=null,loadConfigFile:Boolean=false):void { onLoaded = OnLoaded ; @@ -121,7 +118,7 @@ } /**This function will controll the langEnabled, so be sure that you are calling it after langEnabled set*/ - private static function loadLang() + private static function loadLang():void { if(langEnabled) { @@ -135,7 +132,7 @@ } /**Load the xml file now*/ - private static function loadXML() + private static function loadXML():void { //SaffronLogger.log("1. debug time : "+getTimer()); /*var fileLoader:FileStream = new FileStream(); @@ -148,7 +145,7 @@ } /**xml file loaded*/ - private static function xmlLoaded(e:Event,myInstantData:String='') + private static function xmlLoaded(e:Event,myInstantData:String=''):void { if(myInstantData!='') { @@ -163,7 +160,7 @@ //Dynamic pages will lost in this mode pages = new Vector.(); - for(var i = 0 ; i(); - for(var i = 0 ; i*/ public function export():XML { - var xml = XML(''); + var xml:XML = XML(''); xml.@id = id; xml.music = musicURL ; @@ -256,7 +256,7 @@ package contents //var link1Node:XML = XML(''); //xml.links = new XML(); - for(var i = 0 ; i=0 ; i--) + for(var i:* = l-1 ; i>=0 ; i--) { if(asyncQue[i].id == id) { diff --git a/diagrams/calender/CalenderConstants.as b/diagrams/calender/CalenderConstants.as index 1a09b983..0d3e3da9 100644 --- a/diagrams/calender/CalenderConstants.as +++ b/diagrams/calender/CalenderConstants.as @@ -32,6 +32,11 @@ package diagrams.calender public static var dayNames:Array = [d0,d1,d2,d3,d4,d5,d6]; + + public static function getDayNameFarsi(date:Date):String + { + return dayNames[(date.day+1)%7]; + } public static var dayNames2:Vector. = new Vector.(); dayNames2.push(dd0,dd1,dd2,dd3,dd4,dd5,dd6); diff --git a/diagrams/calender/MyShamsi.as b/diagrams/calender/MyShamsi.as index 07d70737..e462c970 100644 --- a/diagrams/calender/MyShamsi.as +++ b/diagrams/calender/MyShamsi.as @@ -220,7 +220,7 @@ return mounthName; } - public function toString(e = null):String + public function toString(e:* = null):String { return fullYear + '/' + (month + 1) + '/' + date + ' ' + hours + ':' + minutes + ':' + seconds; } diff --git a/drawPad/Paper.as b/drawPad/Paper.as index 5bd84d42..1041336d 100644 --- a/drawPad/Paper.as +++ b/drawPad/Paper.as @@ -130,7 +130,7 @@ this.addEventListener(Event.REMOVED_FROM_STAGE,unLoad); } - private function unLoad(event:Event) + private function unLoad(event:Event):void { this.removeEventListener(Event.ENTER_FRAME,drawLines); this.removeEventListener(Event.REMOVED_FROM_STAGE,unLoad); @@ -163,11 +163,11 @@ } - private function drawLines(ev:Event=null) + private function drawLines(ev:Event=null):void { if(draw) { - for(var i = 0 ; i, + markerItemsList:Vector. = new Vector.(), myIcons:Vector.; private var mapCretedOnStage:Boolean; @@ -96,12 +81,13 @@ public static function setUp(GoogleAPIKey:String=null,DistriqtId:String=null):void { //SaffronLogger.log('*********GoogleAPIKey*******'+GoogleAPIKey); - + if(isSupports==true)return; try { - AuthorisationStatusClass = getDefinitionByName("com.distriqt.extension.nativemaps.AuthorisationStatus") as Class ; - NativeMapsClass = NativeMaps;//getDefinitionByName("com.distriqt.extension.nativemaps.NativeMaps") as Class ; + AuthorisationStatusClass = getDefinitionByName("com.distriqt.extension.application.AuthorisationStatus") as Class ; + NativeMapsClass = getDefinitionByName("com.distriqt.extension.nativemaps.NativeMaps") as Class ; NativeMapEventClass = getDefinitionByName("com.distriqt.extension.nativemaps.events.NativeMapEvent") as Class ; + NativeMapBitmapEventClass = getDefinitionByName("com.distriqt.extension.nativemaps.events.NativeMapBitmapEvent") as Class ; CustomMarkerIconClass = getDefinitionByName("com.distriqt.extension.nativemaps.objects.CustomMarkerIcon") as Class ; LatLngClass = getDefinitionByName("com.distriqt.extension.nativemaps.objects.LatLng") as Class ; MapMarkerClass = getDefinitionByName("com.distriqt.extension.nativemaps.objects.MapMarker") as Class ; @@ -173,6 +159,7 @@ { counter++; super(); + setUp(); dispatcher.dispatchEvent(new Event(Event.REMOVED_FROM_STAGE)); unload(); @@ -185,6 +172,23 @@ this.addEventListener(Event.REMOVED_FROM_STAGE,unload); dispatcher.addEventListener(Event.REMOVED_FROM_STAGE,removeMeBecauseSomeOneElseComes); } + + override public function set visible(value:Boolean):void + { + super.visible = value ; + + try + { + if(value) + (NativeMapsClass as Object).service.showMap(); + else + (NativeMapsClass as Object).service.hideMap(); + } + catch(e:Error) + { + trace(e.message); + } + } protected function removeMeBecauseSomeOneElseComes(event:Event):void { @@ -198,6 +202,8 @@ public function setMap(centerLat:Number=NaN,centerLon:Number=NaN,icons:Vector.=null,zoomLevel:Number=-1,mapStyleJSON:String=null,showUserLocation:Boolean=false):void { + if(!isSupports) + return; map_style = mapStyleJSON ; user_location = showUserLocation ; //unload(); @@ -240,37 +246,59 @@ firstZoomLevel = zoomLevel<0?defaultZoomLevel:zoomLevel ; SaffronLogger.log("...listenning..."); (NativeMapsClass as Object).service.addEventListener( (NativeMapEventClass as Object).MAP_CREATED, mapCreatedHandler ); - (NativeMapsClass as Object).service.addEventListener( NativeMapBitmapEvent.READY , updateCapturedBitmap); + (NativeMapsClass as Object).service.addEventListener( (NativeMapBitmapEventClass as Object).READY , updateCapturedBitmap); + (NativeMapsClass as Object).service.addEventListener((NativeMapEventClass as Object).MARKER_TOUCHED,getTouchedItem); SaffronLogger.log("---Creating..."); - NativeMaps.service.createMap( rect, (MapTypeClass as Object).MAP_TYPE_NORMAL,new LatLng(centerLat,centerLon),firstZoomLevel); - + (NativeMapsClass as Object).service.createMap( rect, (MapTypeClass as Object).MAP_TYPE_NORMAL,new LatLngClass(centerLat,centerLon),firstZoomLevel); + if(!super.visible) + (NativeMapsClass as Object).service.hideMap(); SaffronLogger.log("Create map done"); mapCreated = true ; mapIsShowing = true ; } + else + { + SaffronLogger.log("Google map is not support"); + } this.addEventListener(Event.ENTER_FRAME,repose,false,10000); } - private var centerMarker:MapMarker, - centerMarkerPosition:LatLng, + public function isCreated():Boolean + { + return mapCreated ; + } + + private function getTouchedItem(e:*):void + { + for(var i:int = 0 ; i(); } private function mapCreatedHandler(e:*):void @@ -323,7 +354,7 @@ setMapStyle(); - NativeMaps.service.showUserLocation(user_location); + (NativeMapsClass as Object).service.showUserLocation(user_location); updateMarkers(); updateCenterMarker(); @@ -336,24 +367,26 @@ /*forceToHideMap = true ; repose(null); (NativeMapsClass as Object).service.addEventListener( (NativeMapEvent).MAP_RENDER_COMPLETE, showMapAgain );*/ - var styleOption:MapStyleOptions = new MapStyleOptions(map_style); - NativeMaps.service.setMapStyle(styleOption); + var styleOption:* = new MapStyleOptionsClass(map_style); + (NativeMapsClass as Object).service.setMapStyle(styleOption); } } private function showMapAgain(e:*):void { - (NativeMapsClass as Object).service.removeEventListener( (NativeMapEvent).MAP_RENDER_COMPLETE, showMapAgain ); + (NativeMapsClass as Object).service.removeEventListener( (NativeMapEventClass).MAP_RENDER_COMPLETE, showMapAgain ); forceToHideMap = false ; } public function setCenter(lat:Number,lon:Number,zoomLevel:Number=-1,animationDuration:uint=2000):void { + setUp(); + if(isSupports==false)return; SaffronLogger.log("******* first center is : "+lat,lon,zoomLevel); center = new LatLngClass(lat,lon); firstZoomLevel = zoomLevel<=0?defaultZoomLevel:zoomLevel ; - NativeMaps.service.setCentre(center as LatLng,firstZoomLevel,animationDuration!=0,animationDuration) + (NativeMapsClass as Object).service.setCentre(center/* as LatLng*/,firstZoomLevel,animationDuration!=0,animationDuration) } private function createViewPort():Rectangle @@ -399,8 +432,8 @@ //SaffronLogger.log("Old rect : " +rect); //SaffronLogger.log("scl : "+scl); - SaffronLogger.log("deltaX : "+deltaX); - SaffronLogger.log("deltaY : "+deltaY); + //SaffronLogger.log("deltaX : "+deltaX); + //SaffronLogger.log("deltaY : "+deltaY); rect.x*=scl; rect.y*=scl; @@ -462,7 +495,7 @@ if(forceToHideMap ==false && rect!=null && Obj.isAccesibleByMouse(this)) { //SaffronLogger.log("Show map!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - if(!mapIsShowing) + if(!mapIsShowing && super.visible) { //SaffronLogger.log("!!!!!!!!!!!!!!!!!show!!!!!!!!!!!!"); (NativeMapsClass as Object).service.showMap(); @@ -477,7 +510,7 @@ { //SaffronLogger.log("!!!!!!!!!!!!!!!hide!!!!!!!!!!!!!!!"); (NativeMapsClass as Object).service.hideMap(); - NativeMaps.service.requestMapBitmapData(); + (NativeMapsClass as Object).service.requestMapBitmapData(); mapIsShowing = false ; catchedBitmap.visible = true ; } @@ -485,7 +518,7 @@ if(centerMarker!=null) { - var cent:LatLng = NativeMaps.service.getCentre() ; + var cent:* = (NativeMapsClass as Object).service.getCentre() ; if(centerMarkerPosition==null) { centerMarkerPosition = cent ; @@ -495,20 +528,30 @@ centerMarkerPosition.lat = centerMarkerPosition.lat+(cent.lat-centerMarkerPosition.lat)/2; centerMarkerPosition.lon = centerMarkerPosition.lon+(cent.lon-centerMarkerPosition.lon)/2; centerMarker.setPosition(centerMarkerPosition); - NativeMaps.service.updateMarker(centerMarker); + (NativeMapsClass as Object).service.updateMarker(centerMarker); } } public function centerPosition():Point { - var cent:LatLng = NativeMaps.service.getCentre() ; - if(cent!=null) - return new Point(cent.lat,cent.lon); + setUp() + try{ + var cent:* = (NativeMapsClass as Object).service.getCentre() ; + if(cent!=null) + return new Point(cent.lat,cent.lon); + } + catch(e:Error){}; return new Point(0,0); } - public function addMarker(markerName:String,lat:Number,lon:Number,markerTitle:String,markerInfo:String,color:uint=0,enableInfoWindow:Boolean=true,animated:Boolean=true,showInfoButton:Boolean=true,iconId:String=''):void + /**Be carefull to user a unique name as marekrName */ + public function addMarker(markerName:String,lat:Number,lon:Number,markerTitle:String,markerInfo:String,color:uint=0,enableInfoWindow:Boolean=true,animated:Boolean=true,showInfoButton:Boolean=true,iconId:String=''):MarkerItem { + setUp(); + var markerItem:MarkerItem = new MarkerItem(markerName); + markerItemsList.push(markerItem); + if(!isSupports) + return markerItem; //Alert.show("****************Map marker Added : ",lat,lon,markerName,'iconId : '+iconId); var myMarker:Object = new MapMarkerClass(markerName,new LatLngClass(lat,lon),markerTitle,markerInfo,color,false,enableInfoWindow,animated,showInfoButton,iconId) myMarkers.push(myMarker); @@ -516,6 +559,7 @@ { updateMarkers(); } + return markerItem ; } public function style(style:String):void @@ -526,18 +570,18 @@ public function zoomLevel():Number { - return NativeMaps.service.getZoom(); + return (NativeMapsClass as Object).service.getZoom(); } private function updateMarkers():void { //(NativeMapsClass as Object).service.clearMap(); - var i:int ; + var i:int, j:int ; var isDuplicated:Boolean = false ; for(i = 0 ; i(); for(i = 0 ; i(); + if(super.visible==false)(NativeMapsClass as Object).service.hideMap(); } } } \ No newline at end of file diff --git a/nativeClasses/map/MarkerItem.as b/nativeClasses/map/MarkerItem.as new file mode 100644 index 00000000..97a3bfab --- /dev/null +++ b/nativeClasses/map/MarkerItem.as @@ -0,0 +1,33 @@ +package nativeClasses.map +{ + public class MarkerItem + { + internal var id:int; + + + public var name:String ; + + private var _onClick:Function ; + + public function MarkerItem(markerName:String) + { + name = markerName ; + } + + public function dispatchClicked():void + { + if(_onClick!=null) + { + if(_onClick.length==0) + _onClick(); + else + _onClick(this); + } + } + + public function onClick(event:Function):void + { + _onClick = event ; + } + } +} \ No newline at end of file diff --git a/nativeClasses/player/BandwidthTester.as b/nativeClasses/player/BandwidthTester.as index 750ae7d6..4bb5d08b 100644 --- a/nativeClasses/player/BandwidthTester.as +++ b/nativeClasses/player/BandwidthTester.as @@ -6,21 +6,21 @@ public class BandwidthTester extends EventDispatcher { - public static const BAND_TESTED = 'tested'; - public static const TEST = 'test'; + public static const BAND_TESTED:String = 'tested'; + public static const TEST:String = 'test'; - private var bandwidth = 0; //final average bandwidth - private var peak_bandwidth = 0; //peak bandwidth - private var curr_bandwidth = 0; //current take bandwidth + private var bandwidth:* = 0; //final average bandwidth + private var peak_bandwidth:* = 0; //peak bandwidth + private var curr_bandwidth:* = 0; //current take bandwidth - private var testfile = ''; - private var l; //loader - private var tm; //timer - private var last_bytes = 0; //bytes loaded last time - private var bands; //recorded byte speeds - private var _latency = 1; //network utilization approximation + private var testfile:* = ''; + private var l:*; //loader + private var tm:*; //timer + private var last_bytes:* = 0; //bytes loaded last time + private var bands:*; //recorded byte speeds + private var _latency:* = 1; //network utilization approximation - public function BandwidthTester(latency = 0,URL_Path:String="") + public function BandwidthTester(latency:* = 0,URL_Path:String="") { tm = new Timer(1000, 3); testfile = URL_Path; @@ -30,7 +30,7 @@ _latency = 1 - latency; } - public function start() + public function start():void { l = new URLLoader(); l.addEventListener(Event.OPEN, start_timer); @@ -38,7 +38,7 @@ l.load(new URLRequest(testfile)); } - private function get_band(e:TimerEvent) + private function get_band(e:TimerEvent):void { curr_bandwidth = Math.floor(((l.bytesLoaded - last_bytes) / 125) * _latency); bands.push(curr_bandwidth); @@ -47,12 +47,12 @@ dispatchEvent(new Event(BandwidthTester.TEST)); } - public function start_timer(e:Event) + public function start_timer(e:Event):void { tm.start(); } - private function timer_complete(e:TimerEvent) + private function timer_complete(e:TimerEvent):void { l.close(); bands.sort(Array.NUMERIC | Array.DESCENDING); @@ -63,7 +63,7 @@ dispatchEvent(new Event(BandwidthTester.BAND_TESTED)); } - private function end_download(e) + private function end_download(e:*):void { tm.removeEventListener(TimerEvent.TIMER, get_band); tm.removeEventListener(TimerEvent.TIMER_COMPLETE, timer_complete); @@ -76,10 +76,10 @@ dispatchEvent(new Event(BandwidthTester.BAND_TESTED)); } - private function calc_avg_bandwidth() + private function calc_avg_bandwidth():Number { - var total = 0; - var len = bands.length; + var total:* = 0; + var len:int = bands.length; while (len--) { total += bands[len]; @@ -87,22 +87,22 @@ return Math.round(total / bands.length); } - public function set latency(prc) + public function set latency(prc:*):void { this._latency = 1 - prc; } - public function getBandwidth() + public function getBandwidth():* { return bandwidth; } - public function getPeak() + public function getPeak():* { return peak_bandwidth; } - public function last_speed() + public function last_speed():* { return curr_bandwidth; diff --git a/nativeClasses/player/DistriqtAudioPlayer.as b/nativeClasses/player/DistriqtAudioPlayer.as index 08142e0d..33eca6e9 100644 --- a/nativeClasses/player/DistriqtAudioPlayer.as +++ b/nativeClasses/player/DistriqtAudioPlayer.as @@ -25,7 +25,7 @@ import contents.alert.Alert; - public class DistriqtMediaPlayer extends Sprite + public class DistriqtAudioPlayer extends Sprite { private var isFullScreen:Boolean = false; @@ -82,7 +82,7 @@ private var checkQuailyID:int; private var checkSeekID:int; - public function DistriqtMediaPlayer(Width:Number, Height:Number) + public function DistriqtAudioPlayer(Width:Number, Height:Number) { super(); if (myDistriqtId == null) diff --git a/nativeClasses/player/DistriqtMediaPlayer.as b/nativeClasses/player/DistriqtMediaPlayer.as index 52c7ebbd..f03bd27d 100644 --- a/nativeClasses/player/DistriqtMediaPlayer.as +++ b/nativeClasses/player/DistriqtMediaPlayer.as @@ -153,7 +153,7 @@ } } - private function controlOrientationPortrate() + private function controlOrientationPortrate():void { if (stage.deviceOrientation == StageOrientation.UNKNOWN || (lastDeviceOriention == stage.deviceOrientation && lastStageorientetion == stage.orientation && (isLandScape(stage.orientation) != isLandScape(stage.deviceOrientation)))) return; @@ -316,14 +316,14 @@ } } - private function band_test(e):void + private function band_test(e:*):void { SaffronLogger.log("testSpeed:" + e.target.last_speed() + ' kb/s') } - private function play_video(e):void + private function play_video(e:*):void { - var bw = e.target.getBandwidth(); + var bw:* = e.target.getBandwidth(); SaffronLogger.log("Final bandwidth: " + bw + ' kb/s'); SaffronLogger.log("Peak bandwidth: " + e.target.getPeak() + ' kb/s'); @@ -351,6 +351,8 @@ } videoURL = videoQualities[index]; + if(nc) + nc.removeEventListener(NetStatusEvent.NET_STATUS, nc_status); nc = new NetConnection(); nc.addEventListener(NetStatusEvent.NET_STATUS, nc_status); nc.connect(null); @@ -373,12 +375,12 @@ { stream = new NetStream(nc); stream.addEventListener(NetStatusEvent.NET_STATUS, nc_status); - stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, function(e) + stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, function(e:*):void { }); if (playFirstVideo == true) // play for first time { - player.load(videoURL); + if(player)player.load(videoURL); playFirstVideo = false; } else diff --git a/nativeClasses/pushNotification/DistriqtPushNotification.as b/nativeClasses/pushNotification/DistriqtPushNotification.as index 1fbc23f8..5e065911 100644 --- a/nativeClasses/pushNotification/DistriqtPushNotification.as +++ b/nativeClasses/pushNotification/DistriqtPushNotification.as @@ -1,257 +1,258 @@ -package nativeClasses.pushNotification -{ - /*import com.distriqt.extension.core.Core; - import com.distriqt.extension.pushnotifications.AuthorisationStatus; - import com.distriqt.extension.pushnotifications.PushNotifications; - import com.distriqt.extension.pushnotifications.Service; - import com.distriqt.extension.pushnotifications.builders.ActionBuilder; - import com.distriqt.extension.pushnotifications.builders.CategoryBuilder; - import com.distriqt.extension.pushnotifications.builders.ChannelBuilder; - import com.distriqt.extension.pushnotifications.events.AuthorisationEvent; - import com.distriqt.extension.pushnotifications.events.RegistrationEvent;*/ - import flash.utils.getDefinitionByName; - import contents.alert.Alert; - //import com.distriqt.extension.pushnotifications.events.PushNotificationEvent; - //import com.distriqt.extension.pushnotifications.events.PushNotificationGroupEvent; - /** - * ... - * @author Younes Mashayekhi - */ - public class DistriqtPushNotification - { - public static var deviceToken:String; - public static var CoreClass:Class; - public static var AuthorisationStatusClass:Class; - public static var PushNotificationsClass:Class; - public static var ServiceClass:Class; - public static var ActionBuilderClass:Class; - public static var CategoryBuilderClass:Class; - public static var ChannelBuilderClass:Class; - public static var AuthorisationEventClass:Class; - public static var RegistrationEventClass:Class; - /**com.distriqt.extension.pushnotifications.events.PushNotificationEvent */ - public static var PushNotificationEventClass:Class; - /**com.distriqt.extension.pushnotifications.events.PushNotificationGroupEvent */ - public static var PushNotificationGroupEventClass:Class; +package nativeClasses.pushNotification { + /*import com.distriqt.extension.core.Core; + import com.distriqt.extension.pushnotifications.AuthorisationStatus; + import com.distriqt.extension.pushnotifications.PushNotifications; + import com.distriqt.extension.pushnotifications.Service; + import com.distriqt.extension.pushnotifications.builders.ActionBuilder; + import com.distriqt.extension.pushnotifications.builders.CategoryBuilder; + import com.distriqt.extension.pushnotifications.builders.ChannelBuilder; + import com.distriqt.extension.pushnotifications.events.AuthorisationEvent; + import com.distriqt.extension.pushnotifications.events.RegistrationEvent;*/ + import flash.utils.getDefinitionByName; + import contents.alert.Alert; + //import com.distriqt.extension.pushnotifications.events.PushNotificationEvent; + //import com.distriqt.extension.pushnotifications.events.PushNotificationGroupEvent; + /** + * ... + * @author Younes Mashayekhi + */ + public class DistriqtPushNotification { + public static var deviceToken:String; + private static var CoreClass:Class; + private static var AuthorisationStatusClass:Class; + private static var PushNotificationsClass:Class; + private static var ServiceClass:Class; + private static var ActionBuilderClass:Class; + private static var CategoryBuilderClass:Class; + private static var ChannelBuilderClass:Class; + private static var AuthorisationEventClass:Class; + private static var RegistrationEventClass:Class; + private static var InAppMessagingEventClass:Class; + /**com.distriqt.extension.pushnotifications.events.PushNotificationEvent */ + private static var PushNotificationEventClass:Class; + /**com.distriqt.extension.pushnotifications.events.PushNotificationGroupEvent */ + private static var PushNotificationGroupEventClass:Class; - private static var NotifReceived:Function ; - - public function DistriqtPushNotification() - { - - } - - public static function loadClasses():void - { - if (PushNotificationsClass == null) - { - try - { - CoreClass = getDefinitionByName("com.distriqt.extension.core.Core") as Class; - AuthorisationStatusClass = getDefinitionByName("com.distriqt.extension.pushnotifications.AuthorisationStatus") as Class; - PushNotificationsClass = getDefinitionByName("com.distriqt.extension.pushnotifications.PushNotifications") as Class; - ServiceClass = getDefinitionByName("com.distriqt.extension.pushnotifications.Service") as Class; - ActionBuilderClass = getDefinitionByName("com.distriqt.extension.pushnotifications.builders.ActionBuilder") as Class; - CategoryBuilderClass = getDefinitionByName("com.distriqt.extension.pushnotifications.builders.CategoryBuilder") as Class; - ChannelBuilderClass = getDefinitionByName("com.distriqt.extension.pushnotifications.builders.ChannelBuilder") as Class; - AuthorisationEventClass = getDefinitionByName("com.distriqt.extension.pushnotifications.events.AuthorisationEvent") as Class; - RegistrationEventClass = getDefinitionByName("com.distriqt.extension.pushnotifications.events.RegistrationEvent") as Class; - PushNotificationEventClass = getDefinitionByName("com.distriqt.extension.pushnotifications.events.PushNotificationEvent") as Class; - PushNotificationGroupEventClass = getDefinitionByName("com.distriqt.extension.pushnotifications.events.PushNotificationGroupEvent") as Class; - SaffronLogger.log("RegistrationEventClass : "+RegistrationEventClass); - } - catch (e) - { - SaffronLogger.log('Add \n\n\tcom.distriqt.PushNotification\n\tcom.distriqt.Core\n\n to your project xmls');// and below permitions to the tag : \n\n\n\n\t\n\n\n\n\t\n\n'; - } - } - } - - public static function isSupport():Boolean - { - loadClasses(); - if (PushNotificationsClass == null || PushNotificationsClass.isSupported == false) - return false - else - return true; - } - - /** - * You can receive server data on onNotifReceived function as a String - * @param onResult - * @param onNotifReceived - */ - public static function setup(onResult:Function = null,onNotifReceived:Function=null):void - { - NotifReceived = onNotifReceived ; - var PushNotifications:Object; - loadClasses(); - if(onResult==null) - { - onResult = function(text:String):void - { - //show registration ID : - SaffronLogger.log(text); - } - } - if (PushNotificationsClass == null) - { - SaffronLogger.log("push notification is null"); - deviceToken = "windowsDebug"; - onResult(deviceToken); - return; - } - try - { - if (PushNotificationsClass.isSupported) - { - SaffronLogger.log("Push Notification supported") - if ((PushNotificationsClass as Object).service.isServiceSupported((ServiceClass as Object).FCM)) - { - var service:* = new ServiceClass((ServiceClass as Object).FCM, ""); - service.sandboxMode = false; - service.enableNotificationsWhenActive = true; - service.categories.push(new CategoryBuilderClass().setIdentifier("MESSAGE_CATEGORY").addAction(new ActionBuilderClass().setTitle("OK").setWillLaunchApplication(true).setIdentifier("OPEN_APP_BTN").build()).addAction(new ActionBuilderClass().setTitle("Cancel").setDestructive(true).setShouldCancelOnAction(true).setIdentifier("CANCEL_APP_BTN").build()).build()); - service.channels.push(new ChannelBuilderClass().setId("app_channel").setName("App Channel").build()); - (PushNotificationsClass as Object).service.addEventListener((RegistrationEventClass as Object).REGISTERING, registeringHandler); - (PushNotificationsClass as Object).service.addEventListener((RegistrationEventClass as Object).REGISTER_SUCCESS, registerSuccessHandler); - (PushNotificationsClass as Object).service.addEventListener((RegistrationEventClass as Object).CHANGED, registrationChangedHandler); - (PushNotificationsClass as Object).service.addEventListener((RegistrationEventClass as Object).REGISTER_FAILED, registerFailedHandler); - (PushNotificationsClass as Object).service.addEventListener((RegistrationEventClass as Object).ERROR,errorHandler); - (PushNotificationsClass as Object).service.addEventListener((AuthorisationEventClass as Object).CHANGED,authorisationChangedHandler); - (PushNotificationsClass as Object).service.addEventListener( (PushNotificationEventClass as Object).NOTIFICATION, notificationHandler ); - (PushNotificationsClass as Object).service.addEventListener( (PushNotificationEventClass as Object).NOTIFICATION_SELECTED, notificationHandler ); - (PushNotificationsClass as Object).service.addEventListener( (PushNotificationEventClass as Object).ACTION, actionHandler ); - (PushNotificationsClass as Object).service.addEventListener( (PushNotificationGroupEventClass as Class).GROUP_SELECTED, groupSelectedHandler ); - - (PushNotificationsClass as Object).service.setup(service); - requestAuthorisation(); - function registeringHandler(event:*):void - { - SaffronLogger.log("Registration started"); - } - - function registerSuccessHandler(event:*):void - { - SaffronLogger.log("Registration succeeded with ID: " + event.data); - deviceToken = event.data; - onResult(event.data); - } - - function registrationChangedHandler(event:*):void - { - SaffronLogger.log("Registration ID has changed: " + event.data); - deviceToken = event.data; - onResult(event.data); - } - - function registerFailedHandler(event:*):void - { - SaffronLogger.log("Registration failed"); - // onResult("Registration failed"); - } - - function errorHandler(event:*):void - { - SaffronLogger.log("Registration error: " + event.data); - // onResult("Registration error"); - } - - } - else - { - SaffronLogger.log("fcm notification is not support"); - // onResult("FCM Not Support"); - } - } - else - { - SaffronLogger.log("notification is not support"); - // onResult("windows Debug"); - } - } - catch (e:Error) - { - SaffronLogger.log("ERROR:" + e.message); - // onResult("error occured"); - } - } + private static var NotifReceived:Function; + private static var InAppMsgRecevied:Function; + public function DistriqtPushNotification() { - private static function notificationHandler( event:* ):void - { - SaffronLogger.log( "Notification: ["+event.type+"] state="+event.applicationState+" startup="+event.startup ); - SaffronLogger.log( event.payload );//{"google.delivered_priority":"high","TypeId":"2","google.ttl":2419200,"google.original_priority":"high","Id":"2096"} - SaffronLogger.log(">>Complete data : "+JSON.stringify(event)); - if(NotifReceived!=null) - { - if(NotifReceived.length>0) - { - NotifReceived(event.payload); - } - else - { - NotifReceived(); - } - } - } + } - private static function actionHandler( event:* ):void - { - SaffronLogger.log( "Action: ["+event.type+"] identifier="+event.identifier+" state="+event.applicationState+" startup="+event.startup ); - SaffronLogger.log( event.payload ); - SaffronLogger.log(">>Complete data : "+JSON.stringify(event)); - } + private static function loadClasses():void { + if (PushNotificationsClass == null) { + try { + CoreClass = getDefinitionByName("com.distriqt.extension.core.Core") as Class; + AuthorisationStatusClass = getDefinitionByName("com.distriqt.extension.pushnotifications.AuthorisationStatus") as Class; + PushNotificationsClass = getDefinitionByName("com.distriqt.extension.pushnotifications.PushNotifications") as Class; + ServiceClass = getDefinitionByName("com.distriqt.extension.pushnotifications.Service") as Class; + ActionBuilderClass = getDefinitionByName("com.distriqt.extension.pushnotifications.builders.ActionBuilder") as Class; + CategoryBuilderClass = getDefinitionByName("com.distriqt.extension.pushnotifications.builders.CategoryBuilder") as Class; + ChannelBuilderClass = getDefinitionByName("com.distriqt.extension.pushnotifications.builders.ChannelBuilder") as Class; + AuthorisationEventClass = getDefinitionByName("com.distriqt.extension.pushnotifications.events.AuthorisationEvent") as Class; + RegistrationEventClass = getDefinitionByName("com.distriqt.extension.pushnotifications.events.RegistrationEvent") as Class; + PushNotificationEventClass = getDefinitionByName("com.distriqt.extension.pushnotifications.events.PushNotificationEvent") as Class; + PushNotificationGroupEventClass = getDefinitionByName("com.distriqt.extension.pushnotifications.events.PushNotificationGroupEvent") as Class; + InAppMessagingEventClass = getDefinitionByName("com.distriqt.extension.pushnotifications.events.InAppMessagingEvent") as Class; + SaffronLogger.log("RegistrationEventClass : " + RegistrationEventClass); + } catch (e) { + SaffronLogger.log('Add \n\n\tcom.distriqt.PushNotification\n\tcom.distriqt.Core\n\n to your project xmls'); // and below permitions to the tag : \n\n\n\n\t\n\n\n\n\t\n\n'; + } + } + } - private static function groupSelectedHandler( event:* ):void - { - SaffronLogger.log( "Group Selected: ["+event.type+"] groupKey="+event.groupKey+" state="+event.applicationState+" startup="+event.startup ); - for each (var payload:String in event.payloads) - { - SaffronLogger.log( "PAYLOAD: "+ payload ); - } - SaffronLogger.log(">>Complete data : "+JSON.stringify(event)); - } - - private static function authorisationChangedHandler(e:*):void - { - requestAuthorisation(); - } - - private static function requestAuthorisation(e:* = null):void - { - switch ((PushNotificationsClass as Object).service.authorisationStatus()) - { - case (AuthorisationStatusClass as Object).AUTHORISED: - // This device has been authorised. - // You can register this device and expect: - // - registration success/failed event, and; - // - notifications to be displayed - (PushNotificationsClass as Object).service.register(); - break; - - case (AuthorisationStatusClass as Object).NOT_DETERMINED: - // You are yet to ask for authorisation to display notifications - // At this point you should consider your strategy to get your user to authorise - // notifications by explaining what the application will provide - (PushNotificationsClass as Object).service.requestAuthorisation(); - break; - - case (AuthorisationStatusClass as Object).DENIED: - // The user has disabled notifications - // Advise your user of the lack of notifications as you see fit - - // For example: You can redirect to the settings page on iOS - if ((PushNotificationsClass as Object).service.canOpenDeviceSettings) - { - //PushNotifications.service.openDeviceSettings(); - } - break; - } - } - - } + public static function isSupport():Boolean { + loadClasses(); + if (PushNotificationsClass == null || PushNotificationsClass.isSupported == false) + return false + else + return true; + } -} \ No newline at end of file + /** + * You can receive server data on onNotifReceived & onInAppMsgRecevied function as a String + * @param onResult + * @param onNotifReceived + * @param onInAppMsgRecevied + */ + public static function setup(onResult:Function = null, onNotifReceived:Function = null, onInAppMsgRecevied:Function = null):void { + NotifReceived = onNotifReceived; + InAppMsgRecevied = onInAppMsgRecevied; + var PushNotifications:Object; + loadClasses(); + if (onResult == null) { + onResult = function(text:String):void { + //show registration ID : + SaffronLogger.log(text); + } + } + if (PushNotificationsClass == null) { + SaffronLogger.log("push notification is null"); + deviceToken = "windowsDebug"; + onResult(deviceToken); + return; + } + try { + (CoreClass as Object).init(); + trace("CoreClass init") + if (PushNotificationsClass.isSupported) { + SaffronLogger.log("Push Notification supported") + if ((PushNotificationsClass as Object).service.isServiceSupported((ServiceClass as Object).FCM)) { + SaffronLogger.log("FCM supported") + var service:* = new ServiceClass((ServiceClass as Object).FCM, ""); + service.sandboxMode = true; // false it in production mode!!! + service.setNotificationsWhenActive(true); + service.categories.push(new CategoryBuilderClass().setIdentifier("MESSAGE_CATEGORY").addAction(new ActionBuilderClass().setTitle("OK").setWillLaunchApplication(true).setIdentifier("OPEN_APP_BTN").build()).addAction(new ActionBuilderClass().setTitle("Cancel").setDestructive(true).setShouldCancelOnAction(true).setIdentifier("CANCEL_APP_BTN").build()).build()); + service.channels.push(new ChannelBuilderClass().setId("app_channel").setName("App Channel").build()); + (PushNotificationsClass as Object).service.addEventListener((RegistrationEventClass as Object).REGISTERING, registeringHandler); + (PushNotificationsClass as Object).service.addEventListener((RegistrationEventClass as Object).REGISTER_SUCCESS, registerSuccessHandler); + (PushNotificationsClass as Object).service.addEventListener((RegistrationEventClass as Object).CHANGED, registrationChangedHandler); + (PushNotificationsClass as Object).service.addEventListener((RegistrationEventClass as Object).REGISTER_FAILED, registerFailedHandler); + (PushNotificationsClass as Object).service.addEventListener((RegistrationEventClass as Object).ERROR, errorHandler); + (PushNotificationsClass as Object).service.addEventListener((AuthorisationEventClass as Object).CHANGED, authorisationChangedHandler); + (PushNotificationsClass as Object).service.addEventListener((PushNotificationEventClass as Object).NOTIFICATION, notificationHandler); + (PushNotificationsClass as Object).service.addEventListener((PushNotificationEventClass as Object).NOTIFICATION_SELECTED, notificationHandler); + (PushNotificationsClass as Object).service.addEventListener((PushNotificationEventClass as Object).ACTION, actionHandler); + (PushNotificationsClass as Object).service.addEventListener((PushNotificationGroupEventClass as Class).GROUP_SELECTED, groupSelectedHandler); + (PushNotificationsClass as Object).service.setup(service); + requestAuthorisation(); + function registeringHandler(event:*):void { + SaffronLogger.log("Registration started"); + } + + function registerSuccessHandler(event:*):void { + SaffronLogger.log("Registration succeeded with ID: " + event.data); + deviceToken = event.data; + onResult(event.data); + } + + function registrationChangedHandler(event:*):void { + SaffronLogger.log("Registration ID has changed: " + event.data); + deviceToken = event.data; + onResult(event.data); + } + + function registerFailedHandler(event:*):void { + SaffronLogger.log("Registration failed"); + // onResult("Registration failed"); + } + + function errorHandler(event:*):void { + SaffronLogger.log("Registration error: " + event.data); + // onResult("Registration error"); + } + + } else { + SaffronLogger.log("fcm notification is not support"); + // onResult("FCM Not Support"); + } + } else { + SaffronLogger.log("notification is not support"); + // onResult("windows Debug"); + } + } catch (e:Error) { + SaffronLogger.log("ERROR:" + e.message); + // onResult("error occured"); + } + } + + + private static function notificationHandler(event:*):void { + SaffronLogger.log("Notification: [" + event.type + "] state=" + event.applicationState + " startup=" + event.startup); + SaffronLogger.log(event.payload); //{"google.delivered_priority":"high","TypeId":"2","google.ttl":2419200,"google.original_priority":"high","Id":"2096"} + SaffronLogger.log(">>Complete data : " + JSON.stringify(event)); + if (NotifReceived != null) { + if (JSON.stringify(event.payload).length > 0) { + NotifReceived(event.payload); + } else { + NotifReceived(); + } + } + } + + private static function actionHandler(event:*):void { + SaffronLogger.log("Action: [" + event.type + "] identifier=" + event.identifier + " state=" + event.applicationState + " startup=" + event.startup); + SaffronLogger.log(event.payload); + SaffronLogger.log(">>Complete data : " + JSON.stringify(event)); + } + + private static function groupSelectedHandler(event:*):void { + SaffronLogger.log("Group Selected: [" + event.type + "] groupKey=" + event.groupKey + " state=" + event.applicationState + " startup=" + event.startup); + for each (var payload:String in event.payloads) { + SaffronLogger.log("PAYLOAD: " + payload); + } + SaffronLogger.log(">>Complete data : " + JSON.stringify(event)); + } + + public static function setupInAppMessaging():void { + // call this function after a few second after setup pushnotification + if (PushNotificationsClass == null) { + //windowsDebug; + return; + } + if ((PushNotificationsClass as Object).service.inAppMessaging.isSupported) { + (PushNotificationsClass as Object).service.inAppMessaging.addEventListener((InAppMessagingEventClass as Object).SELECTED, inappmessaging_selectedHandler); + SaffronLogger.log("InAppMessaging SUPPORTED") + } else { + SaffronLogger.log("InAppMessaging NOT SUPPORTED") + } + } + + public static function setTriggerForInAppMessaging(key:String, value:String = ""):void { + //at first,you must call setupInAppMessaging method + if (PushNotificationsClass == null) { + //windowsDebug; + return; + } + (PushNotificationsClass as Object).service.inAppMessaging.addTrigger(key, value); + } + + private static function inappmessaging_selectedHandler(event:*):void { + if (InAppMsgRecevied != null) { + if (JSON.stringify(event.data).length > 0) { + InAppMsgRecevied(JSON.stringify(event.data)); + } else { + InAppMsgRecevied(); + } + } + } + + private static function authorisationChangedHandler(e:*):void { + requestAuthorisation(); + } + + private static function requestAuthorisation(e:* = null):void { + switch ((PushNotificationsClass as Object).service.authorisationStatus()) { + case (AuthorisationStatusClass as Object).AUTHORISED: + // This device has been authorised. + // You can register this device and expect: + // - registration success/failed event, and; + // - notifications to be displayed + (PushNotificationsClass as Object).service.register(); + break; + + case (AuthorisationStatusClass as Object).NOT_DETERMINED: + // You are yet to ask for authorisation to display notifications + // At this point you should consider your strategy to get your user to authorise + // notifications by explaining what the application will provide + (PushNotificationsClass as Object).service.requestAuthorisation(); + break; + + case (AuthorisationStatusClass as Object).DENIED: + // The user has disabled notifications + // Advise your user of the lack of notifications as you see fit + + // For example: You can redirect to the settings page on iOS + if ((PushNotificationsClass as Object).service.canOpenDeviceSettings) { + //PushNotifications.service.openDeviceSettings(); + } + break; + } + } + + } + +} diff --git a/netManager/UDPManager.as b/netManager/UDPManager.as new file mode 100644 index 00000000..3a5c31cc --- /dev/null +++ b/netManager/UDPManager.as @@ -0,0 +1,71 @@ +package netManager +{ + import flash.net.DatagramSocket; + import flash.utils.ByteArray; + import flash.events.DatagramSocketDataEvent; + import flash.utils.getTimer; + + public class UDPManager + { + private static var myUDP:DatagramSocket ; + + private static var onReceiveFunction:Function ; + + private static var lastMassageDeliveryTime:int ; + + private static function setUp():void + { + if(myUDP==null) + { + myUDP = new DatagramSocket(); + myUDP.addEventListener(DatagramSocketDataEvent.DATA,onDataReceived); + } + } + + private static function onDataReceived(e:DatagramSocketDataEvent):void + { + trace("Message received"); + lastMassageDeliveryTime = getTimer(); + var message:String = e.data.toString(); + if(onReceiveFunction!=null && onReceiveFunction.length>0) + onReceiveFunction(message) + } + + public static function getMessageOnPort(onRespond:Function,myPort:uint):void + { + trace("myUDP.connected : "+myUDP.connected); + trace("myUDP.localPort : " +myUDP.localPort); + onReceiveFunction = onRespond ; + if(myUDP.localPort==0 || ( myUDP.localPort!=myPort)) + { + if(myUDP.connected) + myUDP.close(); + + myUDP.bind(myPort); + myUDP.receive(); + } + } + + public static function isConnected():Boolean + { + return myUDP.connected && myUDP.localPort !=0; + } + + public static function sendMessageTo(message:String,onRespond:Function,targetIp:String,targetPort:uint,localPort:uint=2000):void + { + setUp(); + trace("Message sent:"+message); + getMessageOnPort(onRespond,localPort); + var data:ByteArray = new ByteArray(); + data.writeUTFBytes(message); + myUDP.send(data,0,0,targetIp,targetPort); + myUDP.receive(); + } + + /**Returns the last time that connection accured */ + public function getLastConnectionTimeout():int + { + return getTimer()-lastMassageDeliveryTime; + } + } +} \ No newline at end of file diff --git a/netManager/urlSaver/URLSaver.as b/netManager/urlSaver/URLSaver.as index 00a163a3..bd54bda9 100644 --- a/netManager/urlSaver/URLSaver.as +++ b/netManager/urlSaver/URLSaver.as @@ -42,7 +42,7 @@ package netManager.urlSaver private static var acceptableDate:Number = 0 ; - public static function activateDateControll(noOlder:Date) + public static function activateDateControll(noOlder:Date):void { acceptableDate = noOlder.time ; } @@ -240,7 +240,7 @@ package netManager.urlSaver } /**Cansel current download*/ - public function cansel() + public function cansel():void { //SaffronLogger.log('Cansel donwload manager : '+onlineURL); if(fileSaver) @@ -358,7 +358,7 @@ package netManager.urlSaver private function saveLoadedBytes():void { - + trace("Download file done"); var oflineFolder:File; if(mySpecialFolder!=null) { @@ -445,21 +445,34 @@ package netManager.urlSaver fileSaver.close(); fileSaver = null ; } - fileSaver = new FileStream(); - fileSaver.addEventListener(Event.CLOSE,fileIsSaved); - fileSaver.addEventListener(IOErrorEvent.IO_ERROR,fileSaverError); - fileSaver.openAsync(oflineFile,FileMode.WRITE); - fileSaver.writeBytes(myLoadedBytes); - fileSaver.close(); - //SaffronLogger.log("Save the imafe on device...................................... : "+oflineFile.url+' > '+myLoadedBytes.bytesAvailable); - - //SavedDatas.save(onlineURL,offlineURL); - //SaffronLogger.log('offile file saved on : '+onlineURL); - storage.data[onlineURL] = offlineURL ; - datestorage.data[onlineURL] = new Date().time ; - //SaffronLogger.log("datestorage.data[onlineURL] : " +datestorage.data[onlineURL]); - datestorage.flush(); - storage.flush(); + + if(oflineFile.nativePath.indexOf(File.applicationStorageDirectory.nativePath)!=-1) + { + startSaveItem(); + } + else + { + FileManager.controlFilePermission(startSaveItem,true); + } + + function startSaveItem():void + { + fileSaver = new FileStream(); + fileSaver.addEventListener(Event.CLOSE,fileIsSaved); + fileSaver.addEventListener(IOErrorEvent.IO_ERROR,fileSaverError); + fileSaver.openAsync(oflineFile,FileMode.WRITE); + fileSaver.writeBytes(myLoadedBytes); + fileSaver.close(); + SaffronLogger.log("Save the imafe on device...................................... : "+oflineFile.url+' > '+myLoadedBytes.bytesAvailable); + + //SavedDatas.save(onlineURL,offlineURL); + //SaffronLogger.log('offile file saved on : '+onlineURL); + storage.data[onlineURL] = offlineURL ; + datestorage.data[onlineURL] = new Date().time ; + //SaffronLogger.log("datestorage.data[onlineURL] : " +datestorage.data[onlineURL]); + datestorage.flush(); + storage.flush(); + } } protected function fileSaverError(event:IOErrorEvent):void @@ -559,9 +572,9 @@ package netManager.urlSaver //////////////////////////////////////////////delete temporary /**Delete images older than this date*/ - public static function deleteDatasOlderThan(date:Date) + public static function deleteDatasOlderThan(date:Date):void { - for(var i in datestorage.data) + for(var i:* in datestorage.data) { if(datestorage.data[i] < date.time) { diff --git a/notification/NotificationEvent.as b/notification/NotificationEvent.as index 2b14cbd5..1b4bf925 100644 --- a/notification/NotificationEvent.as +++ b/notification/NotificationEvent.as @@ -4,8 +4,8 @@ package notification public class NotificationEvent extends Event { - public static const TOKEN_REGISTER_COMPELETED="TOKEN_REGISTER_COMPELETED" - public static const TOKEN_REGISTER_START = "TOKEN_REGISTER_START" + public static const TOKEN_REGISTER_COMPELETED:String="TOKEN_REGISTER_COMPELETED" + public static const TOKEN_REGISTER_START:String = "TOKEN_REGISTER_START" public static const NOTIFICATION:String = "NOTIFICATION"; public static const FOREGROUND_NOTIFICATION:String = "FOREGROUND_NOTIFICATION"; diff --git a/notification/NotificationManager.as b/notification/NotificationManager.as index dd240358..519f8e78 100644 --- a/notification/NotificationManager.as +++ b/notification/NotificationManager.as @@ -69,7 +69,7 @@ return Notification_Event ; } - private function EasyPushExample() + private function EasyPushExample() :void { //Controll permissions↓ diff --git a/photoEditor/EditorPencil.as b/photoEditor/EditorPencil.as index ca491f3d..b70aa312 100644 --- a/photoEditor/EditorPencil.as +++ b/photoEditor/EditorPencil.as @@ -194,7 +194,7 @@ package photoEditor var tool:MovieClip = event.currentTarget as MovieClip ; var toolSize:Number = uint(tool.name.split(toolsSizeName).join('')); - for(var i = 0 ; i = imageHistory.splice(imageIndex+1,imageHistory.length-imageIndex); - for(var i = 0 ; i0) { @@ -84,7 +86,8 @@ Alert.show(String(evt.field[credit]));
}
*/ - public static function getText(title:String,question:String,tagLable:String,onDone:Function,OnNotAccepted:Function=null,keyboardType:String=SoftKeyboardType.DEFAULT,isPassword:Boolean=false,innerDisplayObject:DisplayObject=null,ButtonFrameYes:int=1,ButtonFrameNo:int=1,defaultTextOnField:String=''):void + public static function getText(title:String,question:String,tagLable:String,onDone:Function,OnNotAccepted:Function=null,keyboardType:String=SoftKeyboardType.DEFAULT,isPassword:Boolean=false, + innerDisplayObject:DisplayObject=null,ButtonFrameYes:int=1,ButtonFrameNo:int=1,defaultTextOnField:String='',numLine:uint=1):void { controllConfig(); onQuestionAccepted = onDone; @@ -93,7 +96,7 @@ var buttons:Array = [new PopButtonData(Contents.lang.t[id_submit],ButtonFrameYes,null,true,true) ,new PopButtonData(Contents.lang.t[id_back],ButtonFrameNo,null,true,true)] ; var popFields:PopMenuFields = new PopMenuFields(); - popFields.addField(tagLable,defaultTextOnField,keyboardType,isPassword,true,true); + popFields.addField(tagLable,defaultTextOnField,keyboardType,isPassword,true,true,numLine,0,1,0,numLine>1); var popText:PopMenuContent = new PopMenuContent(question,popFields,buttons,innerDisplayObject); PopMenu1.popUp(title,null,popText,0,textCatched); } @@ -126,7 +129,7 @@ } } - private static function onQuestionAnswered(e:PopMenuEvent) + private static function onQuestionAnswered(e:PopMenuEvent):void { if(e.buttonTitle == Contents.lang.t[id_yes]) { @@ -174,19 +177,21 @@ { if(_onClose!=null) { - _onClose.call(); + var cahsedhCloseFunc:Function = _onClose ; + _onClose = null ; + cahsedhCloseFunc(); } } /**Show no internet connection available*/ - public static function noInternet(fakeInput:*=null,onClosed:Function=null) + public static function noInternet(fakeInput:*=null,onClosed:Function=null):void { controllConfig(); show(Contents.lang.t[id_no_internet],true,-1,null,'',onClosed); } /**hide hint*/ - public static function hide() + public static function hide():void { PopMenu1.close(); //throw "Hide calls"; @@ -195,7 +200,7 @@ /**Show the please wait page , you have to close this page manualy
* The onCloded function had to get popDataEvent*/ - public static function pleaseWait( onClosed:Function = null ) + public static function pleaseWait( onClosed:Function = null ):void { controllConfig(); var buttons:Array ; diff --git a/popForm/PopButton.as b/popForm/PopButton.as index 9b5b8fdb..2cbddcd0 100644 --- a/popForm/PopButton.as +++ b/popForm/PopButton.as @@ -187,7 +187,7 @@ /**add titles that will triggerring the back button*/ - public static function addBackTitleTrigger(backTitle:String) + public static function addBackTitleTrigger(backTitle:String):void { backList.push(backTitle); } @@ -215,7 +215,7 @@ NativeApplication.nativeApplication.removeEventListener(KeyboardEvent.KEY_DOWN,checkBack); } - private function checkBack(e:KeyboardEvent) + private function checkBack(e:KeyboardEvent):void { if(!Obj.getVisible(me) || !Obj.getImOnStage(me)) { @@ -234,14 +234,16 @@ } } - public function onClick(func:Function):void + public function onClick(func:Function):PopButton { Obj.setButton(this,func); + return this ; } - public function onClickOpenLink(link:LinkData):void + public function onClickOpenLink(link:LinkData):PopButton { Obj.setButton(this,openLink); _link_to_open = link ; + return this ; } private function openLink():void { @@ -249,13 +251,14 @@ this.dispatchEvent(new AppEventContent(_link_to_open)); } - public function setUpByLink(linkData:LinkData):void + public function setUpByLink(linkData:LinkData):PopButton { setUp(linkData.name); var ME:PopButton = this ; onClick(function():void{ ME.dispatchEvent(new AppEventContent(linkData)); }); + return this ; } diff --git a/popForm/PopField.as b/popForm/PopField.as index b476ca1f..c9523081 100644 --- a/popForm/PopField.as +++ b/popForm/PopField.as @@ -69,6 +69,8 @@ private var onSubmited:Function ; private var onEditedFunc:Function ; private var onEditeFuncCalDelay:uint ; + + private var requiredMC:MovieClip ; public function get textField():TextField @@ -185,6 +187,20 @@ { super(); stop(); + requiredMC = Obj.get("required_mc",this); + if(requiredMC)requiredMC.visible = false ; + } + + public function required():PopField + { + if(requiredMC)requiredMC.visible = true ; + return this ; + } + + public function isCurrentcy():PopField + { + if(nativeKeyBoard)nativeKeyBoard.isCurrency() + return this ; } /**Changing the form color without making effect on other values*/ @@ -218,9 +234,10 @@ } } - public function onEdited(func:Function):void + public function onEdited(func:Function):PopField { onEditedFunc = func ; + return this ; } public function setUp(tagName:String,defaultText:String,KeyBordType:String = SoftKeyboardType.DEFAULT,isPass:Boolean = false,editable:Boolean = true,isAraic:Boolean=true,numLines:uint = 1,color:uint=1,frame:uint=1,maxChar:uint=0,otherOptions:Array=null,deleteDefautlText:Boolean=false,activateRadioSwitcher:Boolean=false,returnKey:String=ReturnKeyLabel.DEFAULT,onTypedFunction:Function=null,justShowNativeText:Boolean=false,multiLineTag:Boolean=false,justify:Boolean=true,selectAllCharchter:Boolean=false):PopField @@ -343,7 +360,7 @@ Y0 = myTXT.height; myTXT.multiline = true ; myTXT.wordWrap = true ; - for(var i = 0 ; i(); @@ -156,9 +156,9 @@ package popForm public function update(content:PopMenuFields):void { - for(var i = 0 ; i * When this event dispatches from field, you have to detect field id from buttonID value and you can get last field value by using field[buttinID]*/ diff --git a/popForm/PopMenuFields.as b/popForm/PopMenuFields.as index d57847ca..c460be86 100644 --- a/popForm/PopMenuFields.as +++ b/popForm/PopMenuFields.as @@ -63,7 +63,7 @@ /**add new field
* frameForDirection: 1 for rtl and 2 for ltr script
* if the field is read only, you can set numLines to 0 and make it change the lines by it's needs*/ - public function addField(tagName:String,fieldDefault:*='',keyBoardType:String = SoftKeyboardType.DEFAULT,isPass:Boolean=false,Editable:Boolean = true,isArabic_v:Boolean=true,numLine:uint=1,frameForDirection:uint=0,fieldColorFrame:uint=1,maxChar:uint=0,MultiLineTag:Boolean=false,Align:Boolean=true) + public function addField(tagName:String,fieldDefault:*='',keyBoardType:String = SoftKeyboardType.DEFAULT,isPass:Boolean=false,Editable:Boolean = true,isArabic_v:Boolean=true,numLine:uint=1,frameForDirection:uint=0,fieldColorFrame:uint=1,maxChar:uint=0,MultiLineTag:Boolean=false,Align:Boolean=true):void { if(frameForDirection==0) { @@ -99,7 +99,7 @@ maxCharacters.push(maxChar); } - public function addRadioListField(tagName:String,popFieldOptions:Array,fieldDefault:*='',isArabic_v:Boolean=true,frameForDirection:uint=1,fieldColorFrame:uint=1,Align:Boolean=true) + public function addRadioListField(tagName:String,popFieldOptions:Array,fieldDefault:*='',isArabic_v:Boolean=true,frameForDirection:uint=1,fieldColorFrame:uint=1,Align:Boolean=true):void { tagNames.push(tagName); if(fieldDefault==null) @@ -124,7 +124,7 @@ maxCharacters.push(0); } - public function addPhoneField(tagName:String,fieldDefault:String='',isArabic_v:Boolean=true,frameForDirection:uint=1,fieldColorFrame:uint=1,isEditable:Boolean=true) + public function addPhoneField(tagName:String,fieldDefault:String='',isArabic_v:Boolean=true,frameForDirection:uint=1,fieldColorFrame:uint=1,isEditable:Boolean=true):void { tagNames.push(tagName); fieldDefaults.push(fieldDefault); @@ -147,7 +147,7 @@ /**add new field
* frameForDirection: 1 for rtl and 2 for ltr script*/ - public function addClickField(tagName:String,fieldDefault:String='',/*keyBoardType:String = SoftKeyboardType.DEFAULT*//*,isPass:Boolean=false*//*,Editable:Boolean = true,*/isArabic_v:Boolean=true,numLine:uint=1,frameForDirection:uint=1,fieldColorFrame:uint=1) + public function addClickField(tagName:String,fieldDefault:String='',/*keyBoardType:String = SoftKeyboardType.DEFAULT*//*,isPass:Boolean=false*//*,Editable:Boolean = true,*/isArabic_v:Boolean=true,numLine:uint=1,frameForDirection:uint=1,fieldColorFrame:uint=1):void { //keyBoardType = (keyBoardType==null)?SoftKeyboardType.DEFAULT:keyBoardType; @@ -172,7 +172,7 @@ /**add new field
* frameForDirection: 1 for rtl and 2 for ltr script*/ - public function addDateField(tagName:String,fieldDefaultDates:Date=null,Editable:Boolean = true,isArabic_v:Boolean=true,frameForDirection:uint=1,fieldColorFrame:uint=1) + public function addDateField(tagName:String,fieldDefaultDates:Date=null,Editable:Boolean = true,isArabic_v:Boolean=true,frameForDirection:uint=1,fieldColorFrame:uint=1):void { //keyBoardType = (keyBoardType==null)?SoftKeyboardType.DEFAULT:keyBoardType; @@ -197,7 +197,7 @@ /**add new field
* frameForDirection: 1 for rtl and 2 for ltr script*/ - public function addBooleanField(tagName:String,booleanValue:Boolean,frameForDirection:uint=1,fieldColorFrame:uint=1,Arabic:Boolean=true) + public function addBooleanField(tagName:String,booleanValue:Boolean,frameForDirection:uint=1,fieldColorFrame:uint=1,Arabic:Boolean=true):void { //keyBoardType = (keyBoardType==null)?SoftKeyboardType.DEFAULT:keyBoardType; tagNames.push(tagName); @@ -221,7 +221,7 @@ /**add new field
* frameForDirection: 1 for rtl and 2 for ltr script*/ - public function addTimeField(tagName:String,fieldDefaultDates:Date=null,Editable:Boolean = true,isArabic_v:Boolean=true,frameForDirection:uint=1,fieldColorFrame:uint=1) + public function addTimeField(tagName:String,fieldDefaultDates:Date=null,Editable:Boolean = true,isArabic_v:Boolean=true,frameForDirection:uint=1,fieldColorFrame:uint=1):void { //keyBoardType = (keyBoardType==null)?SoftKeyboardType.DEFAULT:keyBoardType; diff --git a/popForm/PopMenuTypes.as b/popForm/PopMenuTypes.as index 2a518f55..4d1fe2cc 100644 --- a/popForm/PopMenuTypes.as +++ b/popForm/PopMenuTypes.as @@ -23,13 +23,13 @@ } /**this is a answer type of pop ups*/ - public static function get DEFAULT() + public static function get DEFAULT():PopMenuTypes { return new PopMenuTypes(1/*,0xFF33CC*/); } /**this is a question type of pop ups*/ - public static function get CAUTION() + public static function get CAUTION():PopMenuTypes { return new PopMenuTypes(2/*,0x00cc00*/); } diff --git a/restDoaService/RestDoaServiceCaller.as b/restDoaService/RestDoaServiceCaller.as index f16bcec9..39b73e8a 100644 --- a/restDoaService/RestDoaServiceCaller.as +++ b/restDoaService/RestDoaServiceCaller.as @@ -61,6 +61,7 @@ private static var webServiceId:uint = 0 ; + private static var _fake_no_net:Boolean = false ; public function get pureData():String { @@ -158,6 +159,11 @@ requestLoader.addEventListener(ProgressEvent.PROGRESS,dispatchProgress); } + public static function cutConnect(status:Boolean=true):void + { + _fake_no_net = status ; + } + public function then(onResponded:Function):RestDoaServiceCaller { resultReturnedFunc = onResponded ; @@ -455,10 +461,10 @@ } /**Values are not case sencitive*/ - protected function loadParam(obj:Object=null,isDataForm:Boolean=false):void + protected function loadParam(obj:Object=null,isDataForm:Boolean=false,clearFunctions:Boolean=true):void { HTTPStatus = 0 ; - cansel(); + cansel(clearFunctions); updateHeaders(); isConnected = false ; onUpdateProccess = false ; @@ -501,7 +507,7 @@ var readableObject:Object = Obj.createReadAbleObject(obj);// .myParams ; urlVars = new URLVariables(); - for(var i in readableObject) + for(var i:* in readableObject) { urlVars[i] = readableObject[i] ;//a1=123&a2=32 || CaseTbl=(a1=123&a2=32) } @@ -548,7 +554,7 @@ { SaffronLogger.log("* instant cashed data for "+myId+" : "+savedData); } - FuncManager.callAsyncOnFrame(function(){ + FuncManager.callAsyncOnFrame(function():void{ parsLoadedData(savedData); if(expired) { @@ -583,17 +589,27 @@ //debug line //navigateToURL(pureRequest); _isLoading = true ; - requestLoader.load(pureRequest); + if(_fake_no_net) + { + setTimeout(function():void{ + requestLoader.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR,true,false,'no net')); + },100) + } + else + { + requestLoader.load(pureRequest); + } //noInternet(); } - public function reLoad(delay:uint=20000,dontReturnOfflineData:Boolean=false):void + public function reLoad(delay:uint=20000,dontReturnOfflineData:Boolean=false):RestDoaServiceCaller { cansel(false); offlineDate = new Date() ; offlineDataIsOK = !dontReturnOfflineData ; instantOfflineData = false ; - timerId = setTimeout(loadParam,delay) + timerId = setTimeout(loadParam,delay,null,false,false); + return this ; } public function cancel():void diff --git a/sliderMenu/SliderManager.as b/sliderMenu/SliderManager.as index c29f1eba..003514e7 100644 --- a/sliderMenu/SliderManager.as +++ b/sliderMenu/SliderManager.as @@ -348,7 +348,7 @@ package sliderMenu /**start the drag*/ private static function checkDrag(e:MouseEvent):void { - if(lock_flag) + if(lock_flag || PopMenu.isOpen) { //menu is lock return ; diff --git a/tabMenu/TabMenuManager.as b/tabMenu/TabMenuManager.as index 532fb101..45bd1928 100644 --- a/tabMenu/TabMenuManager.as +++ b/tabMenu/TabMenuManager.as @@ -24,7 +24,7 @@ package tabMenu } - for(var valueName in _currentTabe[GroupName_p]) + for(var valueName:* in _currentTabe[GroupName_p]) { _currentTabe[GroupName_p][valueName] = false; } diff --git a/webService/webCallers/WebServiceCaller.as b/webService/webCallers/WebServiceCaller.as index ce2b9bce..c0fcc125 100644 --- a/webService/webCallers/WebServiceCaller.as +++ b/webService/webCallers/WebServiceCaller.as @@ -63,6 +63,7 @@ private var func_onDataRetrived:Function, func_onConnectionError:Function, + func_onConnected:Function, func_onError:Function; private var reloadIfNotConnected:Boolean = false ; @@ -97,10 +98,9 @@ return this ; } - public function onConnected2(onError:Function):WebServiceCaller + public function onConnected2(onConnectedFunc:Function):WebServiceCaller { - func_onConnectionError = onError; - func_onError = onError; + func_onConnected = onConnectedFunc; return this ; } @@ -225,7 +225,7 @@ myWebService.CanselThisToken(myToken); } - private function onConnected() + private function onConnected():void { SaffronLogger.log("connected"); //TODO: implement function @@ -262,11 +262,12 @@ connected = true ; cansel(); generateDataAndDispatchEvent(e.pureData); - if(func_onDataRetrived!=null) + /*if(func_onDataRetrived!=null) { func_onDataRetrived(); - } + }*/ this.dispatchEvent(new Event(Event.CONNECT)); + if(func_onConnected!=null)func_onConnected(); } } diff --git a/wrokersJob/WorkerFunctions.as b/wrokersJob/WorkerFunctions.as index c694290b..1d5f88fc 100644 --- a/wrokersJob/WorkerFunctions.as +++ b/wrokersJob/WorkerFunctions.as @@ -93,7 +93,7 @@ else SaffronLogger.log(moreHints); } - var workerBytes:ByteArray = FileManager.loadFile(workerTarget); + var workerBytes:ByteArray = FileManager.loadFile(workerTarget,false,null,false); SaffronLogger.log("workerTarget.exists : "+workerTarget.exists); SaffronLogger.log("Capabilities.isDebugger : "+Capabilities.isDebugger); @@ -118,7 +118,7 @@ var receiverChannel:MessageChannel = worker.createMessageChannel(Worker.current); receiverChannel.addEventListener(Event.CHANNEL_MESSAGE, handlecustomeChannel); //receiverChannel.addEventListener(Event.DEACTIVATE, workerDeactivated); - receiverChannel.addEventListener(Event.CHANNEL_STATE, function(e:Event){SaffronLogger.log(e)}); + receiverChannel.addEventListener(Event.CHANNEL_STATE, function(e:Event):void{SaffronLogger.log(e)}); worker.setSharedProperty("receiverChannel_fromMainProject", receiverChannel); worker.start(); @@ -166,7 +166,7 @@ } /**Worker state*/ - private static function workerStateHandler(e:Event) { + private static function workerStateHandler(e:Event):void { var worker:Worker = e.currentTarget as Worker ; SaffronLogger.log("Worker State : "+worker.state); if(worker.state == WorkerState.RUNNING)