0 Replies - 8167 Views - Last Post: 04 January 2013 - 10:03 AM

#1 Fatt101  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 18-December 12

Creating Document Classes and AIR publishing questions

Posted 04 January 2013 - 10:03 AM

Basically, i am working on an application that will eventually be deployed to the desktop as an AIR application.

I am wanting to create an Analogue clock and Digital clock with a button that toggles the display between either one when pressed. As well as this, i will be wanting to display the Date below, i am having a number of issues however.

I have the code sorted for three of the four components, i have not attempted to figure out the button thus far as i would be more than happy to have the digital clock, analogue clock and date all being displayed on a drag and drop desktop application first. When i say i have it sorted, i have a fully working analogue clock which i have managed to display on the desktop through air on its lonesome, however, i did not include the drag and drop function. For the digital clock and date components i am not sure how to configure them into document classes. The main issue i am having is i do not know if you can reference a dynamic text box within a movie clip to a document class.

This is the code to show the date

{
var currentTime:Date = new Date();
var month:Array = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var dayOfWeek:Array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
date_text.text = dayOfWeek[currentTime.getDay()] + " " + currentTime.getDate() + " " + month[currentTime.getMonth()] + " " + currentTime.getFullYear();
}


I have put the actionscript frame inside the movie clip file, and i have given both the movie clip, and the dynamic text box within the movie clip the instance name "date_text".
Basically, i am just struggling in how to put this code into a working document class, since the digital clock and date functions are both, some what similar, i feel the solution to one will more than likely lead to me discovering the solution for the other.

The other problem i am having, i do not know how i will display all of the components on one air application. I am assuming, that you create one other document class file which links the other four together? i have tried to do this by just linking a new FLA file with the analogue clock, but it does not work. The code for that is below.

package
{
	import flash.events.Event;
	import flash.display.MovieClip;
	
	public class time1 extends MovieClip
	{
		
		public var now:Date;
		public function time1()
		{
			// Update screen every frame
			addEventListener(Event.ENTER_FRAME,enterFrameHandler);
		}
		// Event Handling:
		
		function enterFrameHandler(event:Event):void
		{
			now = new Date();
			
			// Rotate clock hands
			hourHand_mc.rotation = now.getHours()*30+(now.getMinutes()/2);
			minuteHand_mc.rotation = now.getMinutes()*6+(now.getSeconds()/10);
			secondHand_mc.rotation = now.getSeconds()*6;
		}
	}
}


That is the original clock document class (3 Movie clips for the moving hands, and the clock face is a graphic, which i may have to reference somehow below)?

package 
{

	import flash.display.MovieClip;


	public class main extends MovieClip
	{
		public var hourHand_mc:time1;
		public var minuteHand_mc:time1;
		public var secondHand_mc:time1;
		


		public function main()
		{
			hourHand_mc = new SecondHand();
			addChild(mySecondHand);
			hourHand_mc.x = 75;
			hourHand_mc.y = 75;
			minuteHand_mc = new SecondHand();
			addChild(mySecondHand);
			minuteHand_mc.x = 75;
			minuteHand_mc.y = 75;
			secondHand_mc = new SecondHand();
			addChild(mySecondHand);
			secondHand.x = 75;
			secondHand.y = 75;
		}
	}

}

This is my attempt at creating the main document class in a seperate FLA file to attempt to load the analogue clock, and later on the Digital Clock, Date Function and Toggle Display button in the same AIR application.

Any help on this is much appreciated, i have been reading up a lot on it through tutorials and the like, but i can't seem to fully grasp it.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1