I am trying to import my original package.
But it is said that there is no class files form Akirasda1972_001.as.
My package file is uploaded on sexydesign.club/particle/.
package{
import flash.display.Sprite;
import club.sexydesign.particle.Akirasada1972_001;
public class akirasada1972_002 extends Sprite{
private var akirasada1972_001:Akirasada1972_001;
public function akirasada1972_002():void{
akirasada1972_001=new Akirasada1972_001();
akirasada1972_001.Akirasada1972_001();
addChild(akirasada1972_001);
}
}
}
Related
I have two classes and i tried event dispatch from one class to other class. Here i have used button to invoke the class. But dispatch not working.
class name cusDispatcher.as
package
{
import flash.display.MovieClip;
import flash.events.EventDispatcher;
import flash.events.Event;
import flash.events.MouseEvent;
import Globe;
public class CusDispatcher extends EventDispatcher
{
public function CusDispatcher():void
{
Globe.self.realstage.btn_mc.addEventListener(MouseEvent.CLICK,
doAction);
}
public function doAction(event:MouseEvent):void
{
dispatchEvent(new Event('myevent'));
}
}
}
class name EventDispatcherExample.as
package
{
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.EventDispatcher;
import Globe;
public class EventDispatcherExample extends EventDispatcher
{
public function EventDispatcherExample(Mc:MovieClip)
{
Globe.self.realstage = Mc;
var start:CusDispatcher = new CusDispatcher();
Globe.self.realstage.addEventListener('myevent', handler);
trace("one");
}
public function handler(event:Event):void
{
trace("My Event");
}
}
}
In the adobe CC i used this instance to run the class
var Call:EventDispatcherExample = new EventDispatcherExample(this);
Whenever i click the button(btn_mc) in the adobe flash cc it does not show any
trace of dispatch event.So could please analyze and give solution for this one.
Is your other click listener (in the EventDispatcherExample) working?
The problem might be that you have declared your CusDispatcher as a local variable within a function
var start:CusDispatcher = new CusDispatcher();
Once the function is complete these variables are cleaned up. Try to declare it at the beginning of your class as a class variable:
private var start:CusDispatcher;
public function EventDispatcherExample(Mc:MovieClip)...
and then assign your new Dispatcher to it
start = new CusDispatcher();
I am using Flash Builder 4.7 and have created a Worker Class. Below is the code:
package co.fuix.mobile.system.model
{
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.events.Event;
import flash.system.MessageChannel;
import flash.system.Worker;
import flash.utils.getDefinitionByName;
import mx.managers.SystemManager;
public class InstantMessengerWorker extends Sprite
{
private var bm:MessageChannel;
private var mb:MessageChannel;
public function InstantMessengerWorker()
{
super();
bm = Worker.current.getSharedProperty("BACK_TO_MAIN_CHANNEL");
mb = Worker.current.getSharedProperty("MAIN_TO_BACK_CHANNEL");
mb.addEventListener(Event.CHANNEL_MESSAGE, onMainToBack);
}
protected function onMainToBack(event:Event):void
{
if(mb.messageAvailable){
var s:SystemManager;
trace('*'+mb.receive());
trace('**'+mb.receive());
trace('***'+mb.receive());
trace(mx.core.FlexGlobals.topLevelApplication.myVariable);
}
}
}
}
How do I reference a variable in the main mxml file. I know how to use message channels but I want to get that variable straight.
When I run the above code, this part
trace(mx.core.FlexGlobals.topLevelApplication.myVariable);
is giving me an error.
Any help will be regreatly appreciated
You can't access a variable from the main app like that. They are running separately. What you need to do is:
Link to Adobe docs
I've only recently started using as so sorry for this
as its probably pretty simple. Im basically trying to spawn an AI unit but am getting the error 1009, here is the full error.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at code::Init()[D:\FlashGame\code\Init.as:21]
Im trying to use a function from another class which is in another file. Here is the first file.
package code
{
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.MouseEvent;
import flash.text.TextField;
import code.functions.AIManager;
public class Init extends MovieClip
{
private var _AI:AIManager;
private var _player:MovieClip;
public function Init()
{
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
_AI.createAI();
}
public function enterFrameHandler(event:Event):void
{}
}
}
And the second file..
package code.functions
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.DisplayObjectContainer;
public class AIManager extends MovieClip
{
private var _ai:MovieClip;
public function AIManager()
{
createAI();
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
public function createAI():void
{
_ai = new AI();
_ai.x = stage.stageWidth / 2;
_ai.y = stage.stageHeight / 2;
stage.addChild(_ai);
}
You need to create an instance of a class before you can use it's methods. The exception to that is static methods. In your case you just need to use new AIManager
_AI = new AIManager();
_AI.createAI();
I'm trying to access a function I've defined in an .as file I've imported. However, I keep getting error 1084. Can somebody please tell me what I'm doing wrong?
Here is the code from my .fla file:
import .com.script.Script.as.*;
var a = new draggable();
Here is the code from my .as file:
package com.script{
import flash.display.Sprite;
import flash.events.*;
public class Script {
public var value:Number;
private var max:Number;
private var min:Number;
function draggable() {
min=bar_mc.y;
max=bar_mc.height-Erhu_H3_btn.height;
toErhu_H3_btn.addEventListener(MouseEvent.MOUSE_DOWN, dragHandle);
}
}
}
Try this code.
your .fla file
import com.script.Draggable;
var a = new Draggable();
Here is the code from your .as file:
package com.script{
import flash.display.*;
import flash.events.*;
public class Draggable{
public var value:Number;
private var max:Number;
private var min:Number;
public function Draggable(){
min=bar_mc.y;
max=bar_mc.height-Erhu_H3_btn.height;
toErhu_H3_btn.addEventListener(MouseEvent.MOUSE_DOWN, dragHandle);
}
}
}
package
{
import flash.display.MovieClip;
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.SimpleButton;
public class PencereyiGizle extends MovieClip
{
public var natWindow:NativeWindow=new NativeWindow(
new NativeWindowInitOptions());
public var pencereyiAc_Btn:Button;
public function PencereyiGizle(fro:Button)
{
pencereAc_Btn = fro;
//Pencere ekleniyor
natWindow.width = 500;
natWindow.height = 400;
natWindow.activate();
natWindow.addEventListener(Event.CLOSING,pencereyiSakla);
pencereyiAc_Btn.label = "Pencereyi Ac";
pencereyiAc_Btn.addEventListener(MouseEvent.MOUSE_DOWN,pencereyiAktifEt);
}
//pencerenin kapanmasını engelleyip pencereyi gizliyoruz.;
private function pencereyiSakla(e:Event):void
{
e.preventDefault();
natWindow.visible = false;
}
//gizlenen pencereyi tekrar aktif hale getiriyoruz
private function pencereyiAktifEt(e:MouseEvent):void
{
natWindow.activate();
}
}
}
IN AIR;
import PencereyiGizle;
var firat:PencereyiGizle= new PencereyiGizle();
addChild(firat);
and then, i get that problem "1046: Type was not found or was not a compile-time constant:Button. "
Based on what is in your imports, I think you want to use the SimpleButton class and not the Button class. (Which is a flash component)
Either that or you are missing this import
import fl.controls.Button;
Here is an artilce from adobe on the button component.
http://www.adobe.com/devnet/flash/quickstart/button_component_as3.html