Problem In Using Package
Thanks in Advance,I am trying to use package to load the xml file and to get the particular ID and text in that file. by sending the values using a function. Am just now learning and may have silly mistakes also. Please anyone help me learning this.Can anyone help me out...This is the script in my package file named xmlfun.as package com{var xmlLoader:URLLoader = new URLLoader();xmlLoader.addEventListener(Event.COMPLETE, loadXML);xmlLoader.load(new URLRequest("../common/en/content.xml"));public class xmlfun(e:Event){ public function xmlfun():void{ XML.ignoreWhitespace = true; var inputxml:XML = new XML(e.target.data); } public function xmlfun1(content_id, no_of_text):void { var content_id:Number; var no_of_text:Number; var asdf:Number=inputxml.content("id"); var qwer:Number=inputxml.content.text.length(); trace(inputxml.content[content_id]); trace(inputxml.content.text[no_of_text]); trace("content id no. is:"+asdf); trace("no. of text in content id:"+qwer); }}}////////////////////////////////////////////////////////Thanks in Advance,Tark Ananth.
KirupaForum > Flash > ActionScript 3.0
Posted on: 11-04-2008, 08:31 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
A Package Of Swf's
hi!
+ i wanna dynamically create a flash presentation
+ this results in several swf's, xml docs and some jpegs which is saved on a server
BUT
+ i wanna fompile/create a package which contains all these files.
+ my goal is to be able to send this as one file by mail so that the reciever dont have to unpack it to execute the presentation. the user simply have to save the file and doubleclick it as it was an .exe file or so.
QUESTION: is there any packing/compiling software out there that behaves as a "folder" or something else that can do what im requesting?
TOYTOTA
^[0-9] Package Name?
Hello, I wasn't able to formulate a good keyword search for this question , so apologies if it's come up a million times before.
Given a&&b where:
a) package names should adopt a "reverse domain" standard e.g.
com.flashkit.utils
b) packages, classes in fact anything can't begin with a number.
What is the standard way to name a package originating from a domain with the lack of foresight to avoid beginning with a number. e.g.
com.4sightlacking.utils
Many thanks.
What Is A Package?
What is a package?
How is a class applied to to objects created in the IDE?
What is the equivelent to a prototype?
Such a simple questions, but I cannot find the answers for the life of me. These are things I've been struggling to figure out since I started playing with Flash 9 AS3.0 Preview.
Much of the documentation and advice concerning AS3.0 seems to assume an intimate understanding of programming concepts. I am not a programmer, I learned AS1.0 and to some extent 2.0 only because it is so simple and straight forward. I'm going to need some serious crash courses to grasp 3.0! Any advice there would be great.
Thanks
Package & Co
Hi there
Here is the case: I got two files 1-PV3D.fla and PV3D.as
In PV3D.as there is a package declared like that:
ActionScript Code:
package{
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.render.BasicRenderEngine;
public class PV3D extends Sprite
{
private var viewport: Viewport3D;
private var renderer: BasicRenderEngine;
public function PV3D():void
{
blablabla...
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void
{
primitive.rotationY += 2;
renderer.renderScene(scene, camera, viewport);
}
}
}
}
}
What is weird is that in the 1-PV3D.fla files there is absolutely nothing (no code or movie clip) but when I compile, it works. It calls the package and make the 3d plane.
What is the hell of that ?
Use Package
hi , how to use this package ?!! :
package
{
import org.papervision3d.view.BasicView;
import flash.events.Event;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.core.geom.Particles;
import org.papervision3d.core.geom.renderables.Particle;
import org.papervision3d.materials.special.MovieAssetPart icleMaterial;
/**
* @author Seb Lee-Delisle
*/
public class MovieAssetParticleTest extends BasicView
{
public var particleContainerisplayObject3D;
private var particles : Array;
public function MovieAssetParticleTest()
{
super(stage.stageWidth, stage.stageHeight, false, true);
init();
}
private function init():void
{
particleContainer = new DisplayObject3D("Particle Container");
particles = new Array();
for(var i:int = 0; i<400; i++)
{
var spm:MovieAssetParticleMaterial = new MovieAssetParticleMaterial("Sphere",true);
spm.interactive = true;
spm.smooth = true;
var particles3D:Particles = new Particles("ParticleContainer#"+i);
var p:Particle = new Particle(spm,2,600,0,0);
particles3D.addParticle(p);
particles3D.addEventListener(InteractiveScene3DEve nt.OBJECT_OVER, particleOver);
particles3D.rotationY = Math.random()*360;
particles3D.rotationZ = Math.random()*180;
particles3D.extra = {spin: 0};
particleContainer.addChild(particles3D);
particles.push(particles3D);
}
scene.addChild(particleContainer);
singleRender();
addEventListener(Event.ENTER_FRAME, frameLoop);
}
private function particleOver(e : InteractiveScene3DEvent) : void
{
e.displayObject3D.extra["spin"] = 10;
}
function frameLoop(e:Event): void
{
particleContainer.rotationY+=((stage.stageWidth/2)-mouseX)/200;
particleContainer.rotationX+=((stage.stageHeight/2)-mouseY)/200;
var drag:Number = 0.99;
for(var i:int=0; i<particles .length; i++)
{
var p:Particles = particles[i];
var spin:Number = p.extra["spin"];
if(spin>0.1)
{
p.extra["spin"]*=drag;
p.rotationY+=spin;
}
else
{
p.extra["spin"] = 0;
}
}
singleRender();
}
Package SWF's Into An Exe
OK,
First off...thanks for all the help I've received on this board. Awesome. Much appreciated.
Of course, now I have another question. I've recently created a pretty huge site, which is up and running, and now I have to make that same content available for download as an EXE file. I've created a projector file from my main SWF, and when the EXE is in the same folder as the many other SWFs in the project, it works. The external SWFs load into the main one. Great. But, when I make the EXE available for download, obviously, the other files are not being downloaded, so only the main SWF is viewable. No content is loaded in. How can I package the EXE so that all of the files are included, and everything plays correctly with just the EXE- separate from the SWFs. Any help is much appreciated as usual.
Matt
Best Graphics Package?
Sooo many to choose from....
I am mainly after something to draw and export graphics into flash with, as flash seems a bit weak. What would you all recommend? Fireworks, Freehand, Photoshop, Quark? Do they all have nice eye candy effects, do animations etc...?
I've not really used any a great deal so want to start with something that will do for most things.
Any helps good
Lev
Which Graphics Package
Hi,
Which graphics package would you guys recommend to create graphics in to use with Flash. I've seen some really nice graphics used in Flash which were obviously created in another package.
thank you for for any help.
Lisa
The Whole Sweet Package
Okay, I have always been a person that was very intuitive and outspoken but now in a world no longer seperated by distance I have decided to make a website. Given I have a made a few before, and have had many people tell me they were very good, but I have been seeing these flash/animated websites with awsome intros and incredible naigation and layouts. So I was wondering if you could NAME every program/application that I would need to make one of these awsome sites. Not just free ones either, I am willing to pay any amount.
Which Graphics Package?
Lo guys, just wondering which graphics package is the best and more importantly, the most user friendly and compatable with flash?
I have paint shop pro 7 and adobe photoshop CS at the moment.
My main reason for asking is, I can edit an image in PSP and import it to flash but it automatically gets a white surround. Can I import layers into flash?
From Frame To Package
I had learn how to write code on the frame. As people says that it is better to write code on a separate .as file, which is a package. I tried to copy paste a piece of code that works well in the frame but not in the package. here it is:
Code:
import flash.events.*;
import flash.display.Stage;
import flash.display.MovieClip;
var gravitasi:int = 1;
stage.addEventListener(Event.ENTER_FRAME, buatbaru);
function buatbaru(e:Event):void {
var baru:lalatasli = new lalatasli();
addChild(baru);
baru.masuk();
baru.addEventListener(Event.ENTER_FRAME, baru.terbang);
}
and here are the errors:
1180: Call to a possibly undefined method addChild.
1120: Access of undefined property stage.
I have no idea why it works in the frame but not here.
thank you
Problems With The Fl.* Package
Sometimes I have trouble importing the "fl.controls.*" & "fl.containers.*" packages. I'm assuming it's a problem w/ everything in the "fl.*" package???
is this a common problem? Sometimes it happens and sometimes it doesn't???
How Do I Put More Than 1 Class Into A Package?
Every time I try to put more than one class into an external package I get an error at runtime:
Code:
5006: An ActionScript file can not have more than one externally visible definition: sampleBitmapTri, draggableClip
Here is my code which is causing this:
Code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class draggableClip extends MovieClip {//drag a movieclip
public function draggableClip():void {
trace("draggableClip class constructor called!");
}
public function registerClip(MC):void {
trace("registering MC :"+MC.name);
MC.pointNumTXT.text = MC.name;
MC.addEventListener(MouseEvent.MOUSE_UP, thisMouseUp);
MC.addEventListener(MouseEvent.MOUSE_DOWN, thisMouseDown);
}
private function thisMouseDown(event: MouseEvent):void {
trace("clicked: "+event.target.name);
event.target.startDrag();
}
private function thisMouseUp(event: MouseEvent):void {
event.target.stopDrag();
}
}//drag a movieclip
public class sampleBitmapTri {//sample a triangle from bitmapData
public function sampleBitmapTri():void {
}
}//sample a triangle from bitmapData
}
I have read through an adobe article about this...but the explanation was not very clear to me.
Could somebody please let me know what I'm doing wrong?
Thanks in advance,
David
Array In A Package?
I've got this package that sets up an array, but right now the actual array is on a frame in my timline. Is it possible to include the array in this package? If so, how do I do it?
PHP Code:
package {
public class oFish{
public var creature:Class;
public var popName:String;
public var sciName:String;
public var desc:String;
public var habitat:String;
public var eat:String;
public var web:String;
public var hurt:String;
public function oFish(oCreature:Class, oPopName:String, oSciName:String, oDesc:String, oHabitat:String, oEat:String, oWeb:String, oHurt:String):void{
this.creature = oCreature;
this.popName = oPopName;
this.sciName = oSciName;
this.desc = oDesc;
this.habitat = oHabitat;
this.eat = oEat;
this.web = oWeb;
this.hurt = oHurt;
}
}
}
Help With Package Import
I'm having trouble importing packages.
I have the following:
import com.xfactorstudio.xml.xpath.*;
at the top of a class I am writing. The folder com has been placed in the Classes directory of my Local Settings dir path (this is Windows, Flash 8).
In my class, I have the following:
private function loadConfig()
{
this.f_configXml = new XML();
this.f_configXml.ignoreWhite = true;
this.f_configXml.onLoad = function(success)
{
if(success)
{
var myResult = Xpath.selectNodes(this,'/config');
trace(myResult);
}
else
{
trace("Load of config file failed.");
}
}
trace("Attempting to load config...");
this.f_configXml.load(this.f_path);
}
When I try and compile, I get the following error:
There is no method with the name 'Xpath'.
var myResult = Xpath.selectNodes(this,'/config');
This package is in Flash 8's global Class path. Does anyone have any idea why its class members can't be imported?
Thanks!
Interface In A Package
I have a very simple interface in a package:
Code:
interface Package1.ITradeUpdateSubscriber
{
function tradeUpdate(trade:Package1.Trade, updateType:String):Void;
}
but when I validate the syntax it gets upset saying "The class or interface 'Package1.Trade' could not be loaded."
Now this is very strange as Package1.Trade exists, and works fine in my app (I could include the code, but I don't see the point).
Both the ITradeUpdateSubscriber.as and Trade.as exist in a folder 'Package1' at the root of my application and if I take the Interface out of the package and place it at the root of the application it then works ... but I want it in my package.
Any clever boy or girls want to help me on this one?
Can Interfaces not go in packages or something?
Import Package?
OK i understand how to import document classes. But how do I import other packages. I was given a package code on here pertaining to another question now I want to import it into a fla file so I can use it and learn how it works, so that I can modify it to work with the project I am working on.
Here is the code, now where do I save it and how do I import it.
I currently have it saved at c:\flashASactionScriptPowerbutton
Code:
package flashAS.actionScript.powerButton
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class PowerButton extends Sprite
{
private const POWER_OFF_DELAY : Number = 4 * 1000;
private var powerButton : Sprite;
private var isPowerOn : Boolean;
private var powerOffTimer : Timer;
public function PowerButton() {
init();
}
private function init() : void {
//Draw Red (powered off) power button
// and initiate power state
drawPowerButton(0xFF0000);
isPowerOn = false;
//Setup Timer
powerOffTimer = new Timer(POWER_OFF_DELAY,1);
//Add Power Button interactivity
addPowerButtonInteractivity();
}
private function drawPowerButton(buttonColor:uint = 0x000000) : void {
//Initiate if not
if (!powerButton) {
powerButton = new Sprite();
powerButton.x = stage.stageWidth/2;
powerButton.y = stage.stageHeight/2;
addChild(powerButton);
}
//Clear Button
powerButton.graphics.clear();
//drawButton
powerButton.graphics.beginFill(buttonColor);
powerButton.graphics.drawCircle(0,0,50);
powerButton.graphics.endFill();
}
private function addPowerButtonInteractivity() : void {
//Look like a button
powerButton.buttonMode = true;
//Listen for clicks
powerButton.addEventListener(MouseEvent.MOUSE_DOWN, powerButtonDown_handler);
powerButton.addEventListener(MouseEvent.MOUSE_UP, powerButtonUp_handler);
//Listen for the powerOffTimer
powerOffTimer.addEventListener(TimerEvent.TIMER_COMPLETE, powerOffTimer_complete);
}
private function powerButtonDown_handler(e:MouseEvent) : void {
if (isPowerOn) {
//Power is already on so
// start powerOff Timer.
powerOffTimer.start();
}
else {
//Power is already off so
// turn the power on.
drawPowerButton(0x00FF00);
isPowerOn = true;
}
}
private function powerButtonUp_handler(e:MouseEvent) : void {
if (powerOffTimer.running) powerOffTimer.reset();
}
private function powerOffTimer_complete(e:TimerEvent) : void {
//Power off machine if the powerOffTimer completes
drawPowerButton(0xFF0000);
isPowerOn = false;
}
}
}
Import statement
Code:
import PowerButton
and
Code:
import flashAS.actionScript.powerButton
And
Code:
import flashAS.actionScript.powerButton.PowerButton
all produce similar error message
Code:
1172: Definition powerButton could not be found.
1172: Definition powerButton could not be found.
Using Mx.modules Package
I am working in an ActionScript Project. In this project my need is to use mx.modules package so that I can implement Shell/Module concept in my project. For Shell/Module concept please refer this link:
http://blogs.adobe.com/rgonzalez/flex/
I tried to use it, but most of the part is in MXML. The package mx.modules.Module is not accessible in ActionScript Project. Does any body have used it.
Any reference to implement Shell/Module pattern. ...
Problem With My Package?
ok i have an as file im writing..
it looks like this so far
ActionScript Code:
package ATIscripts {
import flash.printing.PrintJob;
import flash.printing.PrintJobOrientation;
import flash.display.Stage;
import flash.display.Sprite;
import flash.text.TextField;
import flash.geom.Rectangle;
public class printMovie extends Sprite {
public function printMovie(slides:Array) {
var my_pj:PrintJob = new PrintJob();
if (my_pj.start()) {
var i:Number;
for(i=0;i<slides.length;i++){
trace(slides[i][0]);
trace(slides[i][1]);
trace("------------");
}
}
}
}
}
ok fine, and my flash file looks like this
ActionScript Code:
import ATIscripts.printMovie
var slides:Array = new Array(["mov","1"],
["mov2","34"]
)
printMovie(slides);
when i publish i get the compiler error
location: printMovie.as description: Call to a possibley undefined method addFrameScript
im so confused.. what addFrameScript?
GOD DAMN MIGRATION
Cannot Nest Package?
I have a feeling this is a really simple problem, but i just can't figure it out. When i try to write a class in an actionscript file, and then include it in a fla, I get an error message
1037: packages cannot be nested.
what am i doing wrong?
How To Extend A Package
I'm not an expert on OOP (as you'll see) and I'm making a GUI using AS3 and Colin Moock's implementation of the MVC paradigm and want to streamline this and future production by creating a set of superclasses which I'll extend on a project by project basis.
I've added the main folder that houses these classes to my Classpath in Flash's ActionScript 3.0 settings. Let's say the fully-qualified name for that package is fully.qualified.packagename. And suppose the main class for the application is Interface. I have an FLA in another part of my hard drive entirely, and I'm able to use the package via its fully-qualified name, putting fully.qualified.packagename.Interface as the document class. No problem there.
Where I'm ignorant and run into problems is in trying to extend this package, to create another local one that inherits from the individual model, view and controller classes of the original package. Any advice on how to do that? Part of my problem is that I don't really understand the use of the "package" keyword and don't know where/how it is necessary.
"MOBS" is the acronym for the project I'm working on (no, it doesn't stand for "Multiple Orbital Bombardment System" ). There's a folder next to my Flash movie called "mobs_interface", which contains the subclasses. Within it, I've created a MobsInterface.as which I'm using as the Document class for my flash movie - mobs_interface.MobsInterface - and it uses/references the nearby subclasses rather than the original ones.
For the moment, these "subclasses" are not subclasses at all, but just have different names from the original classes. Everything still compiles.
But, I'm in the process of making them subclasses, so suppose I take one of those component classes and try to inherit from the original package in the most minimal way:
ActionScript Code:
package mobs_interface{
import fully.qualified.packagename.*;
class MobsInterfaceModel extends InterfaceModel {
public function MobsInterfaceModel() {
//super();
}
}
}
Well, I'm getting the message that it can't find the definition for the InterfaceModel class, even though I've imported fully.qualified.packagename.InterfaceModel. I know that compiler errors can be very cryptic and that my problem probably lies elsewhere but I'm not sure where to start.
I don't think anyone here needs to solve my particular problem for me, but if someone could direct me to a specific technote or tutorial for extending a package like this, I'd be most grateful. If you've read this far, thanks for doing even that much!
PHP Mailer Package
Hi, I wanna set a "mailer form" package with a php file and I want to send variables dinamically without writing everytime all the fileds to pass to php.
This is the as3 function:
Code:
var campi:Array = new Array("name", "surname", "mail");
function spedisci(){
var pathFile:String = "php/mailer.php";
var requestUrl:URLRequest = new URLRequest(pathFile);
var loader:URLLoader = new URLLoader();
for(var n:Number = 0; n<campi.length; n++){
var trg = getChildByName("input"+n);
var appoggio = campi[n]"="+trg.text;
trg.text = "";
requestUrl.method = URLRequestMethod.POST;
requestUrl.data = variables.appoggio;
}
loader.load(requestUrl);
}
This won't works... I tried to set up an URLVariable called variables and tried to do this:
Code:
var appoggio = campi[n];
variables.appoggio = trg.text;
but the result was:
variables.appoggio=blablabla
variables.appoggio=lalalalala
variables.appoggio=yuyassg
.
.
.
WHY??? Obviusly if on the campi array I'll have "name", "surname", "email" on the php file I'll have $name = $_POST['name'] ecc ecc
Package Naming
Hi all, im new to this actionscript thing, and am currently learning from a book, just the basics.
Anyway, im doing pretty well, but theres one concept that always causes me trouble, naming packages. No matter what i do i always get the 5001 error telling me the code doesnt reflect the class path.
Here is an example:
package com.foundationAS3.ch6 {
import flash.display.GradientType;
import flash.display.Shape;
import flash.display.Sprite;
public class LineGradientTest extends Sprite {
public function LineGradientTest(){
//Creatre and center ellipse shape on stage
var ellipse:Shape = new Shape();
addChild(ellipse);
ellipse.x = stage.stageWidth / 2;
ellipse.y = stage.stageHeight / 2;
//Set basic line style
ellipse.graphics.lineStyle(30);
//Set up gradient properties
var colors:Array =
[
0xFF0000,
0xFF6600,
0xFFFF00,
0x00FF00,
0x0000FF,
0x2E0854,
0x8F5E99
];
var alphas:Array = [1,1,1,1,1,1,1];
var ratios:Array = [0,42,84,126,168,210,255];
//Set gradient line style
ellipse.graphics.lineGradientStyle(GradientType.LI NEAR, colors, alphas, ratios);
//Draw ellipse
ellipse.graphics.drawEllipse(-100, -50, 200, 100);
}
}
}
The flash file is called lineGradient.fla and the one coded here is called LineGradientTest.as
Now, when I try to compile this, get this error:
5001: The name of package 'com.foundationAS3.ch6' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. C:Users(Myname)foundationAS3ch6LineGradientTe st.as
also, when I change the Document Class in the fla file, I get the warning that the class cannot be found and saying it has to make a new one.
The path there says its in the documents, but its not, its in C:foundationAS3ch6, which is what I have the class path set to as well.
Anyone wanna shed some light on this?
Oh, and the code works fine apart from the package thing.
Using My Custom Package?
Hi --
I have created some code in Flash CS3 using AS 3.0 to create form elements
dynamically but now I am having trouble accessing the package I have created
from another Flash movie.
My package setup is like this...
package formbuilder
{
public class forms
{
public function createCheckBox() {
}
}
}
The AS file is saved as FormElements.as
and I am attempting to call the package like this
import FormElements
This seems to work as the IDE had me make some small changes to the code
when I first tested my movie.
However, once I have added this code:
var useForm:forms = new forms()
I get an error, "1046: Type was not found or was not a compile-time
constant: forms."
I am not sure if I need to have my package name and my file name the same?
Do I need to change my import statement? Do I need to change my call? Do I
need to add a constructor to the package?
Please help!!
Thanks
Rich
Package Names
Having trouble naming a package.
I put it in a folder called "electionMap" but it still gives me a
"does not reflect the location of this file" error.
This is the code:
package electionMap
{
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.Font;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
public class Morrow extends MovieClip
{
// this event listener had to be within its own function to work
// this is a constructor
public function Morrow()
{
addEventListener(MouseEvent.CLICK , myFunction); // calls the next function if morrow is clicked
}
private function myFunction(event:MouseEvent):void
{
trace("Morrow is clicked");
}
}
}
Importing As Package
Hello Everyone. Up until now I've done all my actionscript coding directly on the timeline. However I would like to get into the habit of creating packages and importing them into my flash file. So heres the basic setup I have now, and perhaps someone can weigh in as to what I need to do to make it work.
the fla file is called:
mouse follow2.fla
the as file is called:
dynamicmouse.as
the package name is:
dynamicmouse
the class name is:
FollowMouse
the constructor looks like:
public function FollowMouse(strObj:String,originx:Number,originy:Number,originh:Number,originw:Number) {
now on the fla file, the document properties I've set the Document Class to:
dynamicmouse.FollowMouse
(as file and fla file are in the same directory by the way)
in the action script code on the fla file:
import dynamicmouse;
FollowMouse("mcShape01",mcShape01.x,mcShape01.y,mcShape01.height,mcShape01.width);
this results in the error:
Incorrect number of arguments. Expected no more than 1.
Incase your interested below is the package contents in full, I'm not even completely sure if its set up correctly, but I would expect that the function call at least is syntaticly correct. Any help/advice in this matter is appreciated. In retrospect I should have started with a much simpler project to pull in my first package but oh well.
heres the package in full:
Attach Code
package dynamicmouse{
import flash.display.*;
import flash.events.*;
public class FollowMouse extends Sprite {
//the starting positions/dimentions to base the movement off of
public var OriginX:Number;
public var OriginY:Number;
public var OriginH:Number;
public var OriginW:Number;
private var CenterX:Number;
private var CenterY:Number;
internal var Temp:Number;
//the multipler used to figure out how far the movie clip should move off starting position.
//smaller number moves the movie clip less, larger number moves the movie clip more.
//1 will put the symbol on the level of the mouse, 0 will not move it at all.
public var multX:Number = 1;
public var multY:Number = 1;
//set limits, how far can the eye move off of its starting positions
public var Limit:Boolean = false;
public var LimitXLeft:Number = 50;
public var LimitXRight:Number = 50;
public var LimitYTop:Number = 50;
public var LimitYBottom:Number = 50;
public function FollowMouse(strObj:String,originx:Number,originy:Number,originh:Number,originw:Number) {
//Set the object that needs to be manipulated
//var disObj:DisplayObject = parent.getChildByName(strObj);
//if (disObj == null) {
//try { disObj = parent[strObj] as DisplayObject; }
//catch (e:*) {}
//}
//disObject = disObj;
this.OriginX = originx;
this.OriginY = originy;
this.OriginH = originh;
this.OriginW = originw;
this.CenterX = originx+(originw/2);
this.CenterY = originy+(originh/2);
this.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMovement);
}
function removeMouseListener():void {
//if (this == null) { return; }
this.removeEventListener(MouseEvent.MOUSE_MOVE,onMouseMovement);
}
function addMouseListener():void {
//if (this == null) { return; }
this.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMovement);
}
private function onMouseMovement(e:MouseEvent):void {
//if (this == null) { return; }
e.updateAfterEvent();
//compute x position
Temp = OriginX+((e.stageX-CenterX)*multX);
if (Limit = false) {
this.x = Temp;
} else if (Temp<(OriginX-LimitXLeft)) {
this.x = OriginX-LimitXLeft;
} else if (Temp>(OriginX+LimitXRight)) {
this.x = OriginX+LimitXRight;
} else {
this.x = Temp;
}
//compute y position
Temp = OriginY+((e.stageY-CenterY)*multY);
if (Limit = false) {
this.y = Temp;
} else if (Temp<(OriginY-LimitYTop)) {
this.y = OriginY-LimitYTop;
} else if (Temp>(OriginY+LimitYBottom)) {
this.y = OriginY+LimitYBottom;
} else {
this.y = Temp;
}
}
}
}
Create A Package
Can any one lead me to an example of how to create a package?
add a Main.as
package {
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Main extends MovieClip {
/**
*constructor.
*/
pulic function Main() {
}
public function timerHandler(event:TimerEvent):void {
preloadElement.rotation+=3;
}
}
}
[/code]
so I can begin to learn how to control the fla I created?
-Steve
Class Package
I have tried to add a button a .fla and code it with a packaged class (Main.as) with no luck
is it possible to use a button from the GUI and code it with a external imported packaged class?
-
Steve
Package In AS2.0 Problem
This is my problem.
I have classes witch resides in this package :com.network.interface_as.
When I try to load one class from that package in another class in the same package like this:
Code:
import com.network.interface_as.SomeClass_A
class com.network.interface_as.SomeClass_B{
private var class_A:SomeClass_A;
public function(){
class_A = new SomeClass_A();
}
}
I get error message that "class com.network.interface_as.SomeClass_A could not be loaded".
What am I doing wrong.
Package Organization
Hey Guys,
I have a quick question about package organization. Currently I have my fla in my main folder and all of my class files in a directory called Main_Core.
So with each class it starts with the code:
Code:
package Main_Core {
class MyClass {
//insert code
}
}
I'm getting to the stage where I have too many class files in that one folder for my organization levels to feel comfortable.
I'd like to organize it in the following heirarchy but I don't know how to word the syntax. Any help would be great!
Heirarchy: Bold is a folder, regular type is a class file which EXTENDS the previous level's class file. So MultipleClasses1 extends SubObjectTypeClass etc.
Main_CoreMainClass
Main_Objects
MainObjectClassSubObjectType1SubObjectTypeClass
SubSubObjectType1Multiple Classes1
Multiple Classes1
SubObjectType2SubObjectTypeClass
SubSubObjectType2Multiple Classes2
Multiple Classes2
Also if I wanted to instantiate a class that is nested in that heirarchy so for example in the MainClass I wanted to say "new MultipleClasses2()" do i need to put the package class before it?
Thanks again!
2 Classes In The Same Package
This migth be so basic that i am afraid to ask
Anyway
PHP Code:
package leprechan { public class c1{ var gh:int = 1; } public class c2{ var gh:int = 2; }}
saved as leprechan.as
and in the main timeline:
PHP Code:
import leprechan.c1;var c:c1 = new c1();
flash says:
]1172: Definition leprechan:c1 could not be found.
so how can i do that?I dont want a class to be kind of a helper to the other, i want them to be like MovieClip and Sprite inside the same package
More Classes Into One Package Or..
hi to all!
i got flash cs3 some days ago, so i'm really new to actionscript 3. seems powerfull and i'm willing to dive into it.
now, the first obstacle that i cannot pass (i googled it and searched in this forum) is: can i have more classes in one package? if not, where can i put the file secondClassName.as and how to call it in order to be able to include it from baseClassName.as?
thanks in advance.
Flash Package
Does anyone know if the flash package is exposed anywhere, or is it just built into the player? I'd like to have a look at e.g. flash.events.Event
Ta
Variables Outside A Package ?
Ok, I'm not sure what's the deal with this one but it's quite funny... I was a bit bored and played around in flash, I defined a var outside the package, and funnily it sees it... it works... could someone explain, why ? And what's the whole purpose of it ? Because I can't really understand why they let variables work outside packages, and since you can't control them by an access modifier, it's even funnier...
ActionScript Code:
package { import flash.display.Sprite; public class Test extends Sprite { public function Test():void { trace(crap); } } } var crap:String = "hello";
Thanks.
Net Tools Package?
For the AS3 apps that need to deal with loading/sending HTTP requests, I've written a little data-dealer class which can execute a sequence of GETs one after the other, running the results through some pre-decided listener functions. It's pretty good, but pretty basic.
I was wondering if anyone knows of a more mature one of these flash.net wrapper classes. Something with rich start/stop request functionality, etc.
I Want My Own Package Function
Hey guys. I know that this is not in the best practices manual, but I need to place a method DIRECTLY inside a package of mine. Pretty much like flash does with the as3 new flash.utils.* package methods.
Could anyone guide me on this ... I've been searching around hardly with zero results.
Tanks!
XML Package Slideshow
Wondering if someone could give me a hand with this:
I have a swf with a document class attached to it to run a XML driven slideshow. Everything seems to work fine when I go to test movie in flash CS3 but when I upload it to my root directory of the website ethier the XML or the .as document class isnt working because nothing is showing up. Any help with be very appriencated...
Also wondering if someone knows how to change the curr var to play the photos randomly.
Quote:
package
{
import flash.display.MovieClip;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.utils.Timer;
import fl.transitions.Tween;
import fl.transitions.easing.*;
public class slides extends MovieClip
{
var xmlLoader:URLLoader;
var theXML:XML;
var photos:XMLList;
var photoLoader:Loader;
var photoArray:Array;
var fade:Tween;
var curr:Number;
var timer:Timer;
var timey:timeDisplay;
public function slides():void
{
xmlLoader = new URLLoader();
xmlLoader.load(new URLRequest("photos.xml"));
xmlLoader.addEventListener(Event.COMPLETE, getXML);
photoArray = new Array();
curr = 0;
timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, switchPhoto);
timey = new timeDisplay();
timey.x = 235;
timey.y = 93.5;
}
private function getXML(e:Event):void
{
theXML = new XML(e.target.data);
photos = new XMLList(theXML.photo);
for(var i:int=0;i<photos.length();i++)
{
photoArray.push(photos[i].@url);
}
timer.start();
switchPhoto(null);
}
private function switchPhoto(e:TimerEvent):void
{
if(curr < photoArray.length)
{
photoLoader = new Loader();
photoLoader.load(new URLRequest(photoArray[curr]));
curr++;
photoLoader.contentLoaderInfo.addEventListener(Pro gressEvent.PROGRESS, showProgress);
photoLoader.contentLoaderInfo.addEventListener(Eve nt.COMPLETE, removeTimey);
}
else
{
curr = 0;
switchPhoto(null);
photoLoader.unload();
}
}
private function showProgress(erogressEvent):void
{
this.addChild(timey);
var perc:Number = Math.floor(e.bytesLoaded / e.bytesTotal * 100);
timey.timerText.text = perc + "%";
}
private function removeTimey(e:Event):void
{
this.addChild(photoLoader);
fade = new Tween(photoLoader,"alpha",None.easeNone,0,1,2,true );
}
}
}
Package Confusion
I have a 2 classes located in the same folder
fe:
com.furyan.dd.Main
com.furyan.dd.Link
Main I am using as the document class for a flash project.
In Main I am creating an instance of the Link class.
The package structure I defined for Link is
package com.furyan.dd {}
Now everytime I compile the .FLA I receive an error that the class Link is in a wrong location. I dont understand why?
I defined the Document class like this: com.furyan.dd.Main
Package Question
Hi guys,
I want to have two classes in a single .as file, one of the classes will only be visible to the main class in the file.
class QueItem{
...
}
class Que{
//only this class will use QueItem, no other classes will
}
Can I do that ? I tried a few syntaxes but it never works.
Thanks.
Problems With Package...
Hey!
So, Iattempted to create a package that is loaded into theEye.fla:
PHP Code:
package {
import flash.display.MovieClip;
public class theEye extends MovieClip {
Mouse.hide();
var maxMovement:Number = 20;
var ovality:Number = 4;
var origin = {x:eye.x, y:eye.y};
var xdiff, ydiff, radius, angle : Number;
public function theEye() {
addEventListener(MouseEvent.MOUSE_MOVE, theEye);
addEventListener(Event.ENTER_FRAME, frame);
function theEye(evt:MouseEvent):void {
pointer.x = mouseX;
pointer.y = mouseY;
xdiff = mouseX - origin.x;
ydiff = mouseY - origin.y;
radius = Math.min(Math.max(Math.sqrt(xdiff * xdiff + ydiff * ydiff) / ovality, 0), maxMovement);
angle = Math.atan2(ydiff,xdiff);
eye.x = Math.cos(angle) * radius * ovality + origin.x;
eye.y = Math.sin(angle) * radius * ovality + origin.y;
}
function frame(evt:Event):void {
if(pointer.hitTestObject(center) && eye.currentFrame != eye.totalFrames) {
eye.nextFrame();
center.nextFrame();
}
else if(!pointer.hitTestObject(center) && eye.currentFrame != 1) {
eye.prevFrame();
center.prevFrame();
}
}
}
}
}
but when i try run it, I get the following errors:
Type was not found or was not a compile-time constant: MouseEvent
Type was not found or was not a compile-time constant: Event
Package In AS2.0 Problem
This is my problem.
I have classes witch resides in this package :com.network.interface_as.
When I try to load one class from that package in another class in the same package like this:
Code:
import com.network.interface_as.SomeClass_A
class com.network.interface_as.SomeClass_B{
private var class_A:SomeClass_A;
public function(){
class_A = new SomeClass_A();
}
}
I get error message that "class com.network.interface_as.SomeClass_A could not be loaded".
What am I doing wrong.
Build Your Own Package
Hello all!
I've been an Ultrashock viewer for quite some time and felt that it's a great place to research and find a lot of useful information for Flash. This being my first post, I have confidence I'll find an answer.
I want to put together a "Build Your Own Package" form in a flash web page where the user can select from items, number of items, and it changes the price of the final "custom" package on the fly.
I eventually would like to have it display their "custom" package on a page that they could print out outlining the details they have selected.
How would one go about doing this?
Thanks!
[AS3] Package Functions
Hi guys,
Does anyone know if it is possible to create custom 'package functions' similar to setTimeout and clearTimeout etc?
AS3 - I Want My Own Package Function
Hey guys. I know that this is not in the best practices manual, but I need to place a method DIRECTLY inside a package of mine. Pretty much like flash does with the as3 new flash.utils.* package methods.
Could anyone guide me on this ... I've been searching around hardly with zero results.
Tanks!
I Want My Own Package Function
Hey guys. I know that this is not in the best practices manual, but I need to place a method DIRECTLY inside a package of mine. Pretty much like flash does with the as3 new flash.utils.* package methods.
Could anyone guide me on this ... I've been searching around hardly with zero results.
Tanks!
How To Import A Package
I get this error
1037: packages cannot be nested
I understand that this means I cannot post code that uses packages in the actionscript layer
so.. I saved my code as "script.as" in folder: "com"
the syntax I tried in the new fla file is:
import com.script;
No good.
Do I also need to call a function to make it run
What is the syntax?
Whats A Good 3d Package...?
hi all,
whats a good web based 3d package that easy enough to learn. Im very new to the 3d software environment.
Cheers,
dvdvault
|