From 86cc44152f830ae3a59ef6bd1e9057e0494cca37 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sun, 3 Oct 2021 10:07:16 +0330 Subject: [PATCH 01/19] ASPack and sample project link added. --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7b181bc..3423084 100644 --- a/README.md +++ b/README.md @@ -13,20 +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 -• Download our ASPack libraries to. you need these libraries to be able to use all features on SaffronCode. -• 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 From 8d1ebb0a954d640ba1c35bd8113d5cad62015cd6 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sat, 9 Oct 2021 08:56:31 +0330 Subject: [PATCH 02/19] Sound volume auto change --- appManager/mains/App.as | 4 ++++ contents/soundControll/ContentSoundManager.as | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/appManager/mains/App.as b/appManager/mains/App.as index ff90718..b26a008 100644 --- a/appManager/mains/App.as +++ b/appManager/mains/App.as @@ -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/contents/soundControll/ContentSoundManager.as b/contents/soundControll/ContentSoundManager.as index 15d6ae8..283ca54 100644 --- a/contents/soundControll/ContentSoundManager.as +++ b/contents/soundControll/ContentSoundManager.as @@ -97,6 +97,11 @@ package contents.soundControll { SoundPlayer.volumeContril(currentSoundId,1); } + + public static function changeVolume(volume:Number):void + { + SoundPlayer.volumeContril(currentSoundId,volume); + } /**This will change the current playing music ( not tested yet )*/ public static function changeMainMusic(musicURL:String='',volume:Number=1):void From 38e47cdec8ecdb1fad07567ea71adb7170a9382c Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sat, 9 Oct 2021 08:56:36 +0330 Subject: [PATCH 03/19] Create RandomFrameClipPlay.as --- movieClipAssist/RandomFrameClipPlay.as | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 movieClipAssist/RandomFrameClipPlay.as diff --git a/movieClipAssist/RandomFrameClipPlay.as b/movieClipAssist/RandomFrameClipPlay.as new file mode 100644 index 0000000..280a929 --- /dev/null +++ b/movieClipAssist/RandomFrameClipPlay.as @@ -0,0 +1,16 @@ + +package movieClipAssist +//movieClipAssist.RandomFrameClipPlay +{ + import flash.display.MovieClip; + import contents.alert.Alert; + + public class RandomFrameClipPlay extends MovieClip + { + public function RandomFrameClipPlay() + { + super(); + this.gotoAndPlay(Math.floor(Math.random()*this.totalFrames+1)); + } + } +} \ No newline at end of file From 7e0fdcb828b52592cb138d5938030f9e2e3f4ed6 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sat, 9 Oct 2021 08:56:40 +0330 Subject: [PATCH 04/19] Update DistriqtAudioPlayer.as --- nativeClasses/player/DistriqtAudioPlayer.as | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nativeClasses/player/DistriqtAudioPlayer.as b/nativeClasses/player/DistriqtAudioPlayer.as index 08142e0..33eca6e 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) From d3042455d79aa2bc46a5f49a0ac1bb00f15239c1 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sun, 10 Oct 2021 09:19:58 +0330 Subject: [PATCH 05/19] Create StopAtEnd.as --- movieClipAssist/StopAtEnd.as | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 movieClipAssist/StopAtEnd.as diff --git a/movieClipAssist/StopAtEnd.as b/movieClipAssist/StopAtEnd.as new file mode 100644 index 0000000..0afa704 --- /dev/null +++ b/movieClipAssist/StopAtEnd.as @@ -0,0 +1,20 @@ + +package movieClipAssist +//movieClipAssist.StopAtEnd +{ + import flash.display.MovieClip; + + public class StopAtEnd extends MovieClip + { + public function StopAtEnd() + { + super(); + this.addFrameScript(this.totalFrames-1,stopMe); + } + + private function stopMe():void + { + this.stop(); + } + } +} \ No newline at end of file From 910d4dc5bfc77c1ede163e0d7b4694cfbed91f63 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sun, 17 Oct 2021 21:01:02 +0330 Subject: [PATCH 06/19] On popmuenu opened trigger --- popForm/PopMenu.as | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/popForm/PopMenu.as b/popForm/PopMenu.as index 4fa5fe7..5bcfe3c 100644 --- a/popForm/PopMenu.as +++ b/popForm/PopMenu.as @@ -34,6 +34,8 @@ public class PopMenu extends MovieClip { private static const CANCEL_ELEMENT_NAME:String = "cancel_mc" ; + + private static var onPopUpOpenned:Function ; /**main object of class*/ private static var ME:PopMenu; @@ -101,6 +103,11 @@ { backButtonName = backString ; } + + public static function onOpen(func:Function):void + { + onPopUpOpenned = func ; + } /**Activate the static cansel button*/ public static function staticCanselEnabled(CancelNames:Array):void @@ -383,6 +390,7 @@ /**pop the pop menu up*/ public function popUp2(title:String='' , type:PopMenuTypes=null , content:PopMenuContent=null,closeOnTime:int=0,onButtonSelects:Function=null,onClosedByTimer:Function=null,onClose:Function=null):void { + if(onPopUpOpenned!=null)onPopUpOpenned(); SliderManager.hide(); cashedContents = content ; From e891f8ec814a2300ad9175181a80257b3df19108 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sun, 17 Oct 2021 23:26:43 +0330 Subject: [PATCH 07/19] onChanged added to switch button --- appManager/displayObjects/SwitchButtonAnimated.as | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/appManager/displayObjects/SwitchButtonAnimated.as b/appManager/displayObjects/SwitchButtonAnimated.as index 1984c8d..808100c 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) From 526dc9942aa9482760554d3a30f626c01a23195a Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sun, 17 Oct 2021 23:27:14 +0330 Subject: [PATCH 08/19] ContentSoundManager upgraded --- contents/soundControll/ContentSoundManager.as | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/contents/soundControll/ContentSoundManager.as b/contents/soundControll/ContentSoundManager.as index 283ca54..75b9f97 100644 --- a/contents/soundControll/ContentSoundManager.as +++ b/contents/soundControll/ContentSoundManager.as @@ -21,6 +21,8 @@ package contents.soundControll private static var lastPlayingMusic:String ; private static var lastMusicVolume:Number ; + + private static var muted:Boolean = false ; /**2 sound id to swap musics smoothly*/ private static var currentSoundId:uint, @@ -59,7 +61,7 @@ package contents.soundControll var soundPose:Number = SoundPlayer.getPlayedPrecent(currentSoundId); pauseMusic(); SoundMixer.stopAll(); - SoundPlayer.addSound(lastPlayingMusic,currentSoundId,true,lastMusicVolume); + SoundPlayer.addSound(lastPlayingMusic,currentSoundId,true,muted?0:lastMusicVolume); if(firstSoundPlaying) { startMusic(soundPose); @@ -75,10 +77,11 @@ package contents.soundControll else { SaffronLogger.log("soundPose : "+soundPlayingFrom); - SoundPlayer.play(currentSoundId,true,true,soundPlayingFrom); } + SoundPlayer.play(currentSoundId,true,true,soundPlayingFrom); lastMusicState.data.state = true ; lastMusicState.flush(); + if(muted)SoundPlayer.volumeContril(currentSoundId,0); } public static function pauseMusic():void @@ -90,17 +93,19 @@ package contents.soundControll public static function muteMusic():void { + muted = true ; SoundPlayer.volumeContril(currentSoundId,0); } public static function unMuteMusit():void { + muted = false SoundPlayer.volumeContril(currentSoundId,1); } public static function changeVolume(volume:Number):void { - SoundPlayer.volumeContril(currentSoundId,volume); + SoundPlayer.volumeContril(currentSoundId,muted?0:volume); } /**This will change the current playing music ( not tested yet )*/ @@ -115,7 +120,7 @@ package contents.soundControll volume = Contents.homePage.musicVolume ; } lastMusicVolume = volume ; - if(musicURL=='' || lastPlayingMusic == musicURL) + if(muted==false && (musicURL=='' || lastPlayingMusic == musicURL)) { SaffronLogger.log("Music is duplicated on ContentSoundManager.changeMainMusic : "+musicURL); SoundPlayer.volumeContril(currentSoundId,volume); @@ -128,13 +133,15 @@ package contents.soundControll SaffronLogger.log("Pause the sound : "+currentSoundId); SoundPlayer.pause(currentSoundId); SaffronLogger.log("Add the sound : "+otherSoundId); - SoundPlayer.addSound(musicURL,otherSoundId,true,volume); + SoundPlayer.addSound(musicURL,otherSoundId,true,muted?0:volume); if(lastPlayingMusic==null || musicWasPlaying) { SaffronLogger.log("lastPlayingMusic : "+lastPlayingMusic); SaffronLogger.log("musicWasPlaying : "+musicWasPlaying); SoundPlayer.play(otherSoundId); + } + if(muted)SoundPlayer.volumeContril(currentSoundId,0); lastPlayingMusic = musicURL ; From be481091d546d2a8f7b989cafc57351ea6f8fac4 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Mon, 1 Nov 2021 13:26:30 +0330 Subject: [PATCH 09/19] Title manager upgradedd --- appManager/animatedPages/pageManager/TitleManager.as | 1 + 1 file changed, 1 insertion(+) diff --git a/appManager/animatedPages/pageManager/TitleManager.as b/appManager/animatedPages/pageManager/TitleManager.as index 8fd115c..2ee6d46 100644 --- a/appManager/animatedPages/pageManager/TitleManager.as +++ b/appManager/animatedPages/pageManager/TitleManager.as @@ -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) From 7c116af960698d8b64ee0005965b89271c1e7cdb Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Mon, 1 Nov 2021 13:26:47 +0330 Subject: [PATCH 10/19] PageControll event updated --- appManager/event/PageControllEvent.as | 5 ++- appManager/mains/AppWithContent.as | 44 ++++++++++++++------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/appManager/event/PageControllEvent.as b/appManager/event/PageControllEvent.as index c6b3d29..1bb4af5 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/AppWithContent.as b/appManager/mains/AppWithContent.as index 4064b30..d421140 100644 --- a/appManager/mains/AppWithContent.as +++ b/appManager/mains/AppWithContent.as @@ -372,7 +372,7 @@ } prventedPageWasLastPage = false ; - if(preventedEventCash!=null) + if(preventedEventCash!=null && !event.ignorelastCalledPage) { SaffronLogger.log("Prevented page event is released"); managePages(preventedEventCash); @@ -486,19 +486,20 @@ /**Save teh page ID to Analytic server */ private function logPageChange(pageId:String):void { - 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); + //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); } @@ -521,14 +522,15 @@ private function controlCurrentVersion(useOfflineVersion:Boolean=false):void { - 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}) ; + //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); + // VersionController.controllVersion(currentVersionIsOk,stopThisVersion,versionRequest,DevicePrefrence.appVersion,true,useOfflineVersion); } /**The application version is ok*/ From efcac2dd755797fd534337b78d3dee1a27d9a8b2 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Mon, 1 Nov 2021 13:27:24 +0330 Subject: [PATCH 11/19] Callback functions improved on Hins --- popForm/Hints.as | 4 +++- popForm/PopField.as | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/popForm/Hints.as b/popForm/Hints.as index 216a4e3..91b7488 100644 --- a/popForm/Hints.as +++ b/popForm/Hints.as @@ -177,7 +177,9 @@ { if(_onClose!=null) { - _onClose.call(); + var cahsedhCloseFunc:Function = _onClose ; + _onClose = null ; + cahsedhCloseFunc(); } } diff --git a/popForm/PopField.as b/popForm/PopField.as index 3be2b54..c952308 100644 --- a/popForm/PopField.as +++ b/popForm/PopField.as @@ -234,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 @@ -505,7 +506,10 @@ private function callOnEditedFunc():void { clearTimeout(onEditeFuncCalDelay); - onEditeFuncCalDelay = setTimeout(callOnEditedNow,100); + if(onEditedFunc!=null) + { + onEditeFuncCalDelay = setTimeout(callOnEditedNow,100); + } } private function callOnEditedNow():void { From 67cc208bf0bd1b34301895d1deb7560dc64279f9 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Thu, 18 Nov 2021 20:32:32 +0330 Subject: [PATCH 12/19] Update Anim_alpha_shine.as --- animation/Anim_alpha_shine.as | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/animation/Anim_alpha_shine.as b/animation/Anim_alpha_shine.as index 7d49a6e..81efa63 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; } From 7b17304b9eceadb5bc1f55cd9fbacf6a2c6b5dac Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Fri, 19 Nov 2021 14:03:56 +0330 Subject: [PATCH 13/19] No network emulator on RestDoa --- restDoaService/RestDoaServiceCaller.as | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/restDoaService/RestDoaServiceCaller.as b/restDoaService/RestDoaServiceCaller.as index a8620cc..883b0f1 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 ; @@ -583,7 +589,16 @@ //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(); } From a220a8e9c0f84dd1f7677ec77e8a7592d9eb07f4 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Fri, 10 Dec 2021 17:52:44 +0330 Subject: [PATCH 14/19] UDP message send and receive function --- netManager/UDPManager.as | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 netManager/UDPManager.as diff --git a/netManager/UDPManager.as b/netManager/UDPManager.as new file mode 100644 index 0000000..f4c963b --- /dev/null +++ b/netManager/UDPManager.as @@ -0,0 +1,56 @@ +package netManager +{ + import flash.net.DatagramSocket; + import flash.utils.ByteArray; + import flash.events.DatagramSocketDataEvent; + + public class UDPManager + { + private static var myUDP:DatagramSocket ; + + private static var onReceiveFunction:Function ; + + 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"); + var message:String = e.data.toString(); + if(onReceiveFunction!=null && onReceiveFunction.length>0) + onReceiveFunction(message) + } + + private static function getMessageOnPort(onRespond:Function,myPort:uint=43243):void + { + trace("myUDP.connected : "+myUDP.connected); + trace("myUDP.localPort : " +myUDP.localPort); + onReceiveFunction = onRespond ; + if(myUDP.localPort==0 || ( myUDP.localPort!=myPort && myPort!=43243)) + { + if(myUDP.connected) + myUDP.close(); + + myUDP.bind(myPort); + myUDP.receive(); + } + } + + public static function sendMessageTo(message:String,onRespond:Function,targetIp:String,targetPort:uint):void + { + setUp(); + trace("Message sent:"+message); + getMessageOnPort(onRespond); + var data:ByteArray = new ByteArray(); + data.writeUTFBytes(message); + myUDP.send(data,0,0,targetIp,targetPort); + myUDP.receive(); + } + } +} \ No newline at end of file From f06664c558d1ba13d65050024eea0552e114ec4c Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sat, 18 Dec 2021 12:03:36 +0330 Subject: [PATCH 15/19] You can set the local binded port --- netManager/UDPManager.as | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/netManager/UDPManager.as b/netManager/UDPManager.as index f4c963b..c68cf61 100644 --- a/netManager/UDPManager.as +++ b/netManager/UDPManager.as @@ -27,12 +27,12 @@ package netManager onReceiveFunction(message) } - private static function getMessageOnPort(onRespond:Function,myPort:uint=43243):void + private 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 && myPort!=43243)) + if(myUDP.localPort==0 || ( myUDP.localPort!=myPort)) { if(myUDP.connected) myUDP.close(); @@ -42,11 +42,16 @@ package netManager } } - public static function sendMessageTo(message:String,onRespond:Function,targetIp:String,targetPort:uint):void + 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); + getMessageOnPort(onRespond,localPort); var data:ByteArray = new ByteArray(); data.writeUTFBytes(message); myUDP.send(data,0,0,targetIp,targetPort); From 21ec0982300c324b27ae28bcbb6e03dc9b354f1f Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sat, 18 Dec 2021 12:09:11 +0330 Subject: [PATCH 16/19] Update UDPManager.as --- netManager/UDPManager.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netManager/UDPManager.as b/netManager/UDPManager.as index c68cf61..6f209ad 100644 --- a/netManager/UDPManager.as +++ b/netManager/UDPManager.as @@ -27,7 +27,7 @@ package netManager onReceiveFunction(message) } - private static function getMessageOnPort(onRespond:Function,myPort:uint):void + public static function getMessageOnPort(onRespond:Function,myPort:uint):void { trace("myUDP.connected : "+myUDP.connected); trace("myUDP.localPort : " +myUDP.localPort); From b200c8bdcd5ba502acac24818a4459087c461c6e Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Sat, 25 Dec 2021 08:25:36 +0330 Subject: [PATCH 17/19] getLastConnectionTimeout() on UDPManager --- netManager/UDPManager.as | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/netManager/UDPManager.as b/netManager/UDPManager.as index 6f209ad..3a5c31c 100644 --- a/netManager/UDPManager.as +++ b/netManager/UDPManager.as @@ -3,6 +3,7 @@ package netManager import flash.net.DatagramSocket; import flash.utils.ByteArray; import flash.events.DatagramSocketDataEvent; + import flash.utils.getTimer; public class UDPManager { @@ -10,6 +11,8 @@ package netManager private static var onReceiveFunction:Function ; + private static var lastMassageDeliveryTime:int ; + private static function setUp():void { if(myUDP==null) @@ -22,6 +25,7 @@ package netManager 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) @@ -57,5 +61,11 @@ package netManager 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 From 7182f1132a1b7c9612c2286f03990cb7e686fc85 Mon Sep 17 00:00:00 2001 From: "Mohammad E. Sepehr" Date: Tue, 26 Dec 2023 01:49:17 -0800 Subject: [PATCH 18/19] some warnings removed --- dataManager/SavedDatas2.as | 10 +++++----- drawPad/Paper.as | 14 +++++++------- notification/NotificationEvent.as | 4 ++-- notification/NotificationManager.as | 2 +- photoEditor/EditorPencil.as | 4 ++-- photoEditor/PhotoEdit.as | 4 ++-- photoEditor/StampList.as | 4 ++-- restDoaService/RestDoaServiceCaller.as | 4 ++-- tabMenu/TabMenuManager.as | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/dataManager/SavedDatas2.as b/dataManager/SavedDatas2.as index eb79afa..3823db5 100644 --- a/dataManager/SavedDatas2.as +++ b/dataManager/SavedDatas2.as @@ -67,7 +67,7 @@ } /**Change the table name for this special user*/ - public static function setTableName(tableNameTitle:String='') + public static function setTableName(tableNameTitle:String=''):void { tableName = tableBaseName+tableNameTitle; SaffronLogger.log("new table name is : "+tableName); @@ -78,7 +78,7 @@ - public static function setUp(checkTable:Boolean = false) + public static function setUp(checkTable:Boolean = false):void { var needToUpdate:Boolean = false ; if(sql == null) @@ -256,7 +256,7 @@ asyncQuery.execute(); } - private static function continueSaving(e:*=null) + private static function continueSaving(e:*=null):void { var id:String = asyncQue[0].id ; var data:* = asyncQue[0].data ; @@ -283,7 +283,7 @@ } /**load the value if the value is new on data base*/ - public static function loadIfNewer(id,lastDate:Date=null):* + public static function loadIfNewer(id:*,lastDate:Date=null):* { return load(id,lastDate); } @@ -298,7 +298,7 @@ var l:uint = asyncQue.length ; var l2:uint = asyncSaved.length ; - for(var i = l-1 ; i>=0 ; i--) + for(var i:* = l-1 ; i>=0 ; i--) { if(asyncQue[i].id == id) { diff --git a/drawPad/Paper.as b/drawPad/Paper.as index 5bd84d4..1041336 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 = imageHistory.splice(imageIndex+1,imageHistory.length-imageIndex); - for(var i = 0 ; i Date: Mon, 12 Feb 2024 10:03:11 +0330 Subject: [PATCH 19/19] Don't need to encode logs any more. this is an open source SDK for public uses now --- SaffronLogger.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SaffronLogger.as b/SaffronLogger.as index 02ece41..7a326dc 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); } }