Hi i have looked up a lot of answers but havnt been able to fix my problem. I am using external actionscript and i have used the following code:
package
{
import flash.display.MovieClip;
import flash.net.*;
import flash.events.*;
import flash.display.Loader;
import fl.motion.MotionEvent;
import flash.ui.Mouse;
public class submenu1 extends MovieClip
{
private var movieLoader:Loader;
//everything in this function is exicuted when you start the application
public function submenu1()
{
movieLoader = new Loader();
image3_btn.addEventListener(MouseEvent.MOUSE_DOWN,addMovie);
image4_btn.addEventListener(MouseEvent.MOUSE_DOWN,addMovie);
exit_btn.addEventListener(MouseEvent.MOUSE_DOWN,closeTheMovie);
}
private function addMovie(e:MouseEvent)
{
if(e.target.name=="image3_btn")
{
loadTheMovie("image3");
}
else if(e.target.name=="image4_btn")
{
loadTheMovie("image4");
}
}
private function loadTheMovie(m:String)
{
var movieRequest:URLRequest = new URLRequest("../swf/" + m + ".swf");
movieLoader.load(movieRequest);
addChild(movieLoader);
}
private function closeTheMovie (e:MouseEvent)
{
removeChild(movieLoader);
exit_btn.addEventListener(MouseEvent.MOUSE_DOWN,closeTheMovie);
}
}
}
I can get the sub movie to open but i cant get the exit_btn to close the sub movie and return to the original. I am wanting the exit_btn when clicked to remove the child and take you back to the texture page. The flash itself doesn't bring up any errors just the button wont work. Any suggestions?
Did you export to actions script your exit buttons? Right click on the exit button then choose properties and then click on the box called export for actionScript.
Related
My code always gave me an error in the electron console, however the same code did not give me an error in a web browser:
import React, { Component } from 'react';
import { Router, Route, Link, browserHistory ,hashHistory} from 'react-router'
import { render } from 'react-dom';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import injectTapEventPlugin from 'react-tap-event-plugin';
import { RaisedButton } from 'material-ui';
class App extends Component {
render() {
return (
<MuiThemeProvider>
<RaisedButton className="submit" label='xxxxxxx' labelColor="#fff" backgroundColor="#32a62e"></RaisedButton>
</MuiThemeProvider>
)
}
}
injectTapEventPlugin();
let rootElement = document.getElementById('containers');
render(
<App/>,
rootElement
)
You need to add
import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();
to the top level of your javascript files as explained in this page of the documentation . It's because there is a dependencey on this module for onTouchTap to work So move it up before the class definition or to the top js file you have.
I have a document class with this function on it, it targets a symbol with an instance name of scene4_headlights on the stage:
function accUpdate(e:AccelerometerEvent):void{
scene4_headlights.rotation += (e.accelerationX*10);
}
But I keep getting error 1120: Access of undefined property scene4_headlights even though I have a symbol on the stage with the instance name of scene4_headlights..
Help?
Here you go:
package {
import flash.sensors.Accelerometer;
import flash.events.AccelerometerEvent; //importing everything you need is cruicial
import flash.display.MovieClip;
public class CustomClassName extends MovieClip //your custom class can extend the type of class you used to create your scene4_headlights instance (some prefer using Sprite when the timeline is not required)
{
private var accelerometer = new Accelerometer(); //declare a variable data type: Accelerometer
public function CustomClassName() {
// constructor code
accelerometer.addEventListener(AccelerometerEvent.UPDATE, accUpdate); // add an eventlistener to the variable you just created
}
public function accUpdate(e:AccelerometerEvent): void //declare the function handling the eventlistener
{
scene4_headlights.rotation += (e.accelerationX*10);
trace("The function accUpdate is linked properly"); //trace is your friend
}
}
}
I have an application developed in ggts with grails/groovy and there are users with different roles. I want to test if a user can access some parts of the application by directly inserting link into address bar. So, where is my problem? When I test my application on localhost, everything is OK. But when I want to test through http://shopapp then it isn't OK. The application is the same.
Here is my code:
LoginSpec.groovy
import geb.spock.GebReportingSpec
import spock.lang.*
import pages.*
#Stepwise
class LoginSpec extends GebReportingSpec {
def "opage"() {
when:
to LoginPage
loginUser()
acceptButton.click()
then:
to ProductPage
}
}
ProductPage.groovy
package pages
import geb.Browser
import grails.util.Holders
class ProductPage extends ScaffoldPage {
def config = org.codehaus.groovy.grails.commons.ConfigurationHolder.config
static url = {config.grails.serverURL + "/shop/catalog/show/123"}
static at = {
waitFor { title ==~ /Products/ }
title ==~ /Products/
}
static content = {
}
}
config.grails.serverURL should be http://shopapp.
When I start the test, it opens http://shopapp/login, the user logs in and the home page opens. But then it stays on home page. It should go to http://shopapp/shop/catalog/show/123 because I want to test if a user can access a product by directly inserting a link into address bar.
Please help, I don't have any more ideas.
Thanks.
The static url property should be a string, not a closure:
static url = config.grails.serverURL + "/shop/catalog/show/123"
I've had a great deal of success using the DevGirl XpenseIt solution offered by Jason Sturges in response to a couple of other requests for help with this: (http://stackoverflow.com/questions/11812807/take-photo-using-adobe-builder-flex-for-ios being the best example)
Great success except that between the time you press the 'Use' button in iOS6 after taking a photo using the CameraUI and the util class from the tutorial, it takes fully 47 1-hippopotamus, 2 hippapotamusses until the 'fileReady' event occurs.
It doesn't seem, to my mind that it should take the Loader class that terribly long.
Is there something I can do to improve this performance? I'm forced to add a hurry-up-and-wait UI element so my users won't think the program has hung. Here's the code of the CameraUtil.as from the above as I'm currently using it.
// http://stackoverflow.com/questions/11812807/take-photo-using-adobe-builder-flex-for-ios
package classes
{
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.events.MediaEvent;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.media.CameraRoll;
import flash.media.CameraUI;
import flash.media.MediaPromise;
import flash.media.MediaType;
import flash.utils.ByteArray;
import mx.graphics.codec.JPEGEncoder;
import events.CameraEvent;
[Event(name = "fileReady", type = "events.CameraEvent")]
public class CameraUtil extends EventDispatcher
{
protected var camera:CameraUI;
protected var loader:Loader;
public var file:File;
public function CameraUtil(target:IEventDispatcher=null)
{
super(target);
if (CameraUI.isSupported)
{
camera = new CameraUI();
camera.addEventListener(MediaEvent.COMPLETE, mediaEventComplete);
}
} // End CONSTRUCTOR CameraUtil
public function takePicture():void
{
if (camera)
camera.launch(MediaType.IMAGE);
} // End FUNCTION takePicture
protected function mediaEventComplete(event:MediaEvent):void
{
var mediaPromise:MediaPromise = event.data;
if (mediaPromise.file == null)
{
// For iOS we need to load with a Loader first
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleted);
loader.loadFilePromise(mediaPromise);
return;
}
else
{
// Android we can just dispatch the event that it's complete
file = new File(mediaPromise.file.url);
dispatchEvent(new CameraEvent(CameraEvent.FILE_READY, file));
}
} // End FUNCTION mediaEventComplete
protected function loaderCompleted(event:Event):void
{
var loaderInfo:LoaderInfo = event.target as LoaderInfo;
if (CameraRoll.supportsAddBitmapData)
{
var bitmapData:BitmapData = new BitmapData(loaderInfo.width, loaderInfo.height);
bitmapData.draw(loaderInfo.loader);
file = File.applicationStorageDirectory.resolvePath("receipt" + new Date().time + ".jpg");
var stream:FileStream = new FileStream()
stream.open(file, FileMode.WRITE);
var j:JPEGEncoder = new JPEGEncoder();
var bytes:ByteArray = j.encode(bitmapData);
stream.writeBytes(bytes, 0, bytes.bytesAvailable);
stream.close();
dispatchEvent(new CameraEvent(CameraEvent.FILE_READY, file));
}
} // End FUNCTION loaderComplete
} // End CLASS CameraUtil
} // End PACKAGE classes
I was able to solve my delay problem by removing a step from the process. This step is one I myself do not need (at the present time) but others may, so removing it is not really an answer to the question of 'why does this process that seems reasonable take what seems an unreasonable amount of time.
I needed the BitmapData, not an external file so instead of:
Camera => [snap] => Media Promise => Loader => Write File => Event => Read File => Use BitmapData
I rewrote the class to cut out the File/AppStorage i/o.
Camera => [snap] => Media Promise => Loader => Use BitmapData
and so a very reasonable (and expected amount of comp time).
I am still surprised however that it takes such a long time to write the data to a file using the method used in the CameraUtil class. I do need to write these images out to files, but not until the user has reduced the size to a 1024x768 crop area and I encode them into a very compressed jpg, so hopefully I'll only struggle with a smaller portion of the hang/comp time.
Anybody know... Should it take so very long to write 1 file to application storage in iOS from Adobe AIR (via flex)?
I found this process painstakingly slow, too ...
However, it seems the JPEGEncoder is contributing a lot to this delay.
You can speed up the process a lot using the optimized Encoder that can be found here.
http://www.bytearray.org/?p=775
Depending on your device it is about 2 to 4 times faster than the original one.
Another step that can be omitted is the bitmapData.draw(), which is slow as well, by using the Loader.content directly. This way you skip the instantiation of another bitmap instance, which will blowup memory usage.
Like this:
protected function loaderCompleted(event:Event):void
{
var loader:Loader = (event.target as LoaderInfo).loader;
var bitmap:Bitmap = loader.content as Bitmap;
(...)
}
Still, I'm waiting for somebody to write an iOS .ane which should be able to encode a jpg in a few ms instead of seconds. But in the meantime... ;)
I am trying to get this to work for ages but doesnt seem to work out quite well
this is my code:
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Loader;
import flash.net.URLRequest;
var cola:Loader;
cola = new Loader()
cola.load(new URLRequest("resources/colabar.swf"));
this.addChild(cola);
//cola.currentLabel = "frame1";
This works. The .swf is in my stage now. Moving from frame to frame.
Obiously, when deleting the // its not working. And ill get this error message: 1119: Access of possibly undefined property currentLabel through a reference with static type flash.display:Loader.
Try this:
cola.contentLoaderInfo.addEventListener(Event.COMPLETE, colaCompleteHandler);
...
function colaCompleteHandler(event:Event):void
{
var loader:Loader = LoaderInfo(event.target).loader;
var mc:MovieClip = loader.content as MovieClip;
if (mc) {
mc.gotoAndPlay("frame1");
}
}
i.e. wait for the SWF to load, then set the label.