Is it possible to load a URL on stage?
Hi,
I'm using Flash CC-Action Script 3, is it possible to load a URL onto the stage?
Hi,
I'm using Flash CC-Action Script 3, is it possible to load a URL onto the stage?
Thanks. I think our IT department will handle it since they do html/java/and
all that stuff except for action script/flash. I am a little desperate
though. I need to have this at least display a working clock for know and
the phone list, which will display fine once I get to it. Can you be so kind
and look at my horrible action script and help me get the clock to work
continuously and show minutes under 10 with a "0"? I just need to have
something to show for our Annual Management meeting.
Thank you sincerely for your time.
Code:
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.Font;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.text.*;
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
import flash.filters.BlurFilter;
import flash.display.Bitmap;
import flash.display.Loader;
import flash.net.URLRequest;
var link:URLRequest = new URLRequest("http://simplegreen.com/");
//ADD CONTAINERS
var containerStage:Sprite = new Sprite();
containerStage.tabChildren = false;
stage.addChild (containerStage);
//DATE TIMER
var my_date:Date = new Date();
var my_timer:Timer = new Timer(1000);//create a new timer that ticks every
second
my_timer.addEventListener(TimerEvent.TIMER, onTimer);
my_timer.start();
//MONTH AND DATE
var months:Array = ["Jan", "Feb", "Mar", "Apr", "May", "June", "Jul", "Aug",
"Sept", "Oct", "Nov", "Dec"];
var days:Array = ["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri"];
var todayIs = (days[my_date.day] + "," + " " + months[my_date.month] +" " +
my_date.date + " " + my_date.fullYear);
trace(days[my_date.day] + "," + " " + months[my_date.month] +" " +
my_date.date + " " + my_date.fullYear);
//Text Loader
var textLoader:URLLoader = new URLLoader();
textLoader.addEventListener(Event.COMPLETE, textLoaded);
textLoader.load(new URLRequest("assets/phoneList.txt"));
var ampm:String = new String();
var zero:String = new String();
if (my_date.hours<12) {ampm = "AM";
}
else{
ampm = "PM";
}
while(my_date.hours > 12){my_date.hours = my_date.hours - 12;
}
if(my_date.minutes < 10){zero = "0" + my_date.minutes;
}
else{
my_date.minutes;
}
function onTimer(e:TimerEvent):void {
//my_date = new Date();
trace(my_date.hours + ":" + my_date.minutes);
}
var myDateTextBox:TextField = new TextField;
myDateTextBox = new TextField();
// myDateTextBox = todayIs;
var dateStyle:TextFormat = new TextFormat;
dateStyle.color = 0xFFFFFF;
dateStyle.size = 48;
dateStyle.font = "myriadMm";
dateStyle.align = "left";
var myTimeTextBox:TextField = new TextField;
myTimeTextBox = new TextField();
myDateTextBox.text = String(days[my_date.day] + "," + " " +
months[my_date.month] +" " + my_date.date + " " + my_date.fullYear);
myDateTextBox.width = 600;
myDateTextBox.x = 70;
myDateTextBox.y = 70;
myDateTextBox.setTextFormat(dateStyle);
//Add it to the stage;
containerStage.addChild(myDateTextBox);
myTimeTextBox.text = String(my_date.hours + ":" + my_date.minutes + " " +
ampm);
myTimeTextBox.width = 600;
myTimeTextBox.x = 70;
myTimeTextBox.y = 117;
myTimeTextBox.setTextFormat(dateStyle);
//Add it to the stage;
containerStage.addChild(myTimeTextBox);
//Event Listeners
phone.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame);
function fl_ClickToGoToAndPlayFromFrame(event:MouseEvent):void
{
trace("directory ready");
}
simpleGreen.addEventListener(MouseEvent.CLICK,
fl_ClickToGoToAndPlayFromFrame_2);
function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void
{
navigateToURL(link, "_self");
}
videoDirectory.addEventListener(MouseEvent.CLICK,
fl_ClickToGoToAndPlayFromFrame_3);
function fl_ClickToGoToAndPlayFromFrame_3(event:MouseEvent):void
{
trace("Video Player is Ready");
}
function textLoaded(evt:Event):void
{
info_txt.htmlText = textLoader.data;
}
With warmest regards,
Mary Crotteau
Graphic Design Specialist
Sunshine Makers, Inc./Simple Green
use:
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.Font;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.text.*;
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
import flash.filters.BlurFilter;
import flash.display.Bitmap;
import flash.display.Loader;
import flash.net.URLRequest;
var link: URLRequest = new URLRequest("http://simplegreen.com/");
//ADD CONTAINERS
var containerStage: Sprite = new Sprite();
containerStage.tabChildren = false;
stage.addChild(containerStage);
//DATE TIMER
var my_date: Date;
var my_timer: Timer = new Timer(1000); //create a new timer that ticks everysecond
var dateStyle: TextFormat = new TextFormat;
dateStyle.color = 0xFFFFFF;
dateStyle.size = 48;
dateStyle.font = "myriadMm";
dateStyle.align = "left";
var myDateTextBox: TextField = new TextField;
myDateTextBox = new TextField();
myDateTextBox.width = 600;
myDateTextBox.x = 70;
myDateTextBox.y = 70;
myDateTextBox.setTextFormat(dateStyle);
//Add it to the stage;
containerStage.addChild(myDateTextBox);
var myTimeTextBox: TextField = new TextField;
myTimeTextBox = new TextField();
myTimeTextBox.width = 600;
myTimeTextBox.x = 70;
myTimeTextBox.y = 117;
myTimeTextBox.setTextFormat(dateStyle);
//Add it to the stage;
containerStage.addChild(myTimeTextBox);
my_timer.addEventListener(TimerEvent.TIMER, onTimer);
my_timer.start();
//MONTH AND DATE
var months: Array = ["Jan", "Feb", "Mar", "Apr", "May", "June", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"];
var days: Array = ["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri"];
//Text Loader
var textLoader: URLLoader = new URLLoader();
textLoader.addEventListener(Event.COMPLETE, textLoaded);
textLoader.load(new URLRequest("assets/phoneList.txt"));
var ampm: String = new String();
function onTimer(e: TimerEvent): void {
my_date = new Date();
myDateTextBox.text = days[my_date.day] + "," + " " + months[my_date.month] + " " + formatF(my_date.date) + " " + my_date.fullYear;
if (my_date.hours < 12) {
ampm = "AM";
} else {
ampm = "PM";
}
var hours:int = my_date.hours;
if(hours > 12) {
hours-=12;
}
myTimeTextBox.text = formatF(hours) + ":" + formatF(my_date.minutes) + " " + ampm;
}
function formatF(n:int):String{
var s:String = n.toString();
while(s.length<2){
s="0"+s;
}
return s;
}
//Event Listeners
phone.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame);
function fl_ClickToGoToAndPlayFromFrame(event: MouseEvent): void {
trace("directory ready");
}
simpleGreen.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);
function fl_ClickToGoToAndPlayFromFrame_2(event: MouseEvent): void {
navigateToURL(link, "_self");
}
videoDirectory.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_3);
function fl_ClickToGoToAndPlayFromFrame_3(event: MouseEvent): void {
trace("Video Player is Ready");
}
function textLoaded(evt: Event): void {
info_txt.htmlText = textLoader.data;
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.