Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Text (SMS) Ticker in single frame flash

New Here ,
Jun 17, 2017 Jun 17, 2017

Hello

The presentation has 1 frame and some actionscripts running to display Text (and also a clock, sponsor logo's and the line-up)

I have managed to make a basic ticker that pulls in Text (SMS) messages that are saved in an XML file that is being fed new records while the presentation is running (on a ledwall on a music festival)

The XML is synced via dropbox

The AS is running in a 1 frame movie clip that is used on the 1 frame scene

I'm hoping to improve the SMS functionality

It is working somewhat but it is not very intelligent.

it acts the same if there are a lot of messages waiting to be displayed or if there are very few

Also there will be a period when the ticker is finnished that the screen will show no messages until a new list is created and the ticker is restarted

Do you guys have an idea how to improve the code?

(if this is the wrong approach to do this, we can also start from scratch again) I'm quite new to AS

Thank you very much

The Action script for the ticker is this:

import flash.net.URLLoader;

import flash.events.Event;

import flash.utils.Timer;

import flash.events.TimerEvent;

import flash.display.MovieClip;

import flash.text.TextField;

var myXML:XML;

var myLoader:URLLoader = new URLLoader();

var updateSliderBool:Boolean = false;

var displayArray:Array = new Array();

var mcSlider:MovieClip = new MovieClip();

this.stage.addChild(mcSlider);

mcSlider.x=stage.stageWidth;

mcSlider.y = 300;

var myFont = new Font1();

var myFormat:TextFormat = new TextFormat();

myFormat.size = 24;

myFormat.font = myFont.fontName;

var timer:Timer = new Timer(60000);

timer.addEventListener(TimerEvent.TIMER, timerHandler);

timer.start();

myLoader.addEventListener(Event.COMPLETE, processXML);

myLoader.load(new URLRequest("src/SMS/Dropbox/Apps/SMSBackupRestore/sms.xml"));

var timerSlider:Timer = new Timer(20);

timerSlider.addEventListener(TimerEvent.TIMER, timerSliderHandler);

timerSlider.start();

var k:int = 0 //last position previous load

var j:int = 0 //last possition this load

var i:int = 0 //counter

function processXML(e:Event):void{

myXML = new XML(e.target.data);

j = (myXML.sms.length() - 1)

trace('SMS XML loaded - length = ' + j);

timerHandler();

updateSlider();

myLoader.removeEventListener(Event.COMPLETE, processXML);

myLoader.addEventListener(Event.COMPLETE, processSecondXML);

}

function processSecondXML(e:Event):void{

myXML = new XML(e.target.data);

k = j

j = (myXML.sms.length() - 1)

trace("SMS XML reloaded length = " + (j+1) + ' new = ' + (j-k));

}

function timerHandler(e:TimerEvent= null):void{

myLoader.load(new URLRequest("src/SMS/Dropbox/Apps/SMSBackupRestore/sms.xml"));

displayArray = new Array();

if (j>k){

for(i =(k); i<(j);i++){

// nieuwe berichten opladen

displayArray.push(myXML.sms.@body);

}}

if ((j-k)<5){

for(i =(j-10); i<(k);i++){

// opvullen tot 10 berichten

if (i>=0){

displayArray.push(myXML.sms.@body);

}}}

trace(displayArray);

updateSliderBool = true;

//updateSlider();

}

function updateSlider():void{

var xPos = 0;

var marge = 60;

mcSlider.x=stage.stageWidth;

trace("SMS displayArray: "+ displayArray);

//trace(mcSlider.width);

for(var i =0;i<displayArray.length;i++){

var myTextField:TextField = new TextField();

myTextField.defaultTextFormat = myFormat;

myTextField.textColor = 0xffffff;

myTextField.text=displayArray;

myTextField.embedFonts=true;

myTextField.autoSize = 'left';

mcSlider.addChild(myTextField);

myTextField.x = xPos;

xPos+=myTextField.width+marge;

}

}

function timerSliderHandler(e:TimerEvent):void{

mcSlider.x-=1;

//trace(-mcSlider.width);

//trace(mcSlider.x);

if(mcSlider.x<-mcSlider.width){

mcSlider.x = stage.stageWidth;

if(updateSliderBool == true){

resetMcSlider();

//mcSlider.removeChildren(0,mcSlider.numChildren);

updateSlider();

updateSliderBool=false;

}

}

}

function resetMcSlider():void{

this.stage.removeChild(mcSlider);

mcSlider = new MovieClip();

this.stage.addChild(mcSlider);

mcSlider.x=stage.stageWidth;

mcSlider.y = 300;

}

TOPICS
ActionScript
427
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2017 Jun 17, 2017
LATEST

how do you want to 'improve' it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines